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.
Code Example: Download Example
index.php
require 'class.eps_cybersource.php' ; |
$trans_key = 'your SOAP transaction key' ; |
$merchant_id = 'your merchant id' ; |
$url = 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.53.wsdl' ; |
$bill_array = array ( 'firstName' => 'John' , 'lastName' => 'Doe' , 'street1' => '1295 Charleston Road' , |
'city' => 'Mountain View' , 'state' => 'CA' , 'postalCode' => '94043' , 'country' => 'US' , |
'email' => 'null@cybersource.com' , 'ipaddress' => '10.7.111.111' ); |
$card_array = array ( 'accountNumber' => '4111111111111111' , 'expirationMonth' => '12' , |
'expirationYear' => '2020' , 'cvNumber' => '123' ); |
array ( 'unitPrice' => '.50' , 'quantity' =>2, 'productName' => 'product one' ), |
array ( 'unitPrice' => '2.5' , 'quantity' =>1, 'productName' => 'product two' )); |
$custom_array = array ( 'one' , 'two' , 'three' , 'four' ); |
$soap = new EPS_CYBERSOURCE( $url , $merchant_id , $trans_key ); |
$soap ->setMerchantDefinedData( $custom_array ); |
$soap ->setReferenceCode( array ( 'CSTEST' , 'YYYY' , 'J' , '-' , 'RNDM' )); |
$soap ->setCCRequest( $bill_array , $card_array , $item_array ); |
if ( $soap ->success) $soap ->ccCapture(); |
$tok = $soap ->reply->requestToken; |
$id = $soap ->reply->requestID; |
$rc = $soap ->reply->merchantReferenceCode; |
$amount = $soap ->reply->amount; |
$currency = $soap ->reply->currency; |
$trans_array = array ( 'requestToken' => $tok , |
$soap = new EPS_CYBERSOURCE( $url , $merchant_id , $trans_key ); |
$soap ->setCCReversalRequest( $tok , $id , $rc , $amount ); |
$soap = new EPS_CYBERSOURCE( $url , $merchant_id , $trans_key ); |
$soap ->setCCCreditRequest( $bill_array , $card_array ); |
$soap ->setReferenceCode( array ( 'CR' , 'YYYY' , 'J' , '-' , array ( 'RNDM' ,5,5))); |
print_r( $soap ->getHelp()); |
echo "current version: " . $soap ->getHelpVersion() . "\n" ; |
print_r( $soap ->getHelp( 'item' )); |
?>
Payment gateways currently offer the best methods for online financial transactions. If you are looking for Online Payment Gateway Qatar, you should check out PaymentsMe.
ReplyDelete