/ Published in: PHP
This PHP class can be used to process credit card payments via Cybersource.
It can send HTTP requests to Cybersource SOAP Web services API server to perform several types
of operations to process credit card payments.
Currently it can request a payment authorization, capture the result of a payment request and
request the reversal of a previous payment request.
This class would require php_soap and php_openssl extensions.
It can send HTTP requests to Cybersource SOAP Web services API server to perform several types
of operations to process credit card payments.
Currently it can request a payment authorization, capture the result of a payment request and
request the reversal of a previous payment request.
This class would require php_soap and php_openssl extensions.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Test script to show how the EPS_CYBERSOURCE class can be used. */ require 'class.eps_cybersource.php'; /** * These should go in a config file somewhere on the box. */ $trans_key = 'your SOAP transaction key'; $merchant_id = 'your merchant id'; $url = 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.53.wsdl'; /** * These are sent from some GUI and assembled into the applicable arrays. */ 'city'=>'Mountain View','state'=>'CA','postalCode' => '94043','country'=>'US', 'expirationYear'=>'2020','cvNumber'=>'123'); /** * Authorize a transaction. */ try { $soap = new EPS_CYBERSOURCE($url, $merchant_id,$trans_key); $soap->setMerchantDefinedData($custom_array); $soap->setCCRequest($bill_array,$card_array,$item_array); $soap->ccAuthorize(); } catch (SoapFault $e) { } /** * Capture the successful authorization. * A single ccCapture() could have been done instead of a ccAuthorize() followed by a ccCapture(). */ if ($soap->success) $soap->ccCapture(); /** * These return values would be stored locally. */ $tok = $soap->reply->requestToken; $id = $soap->reply->requestID; $rc = $soap->reply->merchantReferenceCode; $amount = $soap->reply->amount; $currency = $soap->reply->currency; 'requestID'=>$id, 'referenceCode'=>$rc, 'amount'=>$amount, 'currency'=>$currency); /** * Reverse the capture or authorization. */ if ($soap->success) { try { $soap = new EPS_CYBERSOURCE($url, $merchant_id,$trans_key); $soap->setCCReversalRequest($tok,$id,$rc,$amount); $soap->ccReverse('c'); } catch (SoapFault $e) { } } /** * Credit the account. */ if ($soap->success) { try { $soap = new EPS_CYBERSOURCE($url, $merchant_id,$trans_key); $soap->setCCCreditRequest($bill_array,$card_array); $soap->ccCredit('2.53'); } catch (SoapFault $e) { } } /** * Get some help on the XML schema. */ echo "current version: " . $soap->getHelpVersion() . "\n"; ?>
URL: http://www.phpmoot.com/php-cybersource-payment-gateway/