loganhenson / firstdata
FirstData API 包装器
v2.0.0
2015-05-06 13:06 UTC
Requires
- guzzlehttp/guzzle: ~5.0
- league/csv: ~6.2
Requires (Dev)
- phpspec/phpspec: ~2.0
- vlucas/phpdotenv: ~1.1
README
First Data API v14
安装
composer require loganhenson/firstdata
信息/API
需要 .env 文件(见 .env.example)
购买
<?php $Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key')); try{ $response = $Transaction->Purchase('Mastercard', 'Logan Henson', 5500000000000004, 1216, 123, 120); }catch(FirstDataException $e){ echo $e->getMessage(); }
预认证
<?php $Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key')); try{ $response = $Transaction->PreAuth('Mastercard', 'Logan Henson', 5500000000000004, 123, 1216); // store the $response['transarmor_token'] }catch(FirstDataException $e){ echo $e->getMessage(); }
晚期购买(需要预认证的 transarmor_token)
<?php // get the transarmor_token from data storage $Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key')); try{ $latePurchaseResponse = $Transaction->LatePurchase('Mastercard', 'Logan Henson', $response['transarmor_token'], 1216, 123, 120); }catch(FirstDataException $e){ echo $e->getMessage(); }
## Refund
```php
<?php
$Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key'));
try{
$response = $Transaction->Refund('Mastercard', 'Logan Henson', $transarmor_token, 1216, 123, 120);
}catch(FirstDataException $e){
echo $e->getMessage();
}
更改货币类型
可以在 购买 和 晚期购买 之前使用
'EUR', 'GBP', 'CHF', 'CZK', 'DKK', 'JPY', 'ZAR', 'SEK', 'CAD'
<?php $Transaction = new Transaction(getenv('fd_gateway_id'), getenv('fd_gateway_password'), getenv('fd_key_id'), getenv('fd_key')); try{ $Transaction->setCurrency('CAD'); $response = $Transaction->Purchase('Mastercard', 'Logan Henson', 5500000000000004, 1216, 123, 120); }catch(FirstDataException $e){ echo $e->getMessage(); }
获取所有交易
$Search = new Search(getenv('fd_username'), getenv('fd_password')); try{ $transactions = $Search->getTransactions(); }catch(FirstDataException $e){ echo $e->getMessage(); }
测试数据
Visa 4111111111111111 有效期:任何未来日期。
Mastercard 5500000000000004 有效期:任何未来日期。
American Express 340000000000009 注意:Amex是15位字符 有效期:任何未来日期。
JCB 3566002020140006 有效期:任何未来日期。
Discover 6011000000000004 有效期:任何未来日期。
Diners Club 36438999960016 有效期:任何未来日期。