Terraswitch
  • Terraswitch - Get Started
  • Test & Live Environments
  • Onboarding as a Business
  • GUIDES
    • 🎾Authentication
    • 🧀Webhooks
    • 🫓Status & Responses
    • 🏉API Rate Limits
    • 🚀Transactions & Destinations
    • 🍊Testing Credentials
    • 🚐Crafting Metadata
  • API ENDPOINTS
    • Account
      • Get Account Details
      • Get Banks
      • Get Beneficiaries
      • Add Bank
      • Change Settlement Bank
    • Wallet
      • Get Wallet Details
      • Get Wallet Transactions
    • Collections
      • Checkout
        • Initialize Transaction
      • Transfer
        • Generate Account
      • Charge
        • Create Charge
        • Authorize Charge
        • Charge Authorization
      • Bank
        • Pay with Opay
    • Payout
      • Bank Transfer
      • Withdraw Money
    • Products
      • List Products
      • Search Products
      • Filter Products
      • Fetch Product
      • Create Product
      • Update Product
    • Subaccounts
      • List Subaccounts
      • Search Subaccounts
      • Filter Subaccounts
      • Fetch Subaccount
      • Create Subaccount
      • Update Subaccount
    • Payment Links
      • List Payment Links
      • List Payment Link Transactions
      • Search Payment Links
      • Filter Payment Links
      • Fetch Payment Link
      • Create Payment Link
      • Update Payment Link
      • Attach Payment Resource
      • Remove Subaccount
      • Enable Payment Link
      • Disable Payment Link
    • Invoices
      • List Invoices
      • Search Invoices
      • Filter Invoices
      • Fetch Invoice
      • Create Invoice
      • Update Invoice
      • Remove Invoice Item
    • Transactions
      • List Transactions
      • Search Transactions
      • Filter Transactions
      • Verify Transaction
    • Refunds
      • List Refunds
      • Fetch Refund
      • Create Refund
    • Bills Payment
      • List Mobile Networks
      • List Bill Categories
      • List Bill Sub-Categories
      • List Mobile Data Plans
      • Validate Biller
      • Validate Bill Status
      • Validate Top-Up Status
      • Buy Airtime
      • Buy Data
      • Pay Bill
    • Resources
      • List Banks
      • List Countries
      • Resolve Bank Account
Powered by GitBook
On this page
  1. API ENDPOINTS
  2. Collections
  3. Checkout

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

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

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: "emmabidem@gmail.com",
    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)
})
{
  error: false,
  errors: [],
  data: {
    name: "Payment-Request-9DWI",
    slug: "tdrlevtnmazv",
    link: "https://staging-app.terraswitching.com/link/tdrlevtnmazv",
    qrcode: "https://storage.googleapis.com/concreap-buckets/qrcode-0c57a16d",
    redirectUrl: "https://pay.terraswitching.com/verify",
    feature: "request",
    type: "fixed",
    isEnabled: true,
    message: "Thank your for your payment",
    description: "Please make your loan repayment",
    amount: 2000,
    totalAmount: 0,
    createdAt: "2024-05-28T11:51:43.932Z",
    updatedAt: "2024-05-28T11:51:44.387Z",
    options: {
      card: true,
      transfer: true,
      bank: false,
      ussd: false,
      bankQR: false
    }
  },
  message: "successful",
  status: 200
}
PreviousCheckoutNextTransfer

Last updated 5 months ago

""

Pass in any other additional information you want using the structure of the metadata object. Learn how to

https://pay.terraswitching.com/verify
craft metadata here