Creating a charge
After you connect to the AffiniPay Payment Gateway and collect and secure payment details, you can call the AffiniPay Payment Gateway API to run a charge.
To authenticate, you’ll need the merchant secret key. Using the test-mode secret key and a test account, you can start using the API immediately without actually submitting charges to the payment processing networks. When you’re ready to start processing payments, just switch to your live-mode secret key and a live account.
When you POST to the charges endpoint, you’ll include:
- amount. The total payment amount in cents. For example: $500.00 = 50000.
- method. The ID of the payment method to use to run the payment. In this case, this payment method is the id property received on the one-time token JSON object collected in your payment form.
- account_id. The ID of the AffiniPay merchant account that should receive payment. Because a merchant can have more than one account, you should set this value for each transaction.
Example request
curl -X POST -H "Content-Type:application/json" --user <secret_key>: https://api.affinipay.com/v1/charges -d '
{
"amount":"50000",
"method":"wKgFaj72F3aBPvZneEsBew",
"account_id":"diON4KOPnesamprmrxA8Iuo"
}
Having problems making a charge? Check out our FAQ.