AffiniPay PHP Library
PHP Client Library for the AffiniPay Payment Gateway, (*1)
Download the PHP client library:, (*2)
git clone git://github.com/charge-io/chargeio-php.git
To use the library in your application, add the following to your PHP script:, (*3)
require_once '/path/to/chargeio-php/lib/ChargeIO.php';
The library's APIs require credentials to access your merchant data on the AffiniPay servers. You can either:, (*4)
Configure the library with default credentials., (*5)
To set default credentials, call ChargeIO::setCredentials with an AffiniPay_Credentials object. The AffiniPay_Credentials object is instantiated with a public_key and a secret_key., (*6)
ChargeIO::setCredentials(new AffiniPay_Credentials('
You must tokenize all sensitive payment information before you submit it to AffiniPay. On your payment form, use AffiniPay’s hosted fields to secure payment data and call window.AffiniPay.HostedFields.getPaymentToken to create a one-time payment token. See "Creating payment forms using hosted fields". Then, POST the payment token ID to your PHP script., (*8)
Pass an amount and the one-time token ID returned from your payment page to complete a charge., (*9)
$amount = $_POST['amount']; $token_id = $_POST['token_id']; $charge = ChargeIO_Charge::create(new ChargeIO_PaymentMethodReference(array('id' => $token_id)), $amount);
The latest AffiniPay Payment Gateway API documentation is available at https://developers.affinipay.com/reference/api.html#PaymentGatewayAPI., (*10)