Create Payment

Create a New Payment

The CreatePayment method allows you to initiate a new payment transaction.

This method is designed to be simple yet flexible, providing you with control over the payment details.

ParametersDefinition
AmountThe amount to be paid, specified as an integer.
CurrencyThe currency in which the payment is made. Currently, only IQD is supported.
StatusCallBackURLThe URL to which the payment status updates will be sent.
WithDescription(description)Adds a description to the payment, specified as a string (Optional).
WithExpiresIn(expiresIn)Sets an expiration time for the payment, specified as a string (Optional).
💡

ExpiresIn A string representation of this duration using ISO-8601 seconds based representation should be used, such as PT8H6M12.345S, here is an Example (opens in a new tab)

payment.go
client, err := fib.New(clientID, clientSecret, isTesting)
if err != nil {
    log.Fatalf("Error creating FIB client: %s - %s", err.Title, err.Description)
}
 
// Create a new payment of 500 IQD
response, paymentErr := client.CreatePayment(500, "IQD", "http://callback.url")
if paymentErr != nil {
    log.Fatal("Error creating payment:", paymentErr.ErrorBody)
}

Response

The response object returned by the CreatePayment function contains important details about the payment transaction.

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

ResponseDefinition
PaymentIDA unique identifier for the payment, usually a UUID.
ReadableCodeA human-readable code associated with the payment.
QRCodeA QR code string that can be used to facilitate the payment.
ValidUntilThe expiration time of the payment.
PersonalAppLinkA link to the personal app where the payment can be completed.
BusinessAppLinkA link to the business app where the payment can be managed.
CorporateAppLinkA link to the corporate app where the payment can be overseen.

Response example:

example.json
{
  "PaymentID": "some-uuid",
  "ReadableCode": "ABC123",
  "QRCode": "some-qr-code-string",
  "ValidUntil": "2023-09-10T12:34:56Z",
  "PersonalAppLink": "http://personal-app-link",
  "BusinessAppLink": "http://business-app-link",
  "CorporateAppLink": "http://corporate-app-link"
}