Back to top

AfriPay API

AfriPay is a simple service that allows clients carry out escrow payments

Authentication

Resources related to authentication in the API.

Authenticate

Get an access token
POST/merchant/verify

Example URI

POST https://afripay.ng/api/v1/merchant/verify
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "api_key": "test_1234567890",
  "secret": "----------------------"
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "success": true,
  "status": "success",
  "message": "Successfully created token",
  "data": {
    "token": "dyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ"
  }
}

Authorization

With your access token, you can now authenticate your API requests. To do that, you need to ensure that you pass your access token in the request header using the Authorization parameter. Like so:

Authorization: Bearer dyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ

Transaction

Resources related to transactions in the API.

Transaction Collection

Use this endpoint to add and view transactions.

List all transactions
GET/transactions

Example URI

GET https://afripay.ng/api/v1/transactions
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "success": true,
  "status": "success",
  "data": {
    "transactions": [
      {
        "name": "",
        "description": "",
        "category": "",
        "amount": 0,
        "transaction_period": 0,
        "inspection_period": 0,
        "status": 0,
        "seller_id": 0,
        "buyer_id": 0,
        "created_at": "",
        "updated_at": "",
        "terms": "",
        "user_id": 0,
        "seller_fee": 0,
        "buyer_fee": 0,
        "accepted": 1,
        "reference_number": "",
        "shipment_paid_by": "",
        "merchant_commission": 0
      }
    ]
  }
}

Add a new transaction
POST/transactions

You may create a new transaction record using this action.

  • name (string) * - Name for the transaction

  • description (string) * - Description of the transaction

  • category (string) * - Should be any one of these; merchandise, electronics, property, vehicle, domain, service, others

  • amount (number) * - Cost of the transaction

  • transaction_period (number) * - Number of days it is expected to get the item delivered

  • inspection_period (number) * - Number of days required for item/service to be verified and dispute raised

  • terms (string) - The terms of the transaction. Explicitly specify terms of condition for the transaction

  • buyer_email (email) * - The email of the buying customer

  • buyer_name (string) * - The fullname of the buying customer

  • buyer_phone (number) * - The phone number of the buying customer

Example URI

POST https://afripay.ng/api/v1/transactions
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "name": "",
  "description": "",
  "category": "",
  "amount": 0,
  "transaction_period": 0,
  "inspection_period": 0,
  "terms": "",
  "buyer_email": "",
  "buyer_name": "",
  "buyer_phone": ""
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "success": true,
  "status": "success",
  "data": {
    "transaction": {
      "name": "Testing Api",
      "description": "Creating Transaction through Api",
      "category": "Electronics",
      "amount": "1500",
      "transaction_period": "10",
      "inspection_period": "3",
      "buyer_id": 20,
      "merchant_commission": "20",
      "seller_id": 11,
      "seller_fee": 150,
      "buyer_fee": 150,
      "status": 0,
      "reference_number": "4DAH59PX",
      "updated_at": "Mar 24, 2017",
      "created_at": "Mar 24, 2017",
      "user_id": 1,
      "accepted": 1
    }
  }
}

Transaction

View a transaction
GET/transactions/{reference_number}

This action allows you to view a transaction details.

Example URI

GET https://afripay.ng/api/v1/transactions/reference_number
URI Parameters
HideShow
reference_number
string (required) 

Reference number of the transaction

Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "success": true,
  "status": "success",
  "data": {
    "transaction": {
      "name": "Testing Api",
      "description": "Creating Transaction through Api",
      "category": "Electronics",
      "amount": "1500",
      "transaction_period": "10",
      "inspection_period": "3",
      "buyer_id": 20,
      "merchant_commission": 20,
      "seller_id": 11,
      "seller_fee": 150,
      "buyer_fee": 150,
      "status": "New Transaction",
      "reference_number": "4DAH59PX",
      "updated_at": "Mar 24, 2017",
      "created_at": "Mar 24, 2017",
      "user_id": 1,
      "accepted": 1
    }
  }
}

Cancel Transaction

Cancel a transaction
POST/transaction/{reference_number}/cancel

This action allows you cancel a transaction.

NOTE: You can only cancel a transaction for which has not been made i.e. funds not in escrow.

Example URI

POST https://afripay.ng/api/v1/transaction/reference_number/cancel
URI Parameters
HideShow
reference_number
string (required) 

Reference number of the transaction

Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "success": true,
  "status": "success",
  "message": "Transaction successfully cancelled",
  "data": {}
}

Payment

Standard Payment

Make payment for transaction
GET/pay/{reference_number}{?redirect_url}{&api_key}{&email}

This action loads the standard payment page of AfriPay. On successful payment, users are redirected to the url you provided with a payment_reference parameter.

Example URI

GET https://afripay.ng//pay/reference_number?redirect_url=&api_key=&email=
URI Parameters
HideShow
reference_number
string (required) 

Reference number of the transaction

redirect_url
string (required) 

The redirect URL on successful payment. The request will have GET parameters 'status' which is set to 'paid' and payment_reference which is set to the dynamically generated reference for the payment.

api_key
string (required) 

Your API key

email
string (required) 

Your registered email

Shipment

Cities

Retrieve all cities
GET/shipment/cities

This action allows you to view the available cities and their IDs. The IDs are needed to retrieve the cost of shipment.

Example URI

GET https://afripay.ng/api/v1/shipment/cities
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": "success",
  "success": true,
  "data": {
    "cities": [
      {
        "id": 0,
        "name": ""
      }
    ]
  }
}

Cost

Calculate shipment cost
POST/shipment/cost

This action allows you to view the cost for the shipment from city A to city B.

  • from (number) * - The city id for the originating city

  • to (number) * - The city id for the destination city

Example URI

POST https://afripay.ng/api/v1/shipment/cost
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "from": 0,
  "to": 0
}
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "status": true,
  "message": "Completed successfully",
  "data": {
    "from": "A",
    "to": "B",
    "price": 0
  }
}

Generated by aglio on 28 Mar 2017