Check Payment

Check a Payment

The CheckPayment method allows you to check the status of an existing payment transaction.

This is crucial for confirming whether a payment has been successfully processed, declined, or is still pending.

ParametersDefinition
paymentIDThe unique identifier for the payment you wish to cancel, UUID.
payment.go
client, err := fib.New(clientID, clientSecret, isTesting)
if err != nil {
    log.Fatalf("Error creating FIB client: %s - %s", err.Title, err.Description)
}
 
// Check the status of an existing payment
response, checkErr := client.CheckPayment(someUUID)
if checkErr != nil {
    log.Fatal("Error checking payment:", checkErr.ErrorBody)
}
 
log.Printf("Payment Status: %s", response.Status)

Response

The response object returned by the CheckPayment method contains important details about the payment status.

Below are the fields that you can expect in the response object:

ResponseDefinition
PaymentIDA unique identifier for the payment, UUID.
StatusThe current status of the payment.
PaidAtThe timestamp indicating when the payment was made (if applicable).
MonetaryValueThe amount and currency of the payment.
DecliningReasonThe reason for payment decline (if applicable).
DeclinedAtThe timestamp indicating when the payment was declined (if applicable).
PaidByInformation about who made the payment (if applicable).
example.json
{
  "PaymentID": "some-uuid",
  "Status": "PAID",
  "PaidAt": "2023-09-10T12:34:56Z",
  "MonetaryValue": {
    "Amount": 500,
    "Currency": "IQD"
  },
  "DecliningReason": null,
  "DeclinedAt": null,
  "PaidBy": {
    "Name": "John Doe",
    "IBAN": "some-iban"
  }
}

Payment Statuses

ResponseDefinition
PAIDThe payment has been successfully completed.
UNPAIDThe payment is still pending and has not been completed.
DECLINEDThe payment was declined for some reason.
REFUND_REQUESTEDA refund for the payment has been requested.
REFUNDEDThe payment has been successfully refunded.