Data Purchase

You can make a data bill payment purchase in three easy steps:

  1. List the data providers
  2. List the provider's details
  3. Initiate the bill payment purchase

1. Get the list of data providers

VerbURL
GET{{baseUrl}}/api/v1/bills/billers?category=data

To initiate data bill payment, make an API call to the list billers endpoint to fetch all the data providers’ details on Anchor. If this is successful, you will receive a list of all data providers on Anchor.

Sample request payload and sample 200 OK response payload are given below:

curl --request GET \
     --url https://api.sandbox.getanchor.co/api/v1/bills/billers?category=data \
     --header 'accept: application/json' \
     --header 'x-anchor-key: <API KEY>'
{
  "data": [
    {
      "id": "168322497971130-anc_blr",
      "type": "Provider",
      "attributes": {
        "name": "MTN",
        "category": "data",
        "slug": "mtn"
      }
    },
    {
      "id": "168322497841229-anc_blr",
      "type": "Provider",
      "attributes": {
        "name": "GLO",
        "category": "data",
        "slug": "glo"
      }
    },
    {
      "id": "168322497720128-anc_blr",
      "type": "Provider",
      "attributes": {
        "name": "Airtel",
        "category": "data",
        "slug": "airtel"
      }
    },
    {
      "id": "168322497484826-anc_blr",
      "type": "Provider",
      "attributes": {
        "name": "9Mobile",
        "category": "data",
        "slug": "9mobile"
      }
    },
    {
      "id": "16832249694660-anc_blr",
      "type": "Provider",
      "attributes": {
        "name": "NTEL",
        "category": "data",
        "slug": "ntel"
      }
    }
  ],
  "meta": {
    "pagination": {
      "size": 20,
      "number": 0,
      "totalPages": 1,
      "total": 5
    }
  }
}

2. Get the provider’s details

VerbURL
GET{{baseUrl}}/api/v1/bills/billers/{billerId}/products

Then call the list biller product endpoint and pass the billerId to fetch all the Products of that provider. When you list the biller product, note the slug and priceof the data product you want to purchase as you will use this in creating the data bill payment.

price - price of the of the data bundle specified in the countries lowest currency unit. Price is a fixed for data

billerId is the unique Id of the bill provider on Anchor.

slug is the human readable identifier of the data product/plan. When you list a biller product you will see the product slug on each biller product.

Sample request payload and sample 200 OK response payload are given below:

curl --request GET \
     --url https://api.sandbox.getanchor.co/api/v1/bills/billers/168322497971130-anc_blr/products \
     --header 'accept: application/json' \
     --header 'x-anchor-key: <API KEY>'
"data": [
    {
      "id": "1683224979755199-anc_bll_itm",
      "type": "Data",
      "attributes": {
        "price": {
          "type": "Fixed",
          "minimumAmount": 10000,
          "maximumAmount": 10000,
          "currency": "NGN"
        },
        "name": "DataPlan 100MB Daily (24 Hours)",
        "slug": "mtn_dataplan_100mb_daily_24_hours_"
      },
      "relationships": {
        "provider": {
          "data": {
            "id": "168322497971130-anc_blr",
            "type": "Provider"
          }
        }
      }
    },
    {
      "id": "1683224979833201-anc_bll_itm",
      "type": "Data",
      "attributes": {
        "price": {
          "type": "Fixed",
          "minimumAmount": 100000,
          "maximumAmount": 100000,
          "currency": "NGN"
        },
        "name": "Data 1.5GB (30 days)",
        "slug": "mtn_data_1_5gb_30_days_"
      },
      "relationships": {
        "provider": {
          "data": {
            "id": "168322497971130-anc_blr",
            "type": "Provider"
          }
        }
      }
    }
}

3. Initiate the data bill payment:

VerbURL
POST{{baseUlr}}/api/v1/bills

When you have identified the data bundle you want to purchase, you can proceed to purchase the identified data plan.

AttributeDescription
typeThe type for data bill payment is Data.
phoneNumberThis is the phone number that will receive the data bundle.
amountThis is the fixed amount of the data bundle (specified in the currencies lowest denomination).
productSlugThe slug of the product for which the payment is being made.
referenceThe unique identifier of the transaction on your system.

You would need to pass the account id and type (Deposit or Subaccount) where this transaction will be initiated and charged from.

curl --request POST \
     --url https://api.sandbox.getanchor.co/api/v1/bills \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'x-anchor-key: <API key>' \
     --data '
{
  "data": {
    "type": "Data",
    "attributes": {
      "phoneNumber": "2347012345678",
      "amount": 10000,
      "productSlug": "mtn_dataplan_100mb_daily_24_hours_",
      "reference": "01213756789"
    },
    "relationships": {
      "account": {
        "data": {
          "type": "DepositAccount",
          "id": "16922123768364-anc_acc"
        }
      }
    }
  }
}
'
{
  "data": {
    "id": "16974493712621-anc_bll",
    "type": "BillPayment",
    "attributes": {
      "reference": "0323756789",
      "createdAt": "2023-10-16T09:42:51.264999",
      "amount": 10000,
      "phoneNumber": "2347012345678",
      "detail": {
        "provider": "MTN",
        "product": "DataPlan 100MB Daily (24 Hours)",
        "units": 0
      },
      "category": "data",
      "commissionAmount": 0,
      "status": "COMPLETED",
      "updatedAt": "2023-10-16T09:42:52.226426"
    },
    "relationships": {
      "account": {
        "data": {
          "id": "16922609921350-anc_subacc",
          "type": "DepositAccount"
        }
      },
      "customer": {
        "data": {
          "id": "16922123736510-anc_bus_cst",
          "type": "BusinessCustomer"
        }
      }
    }
  }
}

Receive webhook events

You will receive bills.initiated events once the bill payment is initiated. If the bill payment is success full, you will receive bills.successful event. If this payment is not successful, you will receive bills.failed event.

{
  "data": {
    "id": "1701682033973157-anc_et",
    "type": "bills.initiated",
    "attributes": {
      "createdAt": "2023-12-04T09:27:14"
    },
    "relationships": {
      "bill": {
        "data": {
          "id": "17016820338191-anc_bll",
          "type": "BillPayment"
        }
      },
      "account": {
        "data": {
          "id": "16922609921350-anc_subacc",
          "type": "DepositAccount"
        }
      },
      "customer": {
        "data": {
          "id": "16922123736510-anc_bus_cst",
          "type": "BusinessCustomer"
        }
      }
    }
  }
{
  "data": {
    "id": "1701682034325158-anc_et",
    "type": "bills.successful",
    "attributes": {
      "createdAt": "2023-12-04T09:27:14"
    },
    "relationships": {
      "bill": {
        "data": {
          "id": "17016820338191-anc_bll",
          "type": "BillPayment"
        }
      },
      "account": {
        "data": {
          "id": "16922609921350-anc_subacc",
          "type": "DepositAccount"
        }
      },
      "customer": {
        "data": {
          "id": "16922123736510-anc_bus_cst",
          "type": "BusinessCustomer"
        }
      }
    }
  }

You can also use the support included functionality when listening to this bill payment event to retrieve other information such as the customer detail that is related to this event.