我想通过以前的交易中已经创建的令牌来测试付款,但实际上找不到使用SOAP Toolkit API找到一种方法。
我在他们的文档中找到了这一点:
Requesting an On-Demand Transaction
An on-demand transaction is a real-time transaction using the details stored in a customer profile. On-demand transactions that you can request are:
Credit cards—authorization, sale (an authorization and capture), and credit.
Electronic checks—debit and credit.
PINless debits—debit.
To request an on-demand sale transaction:
Step 1 Set the ccAuthService_run service field to true.
Step 2 Set the ccCaptureService_run service field to true.
Step 3 Include the following fields in the request:
merchantID
merchantReferenceCode
purchaseTotals_currency
purchaseTotals_grandTotalAmount
recurringSubscriptionInfo_subscriptionID
所以我以为recurringSubscriptionInfo_subscriptionID
是我需要提供的令牌,并编写此代码:
$referenceCode = 'my_merchant_id';
$client = new CybsSoapClient();
$request = $client->createRequest($referenceCode);
// Build a sale request (combining an auth and capture).
$ccAuthService = new stdClass();
$ccAuthService->run = 'true';
$request->ccAuthService = $ccAuthService;
$ccCaptureService = new stdClass();
$ccCaptureService->run = 'true';
$request->ccCaptureService = $ccCaptureService;
$request->merchantID = 'my_merchant_id';
$request->merchantReferenceCode = uniqid();
$request->purchaseTotals_currency = 'USD';
$request->purchaseTotals_grandTotalAmount = '25';
$request->recurringSubscriptionInfo_subscriptionID = 'xxxxxxxx';
$reply = $client->runTransaction($request);
当我第一次运行此代码时,API抱怨我没有提供帐单信息,但是我认为这不是必需的,因为我提供了付款的令牌。添加帐单信息后,它开始抱怨丢失的信用卡号,这没有任何意义,因为重点是避免发送这些信息并使用付款代币。
我相信您需要启用名称值对,以便使用 _
进行嵌套的字段(例如: recurringSubscriptionInfo_subscriptionID
(,当我更改您的代码以使用XML有效载荷时,它可以使用:
// ...
$ccAuthService = new stdClass();
$ccAuthService->run = 'true';
$request->ccAuthService = $ccAuthService;
$ccCaptureService = new stdClass();
$ccCaptureService->run = 'true';
$request->ccCaptureService = $ccCaptureService;
$request->merchantID = '<my merchant id>';
$request->merchantReferenceCode = uniqid();
$recurringSubscriptionInfo = new stdClass();
$recurringSubscriptionInfo->subscriptionID = '<my subscription token>';
$request->recurringSubscriptionInfo = $recurringSubscriptionInfo;
$purchaseTotals = new stdClass();
$purchaseTotals->currency = 'USD';
$purchaseTotals->grandTotalAmount = '100';
$request->purchaseTotals = $purchaseTotals;
// ...