API Reference

Create Payment Request

Use this API to create Payment Requests with the Pay1st Gateway

Used in Gateway Integration

Overview

A Payment Request needs to be created with the Pay1st gateway before an actual payment can be made. This API is a POST request that takes payment details as input, and returns payment identification information as a JSON response.

Pre Requisites

Request Signature

A valid signature should be generated for this request. See Gateway - Generating Signatures for a detailed description on how this should be implemented.

API Description

HTTP Headers

Header NameDescription
AccessTokenThis is the Access Token field returned from the Authentication - Generate Access Token response. This should be in the format Bearer <AccessToken>
Content-Typeapplication/vnd.carry1st.payments.payment+json
X-SIGNATUREThis is the header that will contain the signature of the request. Refer to the Request Signing section above
X-TIMESTAMPThis is the current time in ISO-8601 format. This should be the same timestamp as the one used to generate the Signature

URL Format

https://<payments_url>/api/pay1st/payments/create

List of Create Payment POST fields

These are the list of POST parameters that needs to be passed from the Pay1st Partner to the Pay1st Gateway.

ParamFormatMandatoryDescription
amountDecimalYThe amount to pay
countryCodeStringYThe ISO-2 country code, e.g. ZA
currencyCodeStringYThe currency code for the amount
partnerReferenceStringYThe Pay1st Partner reference that needs to be used for reconciliation. This value will be sent back via the Summary Webhook API Call. This must be unique for the lifetime of the integration
callbackSuccessUrlStringIf provided, this is the URL that will be used to redirect the customer when a payment is successful. If not present, the default value in Configuring Webhooks and Callbacks will be used
callbackFailureUrlStringIf provided, this is the URL that will be used to redirect the customer when a payment has failed. If not present, the default value in Configuring Webhooks and Callbacks will be used
callbackPendingUrlStringIf provided, this is the URL that will be used to redirect the customer when a payment is still pending completion. If not present, the default value in Configuring Webhooks and Callbacks will be used
callbackCancelUrlStringIf provided, this is the URL that will be used to redirect the customer when a payment is has been cancelled. If not present, the default value in Configuring Webhooks and Callbacks will be used
productsList of Product FieldsYThe list of Product objects that identifies what the customer is paying for
metadataList of Metadata FieldsYThis is a list of key value pairs that can be used by the Partner to add any metadata relevant to the Payment
webhookUrlStringIf provided, this is the URL that will be used to notify the partner backend server of payment updated. If not present, the default value in Configuring Webhooks and Callbacks will be used

List of Product Fields

Products are used to describe the item that the customer is paying for within the application. This is typically used for record keeping and reporting. Below are the list of fields that can be configured for a product.

ParamFormatDescription
currencyCodeStringThe currency code for the amount
priceNumberThe cost of the Product
quantityNumberThe number of units bought
skuStringAn identifier for the SKU, typically from the partners backend services
titleStringThe name of the Product

List of Metadata Fields

Metadata fields can be used by the Partner to store any additional metadata that is not formally defined or needed by the Pay1st gateway.

ParamFormatDescription
keyStringAn identifiable key of this metadata field
valueStringThe value of the metadata field

Example JSON Request

The following JSON Request is an example of the correct construction of a Create Payment Request:

{
    "countryCode": "NG",
    "currencyCode": "NGN",
    "amount": 100,
    "partnerReference": "1119bf84-dc97-4be9-aa67-ec27d7003f07",
    "callbackSuccessUrl": "https://callback.success",
    "callbackFailureUrl": "https://callback.failure",
    "callbackPendingUrl": "https://callback.pending",
    "callbackCancelUrl": "https://callback.cancel",
    "webhookUrl": "https://webhook.success",
    "products": [
        {
            "title": "10Credits",
            "sku": "12345",
            "price": 100,
            "quantity": 1,
            "currencyCode": "NGN"
        }
    ],
    "metadata": [
        {
            "key": "customerId",
            "value": "1"
        }
    ]
}

Success Response

Valid HTTP Success Status Codes:

HTTP Status CodeNameDescription
201SuccessThis indicates that the request has been successful.
400Bad RequestThe X-SIGNATUREHTTP header in the request might not be matching the server.
The X-TIMESTAMP HTTP header in the request might not be within 5 minutes of creating the Access Token.
The Request Body might be invalid.

HTTP Response Body:

{
    "reference": "C-113976984708914-P",
    "partnerReference": "e27b3b79-5ab3-4c1b-806f-1428c08d8637",
    "countryCode": "NG",
    "currencyCode": "NGN",
    "amount": 100,
    "status": "NEW"
}

HTTP Response Fields

NameTypeDescription
amountNumberThis will match the amount of the original request
countryCodeStringThis will match the countryCode of the original request
currencyCodeStringThis will match the currencyCode of the original request
partnerReferenceStringThis will match the partnerReference of the original request
referenceStringThis is the Pay1st identifier of this payment request
statusStringThis represents the status of the payment. For all created payments, a value of NEW will be returned

Error Response

See Handling Error Codes for more details on handling error responses.