📌 Initiate and manage charges with this function.
The Create Charge function allows you to initiate a payment transaction by charging a specified amount to a card. This operation is useful for processing online payments, subscriptions, or other financial transactions.
To use the Create Charge function, you need to configure it with specific details:
cardInfo: Provide the card information, including the card number, expiry date, card verification code (CVC), cardholder's name, billing address, and additional address details if required.cardToken: A unique identifier or token representing a customer's card.customerToken: A secure token associated with a customer's profile.amount: Specify the amount to be charged in the selected currency.description: Add a brief description of the charge for reference.email: Enter the email address associated with the charge.options: Configure additional options such as the payment mode (test or live), surcharge inclusion, and surcharge pricing if applicable.
async function script(C) {
const response = await C.createCharge({
cardInfo: {
number: "5520000000000000",
expiry_month: "11",
expiry_year: "2023",
cvc: "123",
name: "test",
address_line1: "ad1",
address_city: "ad2",
address_postcode: "123",
address_country: "Australia",
address_line2: "ad2",
address_state: "st1",
},
// cardToken: cardToken.cardResponse.token,
// customerToken: "customer_token",
amount: 200,
description: "test charge",
email: "[email protected]",
options: {
testOrLive: "test",
addSurcharge: true,
surchargePricing: {
domestic: { percent: 0.2, constantAmount: 1.6 },
},
},
});
return { response };
}
Info:One of
cardInfo,cardTokenorcustomerTokenis required
Output
The output of the Create Charge function will contain information related to the payment transaction. Such as:
- Transaction Status: The output will indicate whether the payment transaction was successful or if any errors occurred.
- Transaction ID: If the transaction is successful, it will provide a unique identifier (ID) for the transaction.
- Payment Receipt: The output may include a receipt or reference.
📌 Need Help?
