Pay with Phone

Overview

Pay with Phone allows customers to make payments using their phone number. A payment prompt is sent directly to their phone for authorization.

How It Works

  1. Initialize payment with customer’s phone number
  2. Customer receives payment prompt on their phone
  3. Customer authorizes payment
  4. Verify transaction status
  5. Optionally cancel the transaction if needed

Base URL

https://mainapi.cashonrails.com/api/v1/s2s

Integration Steps

1. Initialize Payment

Send a POST request to initialize the payment:

curl --location '{{baseurl}}/paywithphone/initialize' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_SECRET_KEY' \
--data-raw '{
    "email": "customer@email.com",
    "amount": "100",
    "currency": "NGN",
    "reference": "{{reference}}",
    "phoneNumber": "08012345678"
}'

Request Parameters

ParameterTypeRequiredDescription
emailstringYesCustomer’s email address
amountstringYesAmount to charge
currencystringYesCurrency code (e.g., NGN)
referencestringYesUnique transaction reference
phoneNumberstringYesCustomer’s phone number

Sample Response

{
    "status": true,
    "message": "Payment prompt sent successfully",
    "data": {
        "reference": "COR_202402210123456789",
        "amount": "100",
        "currency": "NGN",
        "status": "pending"
    }
}

2. Customer Authorization

Customer will receive a prompt on their phone to authorize the payment. This might be a USSD prompt

3. Verify Transaction

After customer authorization, verify the transaction status:

curl -X GET '{{baseurl}}/transaction/verify/{reference}' \
-H "Authorization: Bearer YOUR_SECRET_KEY"

Sample Success Response

{
    "status": true,
    "message": "Transaction verified successfully",
    "data": {
        "reference": "COR_202402210123456789",
        "amount": "100",
        "currency": "NGN",
        "status": "success",
        "payment_method": "phone"
    }
}
⚠️

Always verify the transaction status before confirming payment. The verification step is crucial as the customer might decline or ignore the payment prompt.

4. Cancel Transaction

You can cancel a transaction that is still pending or in progress:

curl -X GET {{baseurl}}/transaction/cancel/{reference} \
-H "Authorization: Bearer YOUR_SECRET_KEY"

Replace {reference} with your transaction reference.

Cancellation Rules

⚠️
  • Only pending or processing transactions can be cancelled
  • Completed transactions cannot be cancelled (use refund instead)
  • Failed transactions are already inactive and don’t need cancellation
  • Once cancelled, a transaction cannot be resumed