idimensionz / affirm-php-sdk
Unofficial PHP SDK for Affirm Transaction API
2.0.0
2023-09-13 19:15 UTC
Requires
- ext-json: *
- guzzlehttp/guzzle: ^6.3 | ^7.0
- leocavalcante/shape: dev-master
Requires (Dev)
- phing/phing: ^2.16
- phpmd/phpmd: ^2.6
- phpstan/phpstan: ^0.9.1 | 1.10.33
- phpunit/phpunit: ^6.5.2 | 10.2.7
- squizlabs/php_codesniffer: ^3.1
This package is auto-updated.
Last update: 2024-12-13 21:50:59 UTC
README
Affirm Transaction API Docs Affirm Charge API Docs
Install:
composer require idimensionz/affirm-php-sdk
Usage:
// get an Affirm PHP Transaction API client sdk instance $config = [ 'public_api_key' => 'MY_AFFIRM_PUBLIC_API_KEY', 'private_api_key' => 'MY_AFFIRM_PRIVATE_API_KEY', 'is_sandbox' => true, ]; $affirm = new \iDimensionz\Affirm\Api\TransactionApiClient($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 transaction id $optionalData = [ 'order_id' => 'abc123', 'shipping_carrier' => 'my carrier', 'shipping_confirmation' => 'abc123', ]; $response = $affirm->capture('MY_TRANSACTION_ID', $optionalData); // read the details of an authorized transaction by transaction id $optionalData = [ 'expand' => 'checkout,events', ]; $response = $affirm->read('MY_TRANSACTION_ID', $optionalData);
Using the Charge API client is similar to the Transaction API Client.