Api

Payments

Receive Payments using SP Pay RESTful API.

A key part of every business, is payments. For any service you provide, you need to be able to receive payments.

To receive payments via API, you will need to make at least one of the two API calls below.

  1. Initiate Payment - This call validates and creates a payment request. However, to prevent fraudulent payment requests, customers who have not used your web / mobile application in while, will receive an OTP (One Time Password) to authenticate the request.This API call, will return one of two things.
    1. If the customer is an existing customer, or has authenticated a request from your app recently, a validation prompt will be immediately triggered for approval and you will receive the transaction details as a response.
    2. Otherwise, a one time password will be sent to the customer via SMS for approval, and you will receive the OTP_ID which you will use in the Confirm Payment Call, along with the OTP code.
  2. Submit OTP - This API call is only required, if an OTP is generated in the Initiate Payment Call.

Initiate a Payment

POST - Initiate Payment

Request to generate an API Token for subsequent requests as a Bearer Token.

This Endpoint is protected. You will need a Bearer token attached to each request. Learn more.

Endpoint

{{sppay-host}}/v1/api/payments/initiate

Request

{
    "receive_account_no": "1000",
    "amount": 2,
    "payee": {
        "email": "[email protected]",
        "account": {
            "code": "MTN",
            "number": "0597018036"
        }
    },
    "callback_url": "{{sppay-host}}/v1/sp-pay/webhook"
}

receive_account_norequired
String

Your SP Pay account number to which the collection should be received.

amountrequired
double

Amount to be collected.

payeerequired
Object

Object of payee.

emailrequired
String

Email address of payee.

accountrequired
Object

Account object of payee.

coderequired
String

Payee account code.

numberrequired
String

Payee account number.

callback_urlrequired
String

URL to which final transaction status and information will be sent to.

Response

{
    "status": "Success",
    "message": "Transaction submitted for processing. Please prompt customer to validate on third party.",
    "transaction": {
        "id": 9,
        "reference": "ZEMQDWUYJ0",
        "external_reference": "",
        "primary": 1,
        "type_code": "TPSD",
        "currency": "GHS",
        "amount": "2.00",
        "debit_account_name": "MICHAEL EKOW SELBY",
        "debit_account_no": "0271777557",
        "debit_account_institution_code": "ATL",
        "credit_account_name": "SP Pay Cedi Account 1",
        "credit_account_no": "1000",
        "credit_account_institution_code": "SPP",
        "status": 3,
        "status_message": "Pending debit completion via script",
        "created_at": "Fri, 15 Mar 2024 07:20:18 GMT",
        "updated_at": "Fri, 15 Mar 2024 07:20:21 GMT",
        "charge": {
            "id": 10,
            "reference": "ZEMQDWUYJ0",
            "external_reference": "",
            "primary": 0,
            "type_code": "CHRG",
            "currency": "GHS",
            "amount": "0.04",
            "debit_account_name": "MICHAEL EKOW SELBY",
            "debit_account_no": "0271777557",
            "debit_account_institution_code": "ATL",
            "credit_account_name": "SP Pay GHS Suspense Account",
            "credit_account_no": "101",
            "credit_account_institution_code": "SPP",
            "status": 1,
            "status_message": "Created. Pending submission",
            "created_at": "Fri, 15 Mar 2024 07:20:21 GMT",
            "updated_at": "Fri, 15 Mar 2024 07:20:21 GMT",
            "payment_category": null,
            "pending_actions": []
        },
        "initiator_id": 1,
        "payment_category": null,
        "pending_actions": [
            {
                "id": 2,
                "transaction_reference": "ZEMQDWUYJ0",
                "action_code": "complete_debit_via_external_script",
                "action_reference": "81fe46792fbc47319497cbf9b10da081",
                "internal_action_link": "https://www.sppay.dev/pay/ZEMQDWUYJ0",
                "external_action_link": null,
                "is_completed": 0,
                "created_at": "2024-03-15T07:20:21.000000Z",
                "updated_at": "2024-03-15T07:20:21.000000Z"
            }
        ]
    }
}

status
String

Status of API request. success for a successful request and error for an unsuccessful request.

message
integer

Status message of submitted transaction if succcessful or error message of API request if unsuccessful.

transaction
Object

Object of generated transaction if successful.

id
integer

Unique ID of transaction.

reference
String

System generated reference of transaction.

external_reference
String

User provided reference which will be sent to recipient via SMS.

primary
integer

Flag to indicate whether transaction is a primary transaction or secondary transaction. 1 for primary and 0 for secondary. Secondary transactions are transactions that are generated by system based on certain conditions. E.g. Tax and Charge transactions.

type_code
String

Type code of the debit account.

currency
String

Currency code of the credit amount.

amount
String

Amount credited to credit account. This is always in the currency of the credit account.

debit_account_name
String

Name on the debit account.

debit_account_no
String

Account number of the debit account.

debit_account_institution_code
String

Institution code of the debit account.

credit_account_name
String

Name on the credit account.

credit_account_no
String

Account number of the credit account.

credit_account_institution_code
String

