Pay with Opay

Create a new charge on a customer's debit card

POST {{ BASE_URL }}/v1/corporate/charge-opay

Body Parameters

Property
Data Type
Description
Example
Required

amount

number

The amount to charge

200

Yes

reference

string

Your unique reference for the transaction

"23456789876CBD"

No

redirectUrl

string

Url you want to redirect to after successful or failed payment

"https://...."

NO

description

string

Description of the transaction

"Payment for card"

No

customer

object

The customer object that holds customer details

{...}

customer.firstName

string

Customer first name

"John"

NO

customer.lastName

string

Customer last name

"Doe"

NO

customer.phoneNumber

string

Customer phone number without country code

"08137031202"

NO

customer.accountNo

string

"Opay" account number for customer. This must be Opay account number

"8036366334"

YES

customer.email

string

Customer emaill address

YES

metadata

Array of objects

Additional parameters you want using the metadata object. Learn how to craft metadata here

[ {...}, {...} ]

No

import Axios from 'axios';

// set the api url
const API_URL = `${BASE_URL}/v1/corporate/charge`;

// define request body
const data = {
  amount: 400,
  reference: "",
  description: "payment for opay charge xid",
  redirectUrl: "https://staging-app.terraswitching.com/verify",
  customer: {
    email: "[email protected]",
    firstName: "Oluwatobi",
    lastName: "Immanuel",
    phoneNumber: "+2348137031202",
    accountNo: "8036366334"
  },
  metadata: [
    {
      product: "zod",
      productId: "12356890"
    }
  ]
}

// make request using axios
Axios({
    method: "POST",
    url: `${API_URL}`,
    headers: {
        lg: 'en',
        ch: 'web'
        Authorization: `Bearer ${API_KEY}`,
        'Content-Type': 'application/json',
    },
    data: data
}).then((resp) => {
    console.log(resp)
}).catch((err) => {
    console.log(err)
})

After creating an Opay charge, you will be most likely required to redirect to a url provided to authorize the charge. For this, you need to use the "url" provided in the response above.

Last updated