cancel
Showing results for 
Search instead for 
Did you mean: 

CyberSource SOAP Toolkit API Token Payment?

I would like to test a payment with already created token from the previous transaction, but can't really find a way to do that using SOAP Toolkit API.

I found this in their documentation:

 

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

So I assumed that recurringSubscriptionInfo_subscriptionID is the token that I need to provide, and wrote this code:

 

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

When I first run this code, the API complained that I didn't provide billing info, but I thought that's not necessary cause I provided the token for payment. After adding the billing info, it started complaining about missing credit card number, which doesn't make any sense, cause the whole point is to avoid sending those information and use payment token instead.

1 REPLY 1

I believe you need to enable name-value-pairs in order to provide fields using _ for nesting (e.g: recurringSubscriptionInfo_subscriptionID), when I changed your code to use XML payloads it worked:

// ...
$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;
// ...



Example, go to https://developer.cybersource.com/cybs-dev-api-ref/index.html#payments-process-a-payment /omegleshagle expand the "REQUEST FIELD DESCRIPTION" underneath and go to