1. Go to this page and download the library: Download saatchiart/affirm-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
saatchiart / affirm-php-sdk example snippets
// get an affirm php sdk instance
$config = [
'public_api_key' => 'MY_AFFIRM_PUBLIC_API_KEY',
'private_api_key' => 'MY_AFFIRM_PRIVATE_API_KEY',
'is_sandbox' => true,
];
$affirm = new \SaatchiArt\Affirm\Api\Client($config);
// authorize an affirm payment by checkout token
/** @var \stdClass $response decoded json from response */
$optionalData = ['order_id' => 'OPTIONAL_ORDER_ID'];
$response = $affirm->authorize('MY_CHECKOUT_TOKEN', $optionalData);
// capture an authorized affirm payment by charge id
$optionalData = [
'order_id' => 'abc123',
'shipping_carrier' => 'my carrier',
'shipping_confirmation' => 'abc123',
];
$response = $affirm->capture('MY_CHARGE_ID', $optionalData);
// read an authorized charge by charge id
$optionalData = [
'limit' => 123,
'before' => 'beforeString',
'after' => 'afterString',
];
$response = $affirm->read('MY_CHARGE_ID', $optionalData);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.