idimensionz/affirm-php-sdk

Affirm 交易 API 的非官方 PHP SDK

2.0.0 2023-09-13 19:15 UTC

This package is auto-updated.

Last update: 2024-09-13 21:19:20 UTC


README

Affirm 交易 API 文档 Affirm 订单 API 文档

安装

composer require idimensionz/affirm-php-sdk

使用方法

// 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);

使用 Charge API 客户端与 Transaction API 客户端类似。