Insitution code of the debit account

status
String

Status ID of the transaction.

status_message
String

Status message of the transaction.

created_at
String

Time the transaction was created.

updated_at
String

Time the transaction wass last updated.

charge
Transaction

Object of the charge transaction. The structure is identical to the transaction object for which it is a part of. It is only returned if a charge exists.

tax
Transaction

Object of the tax transaction. The structure is identical to the transaction object for which it is a part of. It is only returned if a tax exists.

initiator_id
String

ID of the user who created or submitted the transaction.

payment_category
Object

Object of payment category if a payment category is applied.

pending_actions
Array

Array of pending actions.

Submit OTP ( only when required )

POST - Submit OTP

Request to submit OTP required to complete a transaction.

This Endpoint is protected. You will need a Bearer token attached to each request. Learn more.

Endpoint

{{sppay-host}}/v1/api/payments/otp/submit

Request

{
    "otp" : "486110",
    "transaction_reference": "JACGOURQFB",
}

otprequired
String

Grant type your application requires. Set value to password.

transaction_referencerequired
String

A unique ID given to every API accessing user. This is generated when creating API Access for a user.

Response

{
    "status": "Success",
    "message": "Transaction submitted for processing. Please prompt customer to validate on third party.",
    "transaction": {
        "id": 6,
        "reference": "TFR96E4GH2",
        "external_reference": "",
        "primary": 1,
        "type_code": "TPSD",
        "currency": "GHS",
        "amount": "2.00",
        "debit_account_name": "MICHAEL EKOW SELBY",
        "debit_account_no": "0597018036",
        "debit_account_institution_code": "MTN",
        "credit_account_name": "SP Pay Cedi Account 1",
        "credit_account_no": "1000",
        "credit_account_institution_code": "SPP",
        "status": 3,
        "status_message": "Charge attempted",
        "created_at": "Fri, 15 Mar 2024 07:18:39 GMT",
        "updated_at": "Fri, 15 Mar 2024 07:18:41 GMT",
        "charge": {
            "id": 7,
            "reference": "TFR96E4GH2",
            "external_reference": "",
            "primary": 0,
            "type_code": "CHRG",
            "currency": "GHS",
            "amount": "0.04",
            "debit_account_name": "MICHAEL EKOW SELBY",
            "debit_account_no": "0597018036",
            "debit_account_institution_code": "MTN",
            "credit_account_name": "SP Pay GHS Suspense Account",
            "credit_account_no": "101",
            "credit_account_institution_code": "SPP",
            "status": 1,
            "status_message": "Created. Pending submission",
            "created_at": "Fri, 15 Mar 2024 07:18:41 GMT",
            "updated_at": "Fri, 15 Mar 2024 07:18:41 GMT",
            "payment_category": null,
            "pending_actions": []
        },
        "initiator_id": 1,
        "payment_category": null,
        "pending_actions": []
    }

status
String

Status of API request. success for a successful request and error for an unsuccessful request.

message
integer

Status message of submitted transaction if succcessful or error message of API request if unsuccessful.

transaction
Object

Object of generated transaction if successful.

id
integer

Unique ID of transaction.

reference
String

System generated reference of transaction.

external_reference
String

User provided reference which will be sent to recipient via SMS.

primary
integer

Flag to indicate whether transaction is a primary transaction or secondary transaction. 1 for primary and 0 for secondary. Secondary transactions are transactions that are generated by system based on certain conditions. E.g. Tax and Charge transactions.

type_code
String

Type code of the debit account.

currency
String

Currency code of the credit amount.

amount
String

Amount credited to credit account. This is always in the currency of the credit account.

debit_account_name
String

Name on the debit account.

debit_account_no
String

Account number of the debit account.

debit_account_institution_code
String

Institution code of the debit account.

credit_account_name
String

Name on the credit account.

credit_account_no
String

Account number of the credit account.

credit_account_institution_code
String

Insitution code of the debit account

status
String

Status ID of the transaction.

status_message
String

Status message of the transaction.

created_at
String

Time the transaction was created.

updated_at
String

Time the transaction wass last updated.

charge
Transaction

Object of the charge transaction. The structure is identical to the transaction object for which it is a part of. It is only returned if a charge exists.

tax
Transaction

Object of the tax transaction. The structure is identical to the transaction object for which it is a part of. It is only returned if a tax exists.

initiator_id
String

ID of the user who created or submitted the transaction.

payment_category
Object

Object of payment category if a payment category is applied.

pending_actions
Array

Array of pending actions.

id
integer

ID of pending action record.

transaction_reference
String

Transaction reference to which this pending action is tied to.

action_code
String

Unique code assigned to the specific action required to be taken.

action_reference
String

Unique reference assigned to the specific action required to be taken.

internal_action_link
String

SP Pay link to complete the action if required.

external_action_link
String

External link to complete the action if required

is_completed
String

Flag to indicated if action of completed or not. 0 for pending, 1 for completed.

created_at
String

Time which this pending action was created

updated_at
String

Time which this pending action was last updated.


Copyright © 2024