Initialize Transaction

Create a collection link to collect payment by initialization

POST {{ BASE_URL }}/v1/corporate/initialize

Body Parameters

Property
Data Type
Description
Example
Required

type

string

The type of the transaction to be initialized. This can either be fixed or dynamic

"fixed"

Yes

currency

string

currency of the transaction. This can be NGN or USD. This defaults to NGN if not specified.

"NGN"

No

reuseable

boolean

Specify if payment url should be recurring ( i.e. re-useable ) or one-time. Defaults to false

true

No

amount

number

Amount of required for the payment link. This should be set if type is fixed

1000.99

Only if type is fixed

reference

string

A unique reference to identify transaction after successful payment. Note that this overrides reuseable property and it becomes false

"RVFGHYU3"

redirectUrl

string

Preferred payment link redirect url. Customers will be redirected to this link on payment success or failure.

No. Defaults to Terraswitch's url

message

string

Success message after a successful payment.

"Thank you for your payment"

No

description

string

Describe the payment link and its purpose.

"For donation"

No

subaccounts

array

An array of strings that holds subaccount codes if you plan to split the payment.

[ "VSA_6yhyzzkcHc" ]

No

customer

object

An object that hold the customer's (your user) details

{...}

No

customer.email

string

Email of the customer

"emmabidem@gmailcom"

Yes

customer.firstName

string

First name of the customer

"Oluwatobi"

Yes

customer.lastName

string

Last name of the customer

"Immanuel"

Yes

customer.phoneNumber

string

Phone number of the customer

"08137031202"

Yes

customer.phoneCode

string

Country code of the phone number for the customer. Use NGA +234

"+234"

No

metadata

Array of objects

Pass in any other additional information you want using the structure of 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/initialize`;

// define request body
const data = {
  type: "fixed",
  amount: 2000,
  description: "Please make your loan repayment",
  redirectUrl: "https://pay.terraswitching.com/verify",
  subaccounts: [],
  message: "Thank your for your payment",
  customer: {
    email: "[email protected]",
    firstName: "Oluwatobi",
    lastName: "Immanuel",
    phoneNumber: "08137031202",
    phoneCode: "+234"
  }
}

// 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)
})

Last updated