loganhenson/firstdata

FirstData API 包装器

v2.0.0 2015-05-06 13:06 UTC

This package is auto-updated.

Last update: 2024-09-17 05:40:55 UTC


README

Build Status

Code Climate

First Data API v14

安装

composer require loganhenson/firstdata

信息/API

交易API参考

搜索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 有效期:任何未来日期。