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. Charge

Charge Authorization

Charge a debit card for recurring payments using authorization code

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

Body Parameters

Property
Data Type
Description
Example
Required

authCode

string

card authorization code recieved via webhook or response

"TAUTH_MY5NACDG"

Yes

amount

number

The amount to charge

200

Yes

currency

string

The currency of the payment. This can be NGN or USD

"NGN"

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

deviceIp

string

IP address of the customer's device or your device

"192.168.206.32"

Yes

customer

object

The customer object that holds customer details

{...}

Yes

customer.firstName

string

Customer first name

"John"

Yes

customer.lastName

string

Customer last name

"Doe"

Yes

customer.phoneNumber

string

Customer phone number without country code

"08137031202"

Yes

customer.phoneCode

string

Country code for customer's phone number.

"+234"

No

metadata

Array of objects

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

No

import Axios from 'axios';

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

// define request body
const data = {
  authCode: "TAUTH_MY5NACDG",
  amount: 20,
  reference: "",
  redirectUrl: "https://staging-app.terraswitching.com/verify",
  description: "Staff payment for internal training",
  deviceIp: "",
  customer: {
    firstName: "Oluwatobi",
    lastName: "Immanuel",
    email: "emmabidem@gmail.com",
    phoneNumber: "08137031202",
    phoneCode: "+234"
  },
  metadata: [
    {
      staffId: "002RTOPG",
      department: "engineering"
    }
  ]
}

// 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: {
    status: "successful",
    type: "credit",
    domain: "test",
    reference: "TSXFD77BA471CD84E82",
    merchantRef: "",
    amount: 20,
    fee: 0.2,
    vat: 0.015,
    feature: "payment-link",
    ipAddress: "",
    currency: "NGN",
    description: "incoming payment of NGN20 to Gnik Digitals Limited via payment link",
    vasData: {
      ref: "",
      type: "",
      network: "",
      phoneNumber: "",
      billerCode: "",
      billerName: "",
      hasToken: false,
      token: ""
    },
    metadata: [
      {
        staffId: "002RTOPG",
        department: "engineering"
      }
    ],
    bank: {
      name: "",
      accountName: "",
      accountNo: "",
      bankCode: ""
    },
    customer: {
      firstName: "Oluwatobi",
      lastName: "Immanuel",
      email: "emmabidem@gmail.com",
      phoneNumber: "08137031202",
      phoneCode: "+234",
      city: "",
      state: "",
      accountNo: "",
      sourceAccount: ""
    },
    createdAt: "2024-06-02T01:09:15.582Z",
    updatedAt: "2024-06-02T01:09:26.876Z",
    card: {
      brand: "visa",
      cardBin: "400758",
      cardLast: "9961",
      expiryMonth: "06",
      expiryYear: "27",
      createdAt: "2024-06-01T23:46:15.036Z",
      updatedAt: "2024-06-01T23:53:21.777Z",
      authCode: "TAUTH_MY5NABBW"
    }
  },
  message: "successful",
  status: 200
}
PreviousAuthorize ChargeNextBank

Last updated 5 months ago

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

craft metadata here