From 62b7239fdf539c6fd24c2bff2621d5cdae11a0e9 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Wed, 10 Feb 2016 17:55:16 +0530 Subject: [PATCH 01/11] update the SDK after fix the class name and Contradictory issue --- sdk/Velocity/Connection.php | 14 ++-- sdk/Velocity/XmlCreator.php | 125 +++++++++++++++++++++++------------- 2 files changed, 88 insertions(+), 51 deletions(-) diff --git a/sdk/Velocity/Connection.php b/sdk/Velocity/Connection.php index f0f9953..f88fc00 100644 --- a/sdk/Velocity/Connection.php +++ b/sdk/Velocity/Connection.php @@ -9,7 +9,7 @@ class VelocityConnection public static function instance() { if (!isset(self::$instance)) { - self::$instance = new self(); + self::$instance = new self(); } return self::$instance; } @@ -212,11 +212,13 @@ private function request($method, $path, $data = array()) { if (preg_match('/json/', $contentType)) { $response = json_decode($body, true); } elseif (preg_match('/xml/', $contentType)) { - $arr = explode('Path=/', $body); - if(isset($arr[1])) - $response = VelocityXmlParser::parse($arr[1]); - else - $response = VelocityXmlParser::parse($body); + // $arr = explode('Path=/', $body); + // if(isset($arr[1])) + // $response = VelocityXmlParser::parse($arr[1]); + // else + // $response = VelocityXmlParser::parse($body); + preg_match('/<.*/', $body, $matches, PREG_OFFSET_CAPTURE); + $response = VelocityXmlParser::parse($matches[0][0]); } return array($error, $response); diff --git a/sdk/Velocity/XmlCreator.php b/sdk/Velocity/XmlCreator.php index d9d236a..d457644 100644 --- a/sdk/Velocity/XmlCreator.php +++ b/sdk/Velocity/XmlCreator.php @@ -45,8 +45,8 @@ public static function verifyXML($data) { return VelocityXmlCreator::transaction_XML($xml, $root, $data); } - public static function transaction_XML($xml, $root, $data) { - + public static function transaction_XML($xml, $root, $data) { + if (empty($data['amount'])) { throw new Exception(VelocityMessage::$descriptions['erramtnotset']); }else{ @@ -57,6 +57,12 @@ public static function transaction_XML($xml, $root, $data) { throw new Exception(VelocityMessage::$descriptions['errcarddatatokennotset']); } + if ( empty($data['entry_mode']) && (isset($data['carddata']['pan']) || isset($data['token'])) ) { + $data['entry_mode'] = 'Keyed'; + } + if ( empty($data['entry_mode']) && isset($data['carddata']['track2data']) ) { + $data['entry_mode'] = 'TrackDataFromMSR'; + } $n = $xml->createElement("ApplicationProfileId"); $idText = $xml->createTextNode(VelocityProcessor::$applicationprofileid); $n->appendChild($idText); @@ -75,36 +81,37 @@ public static function transaction_XML($xml, $root, $data) { $n1 = $xml->createElement("temp"); if( isset($data['billingdata']) ) { - $n2 = $xml->createElement("ns2:BillingData"); + $n2 = $xml->createElement("txn:BillingData"); $n1->appendChild($n2); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('name', "ns2:Name", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('name', "txn:Name", $xml, $n1, $data['billingdata']); + if(isset($data['billingdata']['address'])) { - $n3 = $xml->createElement("ns2:Address"); + $n3 = $xml->createElement("txn:Address"); $n2->appendChild($n3); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('street', "ns2:Street1", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street2', "ns2:Street2", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('City', "ns2:City", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('StateProvince', "ns2:StateProvince", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('PostalCode', "ns2:PostalCode", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('Country', "ns2:CountryCode", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('street', "txn:Street1", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street2', "txn:Street2", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('City', "txn:City", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('StateProvince', "txn:StateProvince", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('PostalCode', "txn:PostalCode", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Country', "txn:CountryCode", $xml, $n3, $data['billingdata']['address']); } - VelocityXmlCreator::populate_XML_element_if_array_value_isset('business_name', "ns2:BusinessName", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('phone', "ns2:Phone", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('fax', "ns2:Fax", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('email', "ns2:Email", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_id', "ns2:CustomerId", $xml, $n1, $data); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_tax_id', "ns2:CustomerTaxId", $xml, $n1, $data); + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('business_name', "txn:BusinessName", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('phone', "txn:Phone", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('fax', "txn:Fax", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('email', "txn:Email", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_id', "txn:CustomerId", $xml, $n1, $data); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_tax_id', "txn:CustomerTaxId", $xml, $n1, $data); } - if ( isset($data['reportingdata']) ){ - $n1 = $xml->createElement("ns2:ReportingData"); + $n1 = $xml->createElement("txn:ReportingData"); $n->appendChild($n1); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('comment', "ns2:Comment", $xml, $n1, $data['reportingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('description', "ns2:Description", $xml, $n1, $data['reportingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('reference', "ns2:Reference", $xml, $n1, $data['reportingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('comment', "txn:Comment", $xml, $n1, $data['reportingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('description', "txn:Description", $xml, $n1, $data['reportingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('reference', "txn:Reference", $xml, $n1, $data['reportingdata']); } $n1 = $xml->createElement("bcp:TenderData"); @@ -112,22 +119,24 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('token', "txn:PaymentAccountDataToken", $xml, $n1, $data); - if ( isset($data['p2pedata'])) { - VelocityXmlCreator::populate_XML_element_if_array_value_isset('SecurePaymentAccountData', "txn:SecurePaymentAccountData", $xml, $n1, $data['p2pedata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('EncryptionKeyId', "txn:EncryptionKeyId", $xml, $n1, $data['p2pedata']); - } + if ( isset($data['p2pedata'])) { + VelocityXmlCreator::populate_XML_element_if_array_value_isset('SecurePaymentAccountData', "txn:SecurePaymentAccountData", $xml, $n1, $data['p2pedata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('EncryptionKeyId', "txn:EncryptionKeyId", $xml, $n1, $data['p2pedata']); + } if ( isset($data['carddata']) ) { $n2 = $xml->createElement("bcp:CardData"); $n1->appendChild($n2); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('cardtype', "bcp:CardType", $xml, $n2, $data['carddata']); - if( $data['carddata']['track1data'] != '' || $data['carddata']['track2data'] != '') { - VelocityXmlCreator::populate_XML_element_if_array_value_isset('track1data', "bcp:Track1Data", $xml, $n2, $data['carddata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('track2data', "bcp:Track2Data", $xml, $n2, $data['carddata']); - } else { - VelocityXmlCreator::populate_XML_element_if_array_value_isset('pan', "bcp:PAN", $xml, $n2, $data['carddata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('expire', "bcp:Expire", $xml, $n2, $data['carddata']); - } + + if( $data['carddata']['track1data'] != '' || $data['carddata']['track2data'] != '') { + VelocityXmlCreator::populate_XML_element_if_array_value_isset('track1data', "bcp:Track1Data", $xml, $n2, $data['carddata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('track2data', "bcp:Track2Data", $xml, $n2, $data['carddata']); + } else { + VelocityXmlCreator::populate_XML_element_if_array_value_isset('pan', "bcp:PAN", $xml, $n2, $data['carddata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('expire', "bcp:Expire", $xml, $n2, $data['carddata']); + } } if (isset($data['avsdata']) || (isset($data['carddata']) && isset($data['cvdata']['cvv']))){ @@ -154,17 +163,16 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('Country', "bcp:CountryCode", $xml, $n3, $data['avsdata']); } - if (isset($data['carddata']) && isset($data['carddata']['cvv'])) { - - if( $data['carddata']['track1data'] == '' && $data['carddata']['track2data'] == '') { - $n3 = $xml->createElement("bcp:CVDataProvided"); - $idText = $xml->createTextNode('Provided'); - $n3->appendChild($idText); - $n2->appendChild($n3); - - VelocityXmlCreator::populate_XML_element_if_array_value_isset('cvv', "bcp:CVData", $xml, $n2, $data['carddata']); - } - } + if (isset($data['carddata']) && isset($data['carddata']['cvv'])) { + if( $data['carddata']['track1data'] == '' && $data['carddata']['track2data'] == '' ) { + $n3 = $xml->createElement("bcp:CVDataProvided"); + $idText = $xml->createTextNode('Provided'); + $n3->appendChild($idText); + $n2->appendChild($n3); + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('cvv', "bcp:CVData", $xml, $n2, $data['carddata']); + } + } } $n1 = $xml->createElement("bcp:TransactionData"); @@ -174,7 +182,34 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('currency_code', "txn:CurrencyCode", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_if_array_value_isset('transaction_datetime', "txn:TransactionDateTime", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_if_array_value_isset('campaign_id', "txn:CampaignId", $xml, $n1, $data); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('Reference', "txn:Reference", $xml, $n1, $data); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('IgnoreDuplicateCheck', "txn:IgnoreDuplicateCheck", $xml, $n1, $data); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('AccountType', "txn:AccountType", $xml, $n1, $data); + + if (isset($data['AlternativeMerchantData'])) { + $n2 = $xml->createElement("bcp:AlternativeMerchantData"); + $n1->appendChild($n2); + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('CustomerServiceInternet', "txn:CustomerServiceInternet", $xml, $n2, $data['AlternativeMerchantData']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('CustomerServicePhone', "txn:CustomerServicePhone", $xml, $n2, $data['AlternativeMerchantData']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Description', "txn:Description", $xml, $n2, $data['AlternativeMerchantData']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('SIC', "txn:SIC", $xml, $n2, $data['AlternativeMerchantData']); + + if (isset($data['AlternativeMerchantData']['Address'])) { + $n3 = $xml->createElement("txn:Address"); + $n2->appendChild($n3); + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street1', "txn:Street1", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street2', "txn:Street2", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('City', "txn:City", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('StateProvince', "txn:StateProvince", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('PostalCode', "txn:PostalCode", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('CountryCode', "txn:CountryCode", $xml, $n1, $data['AlternativeMerchantData']['Address']); + } + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('MerchantId', "txn:MerchantId", $xml, $n2, $data['AlternativeMerchantData']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Name', "txn:Name", $xml, $n2, $data['AlternativeMerchantData']); + } + VelocityXmlCreator::populate_XML_element_if_array_value_isset('approval_code', "bcp:ApprovalCode", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_with_amount_if_array_value_isset('cash_back_amount', "bcp:CashBackAmount", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_present', "bcp:CustomerPresent", $xml, $n1, $data); From a571e4ce4bc16dca65269709d7ee0d1e504817ad Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Thu, 11 Feb 2016 16:00:51 +0530 Subject: [PATCH 02/11] fixed the track1data & track2data issue. --- sdk/Velocity/XmlCreator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/Velocity/XmlCreator.php b/sdk/Velocity/XmlCreator.php index d457644..0dd0990 100644 --- a/sdk/Velocity/XmlCreator.php +++ b/sdk/Velocity/XmlCreator.php @@ -130,7 +130,7 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('cardtype', "bcp:CardType", $xml, $n2, $data['carddata']); - if( $data['carddata']['track1data'] != '' || $data['carddata']['track2data'] != '') { + if( (array_key_exists('track1data', $data['carddata']) && $data['carddata']['track1data'] != '') || (array_key_exists('track2data', $data['carddata']) && $data['carddata']['track2data'] != '')) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('track1data', "bcp:Track1Data", $xml, $n2, $data['carddata']); VelocityXmlCreator::populate_XML_element_if_array_value_isset('track2data', "bcp:Track2Data", $xml, $n2, $data['carddata']); } else { @@ -164,7 +164,7 @@ public static function transaction_XML($xml, $root, $data) { } if (isset($data['carddata']) && isset($data['carddata']['cvv'])) { - if( $data['carddata']['track1data'] == '' && $data['carddata']['track2data'] == '' ) { + if ((!array_key_exists('track1data', $data['carddata']) || $data['carddata']['track1data'] == '') && (!array_key_exists('track2data', $data['carddata']) || $data['carddata']['track2data'] == '')) { $n3 = $xml->createElement("bcp:CVDataProvided"); $idText = $xml->createTextNode('Provided'); $n3->appendChild($idText); From bbc1a18c9afb67da06b6e9bf42d39af305b6f98a Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Tue, 21 Apr 2015 19:24:07 +0530 Subject: [PATCH 03/11] update SDK and README.md --- README.md | 179 +++++++++++++++++++++++++----------- sdk/Velocity/Message.php | 2 +- sdk/Velocity/XmlCreator.php | 33 +++---- velocityClients.php | 110 +++++++++++++++++++++- 4 files changed, 243 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 3d86cb7..af1a633 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ $identitytoken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPS $applicationprofileid = 14644; $merchantprofileid = "PrestaShop Global HC"; $workflowid = 2317000001; -$isTestAccount = true; +$isTestAccount = true; + +Note: track1data and track2data optional. try { $velocityProcessor = new Velocity_Processor($applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken); @@ -41,11 +43,10 @@ To understand the Authorization & Capture process, please read our [Integration Below is an example of an authorize and capture with each of the different types of data: -#### Authorize and capture with token +#### Verify method -``` -try { - + + try { $response = $velocityProcessor->authorizeAndCapture(array( 'amount' => 10.03, 'avsdata' => array( @@ -70,12 +71,59 @@ try { print_r($response); } - $authCapTransactionid = $response['TransactionId']; + $response = $velocityProcessor->verify( array( + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => $track1data, + 'track2data' => '˜' + ) + 'entry_mode' => '˜TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); + + } catch(Exception $e) { + echo $e->getMessage(); + } + + OR + + try { -} catch(Exception $e) { - echo $e->getMessage(); -} -``` + $response = $velocityProcessor->verify( array( + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '˜', + 'track2data' => $track2data + ), + 'entry_mode' => '˜TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); + + } catch (Exception $e) { + echo $e->getMessage(); + } #### Authorize and capture with keyed data @@ -192,10 +240,9 @@ try { } ``` -#### Capture + OR -``` -try { + try { $response = $velocityProcessor->capture(array( 'amount' => 6.03, @@ -212,12 +259,11 @@ try { $captxnid = $response['TransactionId']; -} catch(Exception $e) { - echo $e->getMessage(); -} -``` + } catch (Exception $e) { + echo $e->getMessage(); die; + } -#### Undo (Void/Reversal) +#### Capture method: ``` try { @@ -225,26 +271,43 @@ try { $response = $velocityProcessor->undo(array( 'TransactionId' => $adjusttxnid )); + - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'Undo Successful!
'; - echo 'TransactionId: ' . $response['TransactionId'] . '

'; - } else { - // some error - print_r($response); + $response = $velocityProcessor->capture( array( + 'amount' => 6.03, + 'TransactionId' => $authTransactionid + )); + $captxnid = $response['TransactionId']; + + } catch(Exception $e) { + echo $e->getMessage(); } - -} catch (Exception $e) { - echo $e->getMessage(); -} -``` -#### Adjust +Note : $authTransactionid is get from authorize response. -``` -try { - - $response = $velocityProcessor->adjust(array( + + + + +#### Void(Undo) method: + + try { + $response = $velocityProcessor->undo( array( + 'TransactionId' => $adjusttxnid + ) + ); + + } catch (Exception $e) { + echo $e->getMessage(); + } + + + + +#### Adjust method: + + try { + $response = $velocityProcessor->adjust(array( 'amount' => 3.01, 'TransactionId' => $captxnid )); @@ -255,14 +318,13 @@ try { } else { // some error print_r($response); + + } catch (Exception $e) { + echo $e->getMessage(); } - -} catch (Exception $e) { - echo $e->getMessage(); -} -``` + + $adjusttxnid = $response['TransactionId']; -#### ReturnById ``` try { @@ -271,20 +333,10 @@ try { 'TransactionId' => $authCapTransactionid )); - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'ReturnById Successful!
'; - echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; - } else { - // some error - print_r($response); + } catch (Exception $e) { + echo $e->getMessage(); } -} catch (Exception $e) { - echo $e->getMessage(); -} -``` - -#### ReturnUnlinked with token: ``` try { @@ -308,11 +360,28 @@ try { } ``` -#### Verify method + OR -``` -try { + try { + + $response = $velocityProcessor->returnUnlinked( array( + 'amount' => 1.03, + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '˜', + 'track2data' => track2data + ), + 'order_id' => '629203' + 'entry_mode' => '˜TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); + $response = $velocityProcessor->verify(array( 'avsdata' => array( 'Street' => 'xyz', diff --git a/sdk/Velocity/Message.php b/sdk/Velocity/Message.php index a3dd074..c129122 100644 --- a/sdk/Velocity/Message.php +++ b/sdk/Velocity/Message.php @@ -13,7 +13,7 @@ public function __construct(){ 'errgetmethod' => 'Requested url of gateway is not valid.', 'errputmethod' => 'Requested url of gateway is not valid.', 'errunknown' => 'some unknown technical issue.', - 'errsignon' => 'Your order cannot be completed at this time. If you need further assistance please contact customer care. Error Code 8124', + 'errsignon' => 'An invalid security token was provided', 'errmrchtid' => 'Invalid merchant credential', 'errpannum' => 'Invalid credit card number', 'errexpire' => 'Invalid expiry month and/or year', diff --git a/sdk/Velocity/XmlCreator.php b/sdk/Velocity/XmlCreator.php index 89164e5..ef20d42 100644 --- a/sdk/Velocity/XmlCreator.php +++ b/sdk/Velocity/XmlCreator.php @@ -46,6 +46,7 @@ public static function verifyXML($data) { } public static function transaction_XML($xml, $root, $data) { + if (empty($data['amount'])) { throw new Exception(VelocityMessage::$descriptions['erramtnotset']); }else{ @@ -55,23 +56,7 @@ public static function transaction_XML($xml, $root, $data) { if (empty($data['token']) && empty($data['carddata']) && empty($data['p2pedata']) ) { throw new Exception(VelocityMessage::$descriptions['errcarddatatokennotset']); } - - if ( empty($data['entry_mode']) && (isset($data['carddata']['pan']) || isset($data['token'])) ) { - $data['entry_mode'] = 'Keyed'; - } - - if ( empty($data['entry_mode']) && isset($data['carddata']['track2data']) ) { - $data['entry_mode'] = 'TrackDataFromMSR'; - } - if ( empty($data['entry_mode']) && isset($data['p2pedata']['EncryptionKeyId'] ) ) { - $data['entry_mode'] = 'TrackDataFromMSR'; - $data['IndustryType'] = 'Retail'; - $data['Reference'] = 'xyt'; - $data['EmployeeId'] = '11'; - } else { - $data['IndustryType'] = 'Ecommerce'; - } - + $n = $xml->createElement("ApplicationProfileId"); $idText = $xml->createTextNode(VelocityProcessor::$applicationprofileid); $n->appendChild($idText); @@ -138,10 +123,13 @@ public static function transaction_XML($xml, $root, $data) { $n2 = $xml->createElement("bcp:CardData"); $n1->appendChild($n2); VelocityXmlCreator::populate_XML_element_if_array_value_isset('cardtype', "bcp:CardType", $xml, $n2, $data['carddata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('pan', "bcp:PAN", $xml, $n2, $data['carddata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('expire', "bcp:Expire", $xml, $n2, $data['carddata']);; - VelocityXmlCreator::populate_XML_element_if_array_value_isset('track1data', "bcp:Track1Data", $xml, $n2, $data['carddata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('track2data', "bcp:Track2Data", $xml, $n2, $data['carddata']); + if( $data['carddata']['track1data'] != '' || $data['carddata']['track2data'] != '') { + VelocityXmlCreator::populate_XML_element_if_array_value_isset('track1data', "bcp:Track1Data", $xml, $n2, $data['carddata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('track2data', "bcp:Track2Data", $xml, $n2, $data['carddata']); + } else { + VelocityXmlCreator::populate_XML_element_if_array_value_isset('pan', "bcp:PAN", $xml, $n2, $data['carddata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('expire', "bcp:Expire", $xml, $n2, $data['carddata']); + } } if (isset($data['avsdata']) || (isset($data['carddata']) && isset($data['cvdata']['cvv']))){ @@ -169,12 +157,15 @@ public static function transaction_XML($xml, $root, $data) { } if (isset($data['carddata']) && isset($data['carddata']['cvv'])) { + + if( $data['carddata']['track1data'] == '' && $data['carddata']['track2data'] == '') { $n3 = $xml->createElement("bcp:CVDataProvided"); $idText = $xml->createTextNode('Provided'); $n3->appendChild($idText); $n2->appendChild($n3); VelocityXmlCreator::populate_XML_element_if_array_value_isset('cvv', "bcp:CVData", $xml, $n2, $data['carddata']); + } } } diff --git a/velocityClients.php b/velocityClients.php index bd2b97b..a221b11 100644 --- a/velocityClients.php +++ b/velocityClients.php @@ -37,8 +37,21 @@ * carddata optional for use SDK only without transparent redirect. * Note: array key must be not change. */ + $cardDataKeyed = array('cardowner' => 'Jane Doe', 'cardtype' => 'Visa', 'pan' => '4012888812348882', 'expire' => '1215', 'cvv' => '123'); $cardDataSwiped = array('track2data' => '4012000033330026=09041011000012345678', 'cardtype' => 'Visa'); + + $cardData = array( + 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '4012888812348882', + 'expire' => '1215', + 'cvv' => '123', + 'track1data' => '', + 'track2data' => '' + ); + $trackData = array('track2data' => '4012000033330026=09041011000012345678', 'cardtype' => 'Visa'); + /* *****************************************************verify************************************************************************* */ @@ -46,7 +59,11 @@ $response = $velocityProcessor->verify(array( 'avsdata' => $avsData, - 'carddata' => $cardDataKeyed, + 'carddata' => $cardDataKeyed, + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); if (isset($response['Status']) && $response['Status'] == 'Successful') { @@ -72,6 +89,10 @@ 'avsdata' => $avsData, 'token' => $paymentAccountDataToken, 'order_id' => '629203', + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); if (isset($response['Status']) && $response['Status'] == 'Successful') { @@ -150,7 +171,11 @@ $response = $velocityProcessor->authorize(array( 'amount' => 10, 'carddata' => $cardDataKeyed, - 'order_id' => '629203' + 'order_id' => '629203', + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); if (isset($response['Status']) && $response['Status'] == 'Successful') { @@ -267,7 +292,11 @@ $response = $velocityProcessor->returnUnlinked(array( 'amount' => 1.03, 'token' => $paymentAccountDataToken, - 'order_id' => '629203' + 'order_id' => '629203', + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); @@ -350,7 +379,11 @@ 'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88', 'EncryptionKeyId' => '9010010B257DC7000084' ), - 'order_id' => '629203' + 'order_id' => '629203', + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); if (isset($response['Status']) && $response['Status'] == 'Successful') { @@ -368,9 +401,78 @@ echo $e->getMessage(); } + /* *****************************************************CaptureAll******************************************************************************** */ $identitytoken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPSIxIiBBc3NlcnRpb25JRD0iXzQ2ZTdkZDAzLTIwYzctNGJlZS1hNTdhLWRiNmE4MTA5MDlkNiIgSXNzdWVyPSJJcGNBdXRoZW50aWNhdGlvbiIgSXNzdWVJbnN0YW50PSIyMDE0LTExLTA3VDIxOjQ5OjU2Ljg3N1oiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjEuMDphc3NlcnRpb24iPjxzYW1sOkNvbmRpdGlvbnMgTm90QmVmb3JlPSIyMDE0LTExLTA3VDIxOjQ5OjU2Ljg3N1oiIE5vdE9uT3JBZnRlcj0iMjA0NC0xMS0wN1QyMTo0OTo1Ni44NzdaIj48L3NhbWw6Q29uZGl0aW9ucz48c2FtbDpBZHZpY2U+PC9zYW1sOkFkdmljZT48c2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PHNhbWw6U3ViamVjdD48c2FtbDpOYW1lSWRlbnRpZmllcj4xQzA4MTc1OEVFNzAwMDAxPC9zYW1sOk5hbWVJZGVudGlmaWVyPjwvc2FtbDpTdWJqZWN0PjxzYW1sOkF0dHJpYnV0ZSBBdHRyaWJ1dGVOYW1lPSJTQUsiIEF0dHJpYnV0ZU5hbWVzcGFjZT0iaHR0cDovL3NjaGVtYXMuaXBjb21tZXJjZS5jb20vSWRlbnRpdHkiPjxzYW1sOkF0dHJpYnV0ZVZhbHVlPjFDMDgxNzU4RUU3MDAwMDE8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgQXR0cmlidXRlTmFtZT0iU2VyaWFsIiBBdHRyaWJ1dGVOYW1lc3BhY2U9Imh0dHA6Ly9zY2hlbWFzLmlwY29tbWVyY2UuY29tL0lkZW50aXR5Ij48c2FtbDpBdHRyaWJ1dGVWYWx1ZT40OTJhNWU0Yi02NWE0LTRkOTktYjQ0MS1iMzJjOTdmODNkNzY8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgQXR0cmlidXRlTmFtZT0ibmFtZSIgQXR0cmlidXRlTmFtZXNwYWNlPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcyI+PHNhbWw6QXR0cmlidXRlVmFsdWU+MUMwODE3NThFRTcwMDAwMTwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjwvc2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PFNpZ25hdHVyZSB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyI+PFNpZ25lZEluZm8+PENhbm9uaWNhbGl6YXRpb25NZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzEwL3htbC1leGMtYzE0biMiPjwvQ2Fub25pY2FsaXphdGlvbk1ldGhvZD48U2lnbmF0dXJlTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnI3JzYS1zaGExIj48L1NpZ25hdHVyZU1ldGhvZD48UmVmZXJlbmNlIFVSST0iI180NmU3ZGQwMy0yMGM3LTRiZWUtYTU3YS1kYjZhODEwOTA5ZDYiPjxUcmFuc2Zvcm1zPjxUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjZW52ZWxvcGVkLXNpZ25hdHVyZSI+PC9UcmFuc2Zvcm0+PFRyYW5zZm9ybSBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvMTAveG1sLWV4Yy1jMTRuIyI+PC9UcmFuc2Zvcm0+PC9UcmFuc2Zvcm1zPjxEaWdlc3RNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjc2hhMSI+PC9EaWdlc3RNZXRob2Q+PERpZ2VzdFZhbHVlPlQ2QmZhUDB2bXgwRitsT3JrRDVja0h4U2lYRT08L0RpZ2VzdFZhbHVlPjwvUmVmZXJlbmNlPjwvU2lnbmVkSW5mbz48U2lnbmF0dXJlVmFsdWU+VHBOalhUNnFMejZ5K2RYVU5yQlRQV0hqVitWbmVkTlNNNTNqdzB5N1RxK1NndEI1OEcvWjdKTEFoNUVLRTBqRERpMHRuQ3cvdmF3bGZ6TjU3VVBxeERzZVpmb1FobmJpQzVxVm5CNmZyOVFZRTlYQ0d1OG01bXhLYno2djl3QzVkVlFEMmxXenRFT0trcnZWL1kwRFVOR2drOEZpdFhmbk1rMVpvakdnNzUvaVFHYW4vUFlWaTBNZDYvc3JLZ1IzdkVsTTlUMm5GWVNkSmlrZUFvM3cweUlEZDNPbG5PL2UyNE1GTzQxdlE3d3lIZDBZUkdDZ2I1YVU4K0ZYelJRbXlyK00rU1RpQVlHT3MwcGRPVE9RNlBleGRITndFS1YzVzJkSUExaElIR2EvUmY0WWc0d0p2aTNublJHd2Z2b1h3RlZYckNsd1d4SVV4ODR2eGtDNitnPT08L1NpZ25hdHVyZVZhbHVlPjxLZXlJbmZvPjxvOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2UgeG1sbnM6bz0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzLzIwMDQvMDEvb2FzaXMtMjAwNDAxLXdzcy13c3NlY3VyaXR5LXNlY2V4dC0xLjAueHNkIj48bzpLZXlJZGVudGlmaWVyIFZhbHVlVHlwZT0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzL29hc2lzLXdzcy1zb2FwLW1lc3NhZ2Utc2VjdXJpdHktMS4xI1RodW1icHJpbnRTSEExIj5ZREJlRFNGM0Z4R2dmd3pSLzBwck11OTZoQ2M9PC9vOktleUlkZW50aWZpZXI+PC9vOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2U+PC9LZXlJbmZvPjwvU2lnbmF0dXJlPjwvc2FtbDpBc3NlcnRpb24+"; + + /* *****************************************************Authorizeandcapture P2PE******************************************** */ + + try { + + $response = $VelocityProcessor->authorizeAndCapture(array( + 'amount' => 10.03, + 'avsdata' => $avsData, + 'p2pedata' => array( + 'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88', + 'EncryptionKeyId' => '9010010B257DC7000084' + ), + 'order_id' => '629203', + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'P2PE AuthorizeAndCapture Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId'] . '

'; + } else { + // some error + echo '
'; print_r($response); echo '
'; + } + + + } catch(Exception $e) { + echo $e->getMessage(); + } + + /* *****************************************************ReturnUnlinked P2PE************************************************* */ + + try { + + $response = $VelocityProcessor->returnUnlinked(array( + 'amount' => 1.03, + 'p2pedata' => array( + 'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88', + 'EncryptionKeyId' => '9010010B257DC7000084' + ), + 'order_id' => '629203', + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'P2PE ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId'] . '

'; + } else { + // some error + echo '
'; print_r($response); echo '
'; + } + + } catch (Exception $e) { + echo $e->getMessage(); + } + + $applicationprofileid = 15464; $merchantprofileid = "GlobalEastTCEBT"; $workflowid = "A39DF00001"; From b06b5690cd6ef2b9d2547546b4f2c928f58cdfe1 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Wed, 22 Apr 2015 15:44:27 +0530 Subject: [PATCH 04/11] update readme.md --- README.md | 468 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 431 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index af1a633..37201c7 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,7 @@ $identitytoken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPS $applicationprofileid = 14644; $merchantprofileid = "PrestaShop Global HC"; $workflowid = 2317000001; -$isTestAccount = true; - -Note: track1data and track2data optional. +$isTestAccount = true; try { $velocityProcessor = new Velocity_Processor($applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken); @@ -242,8 +240,6 @@ try { OR - try { - $response = $velocityProcessor->capture(array( 'amount' => 6.03, 'TransactionId' => $authTransactionid @@ -273,36 +269,120 @@ try { )); - $response = $velocityProcessor->capture( array( - 'amount' => 6.03, - 'TransactionId' => $authTransactionid - )); - $captxnid = $response['TransactionId']; + $authTransactionid = $response['TransactionId']; - } catch(Exception $e) { - echo $e->getMessage(); - } - -Note : $authTransactionid is get from authorize response. - - + } catch(Exception $e) { + echo $e->getMessage(); + } + OR + + try { + $response = $velocityProcessor->authorize( array( + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '', + 'track2data' => '4012000033330026=09041011000012345678', + ), + 'order_id' => '629203', + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + ) + ); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Authorize Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } + + $authTransactionid = $response['TransactionId']; + + } catch(Exception $e) { + echo $e->getMessage(); + } +``` +### Authorize with encrypted data -#### Void(Undo) method: +Before doing the actualy transaction, you must re-instantiate your processor with the proper workflow id (provided by your velocity representative): - try { - $response = $velocityProcessor->undo( array( - 'TransactionId' => $adjusttxnid - ) - ); - +``` + $workflowid = 'BBBAAA0001'; + try { + $velocityProcessor = new VelocityProcessor( $applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken ); } catch (Exception $e) { - echo $e->getMessage(); - } + echo $e->getMessage(); + } +``` +Then you can perform the transaction: +``` + try{ + $response = $velocityProcessor->authorize( + array( + 'amount' => $cash, + 'p2pedata' => array( + 'SecurePaymentAccountData' => $SecurePaymentAccountData, + 'EncryptionKeyId' => $EncryptionKeyId + ), + 'order_id' => '629203' + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful'){ + echo 'Authorize Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } + + $authTransactionid = $response['TransactionId']; + } catch (Exception $ex) { + echo $e->getMessage(); + } +..... +#### Capture + try { + + $response = $velocityProcessor->capture(array( + 'amount' => 6.03, + 'TransactionId' => $authTransactionid + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Capture Successful!
'; + echo 'Amount: ' . $response['TransactionSummaryData']['NetTotals']['NetAmount']; + } else { + // some error + print_r($response); + } #### Adjust method: @@ -325,6 +405,56 @@ Note : $authTransactionid is get from authorize response. $adjusttxnid = $response['TransactionId']; + $captxnid = $response['TransactionId']; + +} catch(Exception $e) { + echo $e->getMessage(); +} + +#### Undo (Void/Reversal) + +``` +try { + $response = $velocityProcessor->undo(array( + 'TransactionId' => $adjusttxnid + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Undo Successful!
'; + echo 'TransactionId: ' . $response['TransactionId'] . '

'; + } else { + // some error + print_r($response); + } + +} catch (Exception $e) { + echo $e->getMessage(); +} +``` + +#### Adjust + +``` +try { + $response = $velocityProcessor->adjust(array( + 'amount' => 3.01, + 'TransactionId' => $captxnid + )); + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Adjust Successful!
'; + echo 'Amount: ' . $response['Amount'] . '

'; + $adjusttxnid = $response['TransactionId']; + } else { + // some error + print_r($response); + } + +} catch (Exception $e) { + echo $e->getMessage(); +} +``` + +#### ReturnById ``` try { @@ -333,10 +463,18 @@ try { 'TransactionId' => $authCapTransactionid )); - } catch (Exception $e) { - echo $e->getMessage(); + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnById Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); } +} catch (Exception $e) { + echo $e->getMessage(); +} +``` ``` try { @@ -345,6 +483,10 @@ try { 'amount' => 1.03, 'token' => $paymentAccountDataToken, 'order_id' => '629203' + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); if (isset($response['Status']) && $response['Status'] == 'Successful') { @@ -359,26 +501,93 @@ try { echo $e->getMessage(); } ``` +#### ReturnUnlinked with keyed data - OR +``` +try { + $response = $velocityProcessor->returnUnlinked( array( + 'amount' => 1.03, + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '4012888812348882', + 'expire' => '1215', + 'cvv' => '123' + 'track1data' => '', + 'track2data' => '' + ), + 'order_id' => '629203' + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } + + } catch(Exception $e) { + echo $e->getMessage(); + } +``` - try { - - $response = $velocityProcessor->returnUnlinked( array( +### ReturnUnlinked with swiped data + +``` + + try { + $response = $velocityProcessor->returnUnlinked( array( + 'amount' => 1.03, + 'carddata' => array( + 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '%B4012000033330026^NAJEER/SHAIK ^0904101100001100000000123456780?', + 'track2data' => '' + ), + 'order_id' => '629203' + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } + + } catch(Exception $e) { + echo $e->getMessage(); + } + + OR + + try { + $response = $velocityProcessor->returnUnlinked( array( 'amount' => 1.03, 'carddata' => array( 'cardowner' => 'Jane Doe', 'cardtype' => 'Visa', 'pan' => '', 'expire' => '', 'cvv' => '' - 'track1data' => '˜', - 'track2data' => track2data + 'track1data' => '', + 'track2data' => '4012000033330026=09041011000012345678' ), 'order_id' => '629203' - 'entry_mode' => '˜TrackDataFromMSR', + 'entry_mode' => 'TrackDataFromMSR', 'IndustryType' =>'Retail', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); @@ -415,6 +624,191 @@ try { ####CaptureAll Method: +``` + try{ + $velocityProcessor->captureAll(); + } catch (Exception $ex) { + echo $e->getMessage(); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } + + } catch(Exception $e) { + echo $e->getMessage(); + } +``` + +### ReturnUnlinked with encrypted data + +Before doing the actualy transaction, you must re-instantiate your processor with the proper workflow id (provided by your velocity representative): + +``` + $workflowid = 'BBBAAA0001'; + try { + $velocityProcessor = new VelocityProcessor( $applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken ); + } catch (Exception $e) { + echo $e->getMessage(); + } +``` + +Then you can perform the transaction: + +``` + try{ + $response = $velocityProcessor->returnUnlinked ( array( + 'amount' => $cash, + 'p2pedata' => array( + 'SecurePaymentAccountData' => $SecurePaymentAccountData, + 'EncryptionKeyId' => $EncryptionKeyId + ), + 'order_id' => '629203' + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } + } catch (Exception $ex) { + echo $e->getMessage(); + } + +#### Verify with keyed data +``` + try { + $response = $velocityProcessor->verify(array( + 'avsdata' => array( + 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( + 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '4012888812348882', + 'expire' => '1215', + 'cvv' => '123' + 'track1data' => '', + 'track2data' => '' + ), + 'order_id' => '629203' + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Verify Successful!
'; + echo 'PostalCodeResult: ' . $response['AVSResult']['PostalCodeResult'] . '
'; + echo 'CVResult: ' . $response['CVResult']; + } else { + // some error + print_r($response); + } + + } catch(Exception $e) { + echo $e->getMessage(); + } +``` + + +### Verify with swiped data +``` + + try { + $response = $velocityProcessor->verify( array( + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '%B4012000033330026^NAJEER/SHAIK ^0904101100001100000000123456780?', + 'track2data' => '' + ) + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Verify Successful!
'; + echo 'PostalCodeResult: ' . $response['AVSResult']['PostalCodeResult'] . '
'; + echo 'CVResult: ' . $response['CVResult']; + } else { + // some error + print_r($response); + } + + } catch(Exception $e) { + echo $e->getMessage(); + + } +``` + + +####QueryTransactionDetail Method: + + OR + + try { + $response = $velocityProcessor->verify( array( + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '', + 'track2data' => '4012000033330026=09041011000012345678' + ), + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Verify Successful!
'; + echo 'PostalCodeResult: ' . $response['AVSResult']['PostalCodeResult'] . '
'; + echo 'CVResult: ' . $response['CVResult']; + } else { + // some error + print_r($response); + } + + } catch(Exception $e) { + echo $e->getMessage(); + } +``` + +####CaptureAll Method: + ``` try{ $velocityProcessor->captureAll(); From ef50a90c72276f89a46291d35acb5d87a0c3bf29 Mon Sep 17 00:00:00 2001 From: ashishCetuG Date: Wed, 22 Apr 2015 15:53:20 +0530 Subject: [PATCH 05/11] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 37201c7..adfc56e 100644 --- a/README.md +++ b/README.md @@ -726,7 +726,7 @@ Then you can perform the transaction: ``` -### Verify with swiped data +#### Verify with swiped data ``` try { @@ -807,7 +807,7 @@ Then you can perform the transaction: } ``` -####CaptureAll Method: +#### CaptureAll Method: ``` try{ @@ -817,7 +817,7 @@ Then you can perform the transaction: } ``` -####QueryTransactionDetail Method: +#### QueryTransactionDetail Method: ``` try { @@ -856,4 +856,4 @@ Then you can perform the transaction: } catch(Exception $e) { echo $e->getMessage(); } -``` \ No newline at end of file +``` From 6b803849ef4d38b3f8edb24f7e5702a2656dc397 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Tue, 21 Apr 2015 19:24:07 +0530 Subject: [PATCH 06/11] update SDK and README.md --- README.md | 463 ++++++++++++++++++++++++++++++-------------- velocityClients.php | 73 ++++++- 2 files changed, 389 insertions(+), 147 deletions(-) diff --git a/README.md b/README.md index adfc56e..6b0c448 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ $identitytoken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPS $applicationprofileid = 14644; $merchantprofileid = "PrestaShop Global HC"; $workflowid = 2317000001; -$isTestAccount = true; +$isTestAccount = true; + +Note: track1data and track2data optional. try { $velocityProcessor = new Velocity_Processor($applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken); @@ -123,120 +125,256 @@ Below is an example of an authorize and capture with each of the different types echo $e->getMessage(); } -#### Authorize and capture with keyed data +#### Authorize and capture with token Method: + + try { + $response = $velocityProcessor->authorizeAndCapture( array( + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'token' => $paymentAccountDataToken, + 'order_id' => '629203', + 'entry_mode' => '˜Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + ) + ); + + $authCapTransactionid = $response['TransactionId']; + + } catch(Exception $e) { + echo $e->getMessage(); + } + +Note: $paymentAccountDataToken is get from verify response. + + +#### Authorize and capture without token Method: + + try { + $response = $velocityProcessor->authorizeAndCapture( array( + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( + 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '4012888812348882', + 'expire' => '1215', + 'cvv' => '123' + 'track1data' => '', + 'track2data' => '' ), + 'order_id' => '629203', + 'entry_mode' => '˜Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + ) + ); + + $authCapTransactionid = $response['TransactionId']; + + } catch(Exception $e) { + echo $e->getMessage(); + } -``` -try { - $response = $velocityProcessor->authorizeAndCapture(array( - 'amount' => 10.03, - 'avsdata' => array( - 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'carddata' => array( - 'cardowner' => 'Jane Doe', - 'cardtype' => 'Visa', - 'pan' => '4012888812348882', - 'expire' => '1215', - 'cvv' => '123' - ), - 'order_id' => '629203', - )); -``` + OR -### Authorize and capture with swiped data + try { + $response = $velocityProcessor->authorizeAndCapture( array( + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => track1data, + 'track2data' => '˜' ), + 'order_id' => '629203', + 'entry_mode' => '˜TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + ) + ); + + $authCapTransactionid = $response['TransactionId']; + + } catch(Exception $e) { + echo $e->getMessage(); + } -``` - $response = $velocityProcessor->authorizeAndCapture(array( - 'amount' => 10.03, - 'avsdata' => array( - 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'carddata' => array( - 'track2data' => '4012000033330026=09041011000012345678', - 'cardtype' => 'Visa' - ), - 'order_id' => '629203', - )); -``` + OR -### Authorize and capture with encrypted data + try { + $response = $velocityProcessor->authorizeAndCapture( array( + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '˜', + 'track2data' => track2data, + ), + 'order_id' => '629203', + 'entry_mode' => '˜TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + ) + ); -Before doing the actualy transaction, you must re-instantiate your processor with the proper workflow id (provided by your velocity representative): + $authCapTransactionid = $response['TransactionId']; + + } catch(Exception $e) { + echo $e->getMessage(); + } -``` - $workflowid = 'BBBAAA0001'; - try { - $velocityProcessor = new VelocityProcessor( $applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken ); +##### Authorize method with Token: + + try { + + $response = $velocityProcessor->authorize( array( + 'amount' => 10, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'token' => $paymentAccountDataToken, + 'order_id' => '629203' + 'entry_mode' => '˜Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); + + $authTransactionid = $response['TransactionId']; + } catch (Exception $e) { - echo $e->getMessage(); - } -``` + echo $e->getMessage(); die; + } -Then you can perform the transaction: +##### Authorize method without Token: + + try { + + $response = $velocityProcessor->authorize( array( + 'amount' => 10, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '4012888812348882', + 'expire' => '1215', + 'cvv' => '123' + 'track1data' => '', + 'track2data' => '˜' ), + 'order_id' => '629203' + 'entry_mode' => '˜Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + ) ); + + $authTransactionid = $response['TransactionId']; + + } catch (Exception $e) { + echo $e->getMessage(); die; + } -``` - $response = $velocityProcessor->authorizeAndCapture(array( - 'amount' => 10.03, - 'avsdata' => array( - 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'p2pedata' => array( - 'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88', - 'EncryptionKeyId' => '9010010B257DC7000084' - ), - 'order_id' => '629203', - )); -``` + OR -The rest of the payment methods can be found below: + try { + + $response = $velocityProcessor->authorize( array( + 'amount' => 10, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => track1data, + 'track2data' => '˜' + ), + 'order_id' => '629203' + 'entry_mode' => '˜TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); + + $authTransactionid = $response['TransactionId']; + + } catch (Exception $e) { + echo $e->getMessage(); die; + } -#### Authorize method +OR -``` -try { - - $response = $velocityProcessor->authorize(array( - 'amount' => 10, - 'avsdata' => array( - 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'token' => $paymentAccountDataToken, - 'order_id' => '629203' - )); + try { - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'Authorize Successful!
'; - echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; - echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; - echo 'Amount: ' . $response['Amount'] . '
'; - echo 'TransactionId: ' . $response['TransactionId']; - } else { - // some error - print_r($response); - } - - $authTransactionid = $response['TransactionId']; + $response = $velocityProcessor->authorize( array( + 'amount' => 10, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '˜', + 'track2data' => track2data + ), + 'order_id' => '629203' + 'entry_mode' => '˜TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); + + $authTransactionid = $response['TransactionId']; -} catch (Exception $e) { - echo $e->getMessage(); -} -``` + } catch (Exception $e) { + echo $e->getMessage(); die; + } OR @@ -261,9 +399,9 @@ try { #### Capture method: -``` -try { + try { + $response = $velocityProcessor->undo(array( 'TransactionId' => $adjusttxnid )); @@ -411,9 +549,6 @@ Then you can perform the transaction: echo $e->getMessage(); } -#### Undo (Void/Reversal) - -``` try { $response = $velocityProcessor->undo(array( 'TransactionId' => $adjusttxnid @@ -430,11 +565,7 @@ try { } catch (Exception $e) { echo $e->getMessage(); } -``` - -#### Adjust -``` try { $response = $velocityProcessor->adjust(array( 'amount' => 3.01, @@ -447,36 +578,29 @@ try { } else { // some error print_r($response); + } - -} catch (Exception $e) { - echo $e->getMessage(); -} -``` + + $adjusttxnid = $response['TransactionId']; -#### ReturnById -``` -try { - $response = $velocityProcessor->returnById(array( - 'amount' => 5.03, - 'TransactionId' => $authCapTransactionid - )); + + + +##### ReturnById method: + + try { + $response = $velocityProcessor->returnById( array( + 'amount' => 5.03, + 'TransactionId' => $authCapTransactionid + ) + ); - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'ReturnById Successful!
'; - echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; - } else { - // some error - print_r($response); + } catch (Exception $e) { + echo $e->getMessage(); } -} catch (Exception $e) { - echo $e->getMessage(); -} -``` - -``` + try { $response = $velocityProcessor->returnUnlinked(array( @@ -574,6 +698,7 @@ try { try { $response = $velocityProcessor->returnUnlinked( array( + 'amount' => 1.03, 'carddata' => array( 'cardowner' => 'Jane Doe', 'cardtype' => 'Visa', @@ -617,16 +742,69 @@ try { print_r($response); } -} catch(Exception $e) { - echo $e->getMessage(); + +For below all credential provided by velocity gateway. +$SecurePaymentAccountData +$EncryptionKeyId + +##### P2PE for Authorize: + + try{ + $response = $velocityProcessor->authorize( + array( + 'amount' => $cash, + 'p2pedata' => array( + 'SecurePaymentAccountData' => $SecurePaymentAccountData, + 'EncryptionKeyId' => $EncryptionKeyId + ), + 'order_id' => '629203' + 'entry_mode' => '˜Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + ) +); + } catch (Exception $ex) { + echo $e->getMessage(); } -``` -####CaptureAll Method: +#### P2PE for AuthorizeandCapture: -``` - try{ - $velocityProcessor->captureAll(); + try{ + $response = $velocityProcessor->authorizeAndCapture( + array( + 'amount' => $cash, + 'p2pedata' => array( + 'SecurePaymentAccountData' => $SecurePaymentAccountData, + 'EncryptionKeyId' => $EncryptionKeyId + ), + 'order_id' => '629203' + 'entry_mode' => '˜Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); + + } catch (Exception $ex) { + echo $e->getMessage(); + } + + +##### P2PE for ReturnUnlinked: + + try{ + $response = $velocityProcessor->returnUnlinked ( array( + 'amount' => $cash, + 'p2pedata' => array( + 'SecurePaymentAccountData' => $SecurePaymentAccountData, + 'EncryptionKeyId' => $EncryptionKeyId + ), + 'order_id' => '629203' + 'entry_mode' => '˜Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); } catch (Exception $ex) { echo $e->getMessage(); @@ -764,7 +942,6 @@ Then you can perform the transaction: echo $e->getMessage(); } -``` ####QueryTransactionDetail Method: @@ -856,4 +1033,4 @@ Then you can perform the transaction: } catch(Exception $e) { echo $e->getMessage(); } -``` + diff --git a/velocityClients.php b/velocityClients.php index a221b11..a45098b 100644 --- a/velocityClients.php +++ b/velocityClients.php @@ -51,7 +51,6 @@ 'track2data' => '' ); $trackData = array('track2data' => '4012000033330026=09041011000012345678', 'cardtype' => 'Visa'); - /* *****************************************************verify************************************************************************* */ @@ -401,12 +400,78 @@ echo $e->getMessage(); } - - /* *****************************************************CaptureAll******************************************************************************** */ + /* *****************************************************Authorizeandcapture P2PE******************************************** */ + + try { + + $response = $VelocityProcessor->authorizeAndCapture(array( + 'amount' => 10.03, + 'avsdata' => $avsData, + 'p2pedata' => array( + 'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88', + 'EncryptionKeyId' => '9010010B257DC7000084' + ), + 'order_id' => '629203', + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'P2PE AuthorizeAndCapture Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId'] . '

'; + } else { + // some error + echo '
'; print_r($response); echo '
'; + } + + + } catch(Exception $e) { + echo $e->getMessage(); + } + + /* *****************************************************ReturnUnlinked P2PE************************************************* */ + + try { + + $response = $VelocityProcessor->returnUnlinked(array( + 'amount' => 1.03, + 'p2pedata' => array( + 'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88', + 'EncryptionKeyId' => '9010010B257DC7000084' + ), + 'order_id' => '629203', + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'P2PE ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId'] . '

'; + } else { + // some error + echo '
'; print_r($response); echo '
'; + } + + } catch (Exception $e) { + echo $e->getMessage(); + } + + + /* *****************************************************CaptureAll******************************************************************************** */ $identitytoken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPSIxIiBBc3NlcnRpb25JRD0iXzQ2ZTdkZDAzLTIwYzctNGJlZS1hNTdhLWRiNmE4MTA5MDlkNiIgSXNzdWVyPSJJcGNBdXRoZW50aWNhdGlvbiIgSXNzdWVJbnN0YW50PSIyMDE0LTExLTA3VDIxOjQ5OjU2Ljg3N1oiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjEuMDphc3NlcnRpb24iPjxzYW1sOkNvbmRpdGlvbnMgTm90QmVmb3JlPSIyMDE0LTExLTA3VDIxOjQ5OjU2Ljg3N1oiIE5vdE9uT3JBZnRlcj0iMjA0NC0xMS0wN1QyMTo0OTo1Ni44NzdaIj48L3NhbWw6Q29uZGl0aW9ucz48c2FtbDpBZHZpY2U+PC9zYW1sOkFkdmljZT48c2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PHNhbWw6U3ViamVjdD48c2FtbDpOYW1lSWRlbnRpZmllcj4xQzA4MTc1OEVFNzAwMDAxPC9zYW1sOk5hbWVJZGVudGlmaWVyPjwvc2FtbDpTdWJqZWN0PjxzYW1sOkF0dHJpYnV0ZSBBdHRyaWJ1dGVOYW1lPSJTQUsiIEF0dHJpYnV0ZU5hbWVzcGFjZT0iaHR0cDovL3NjaGVtYXMuaXBjb21tZXJjZS5jb20vSWRlbnRpdHkiPjxzYW1sOkF0dHJpYnV0ZVZhbHVlPjFDMDgxNzU4RUU3MDAwMDE8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgQXR0cmlidXRlTmFtZT0iU2VyaWFsIiBBdHRyaWJ1dGVOYW1lc3BhY2U9Imh0dHA6Ly9zY2hlbWFzLmlwY29tbWVyY2UuY29tL0lkZW50aXR5Ij48c2FtbDpBdHRyaWJ1dGVWYWx1ZT40OTJhNWU0Yi02NWE0LTRkOTktYjQ0MS1iMzJjOTdmODNkNzY8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgQXR0cmlidXRlTmFtZT0ibmFtZSIgQXR0cmlidXRlTmFtZXNwYWNlPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcyI+PHNhbWw6QXR0cmlidXRlVmFsdWU+MUMwODE3NThFRTcwMDAwMTwvc2FtbDpBdHRyaWJ1dGVWYWx1ZT48L3NhbWw6QXR0cmlidXRlPjwvc2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PFNpZ25hdHVyZSB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnIyI+PFNpZ25lZEluZm8+PENhbm9uaWNhbGl6YXRpb25NZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzEwL3htbC1leGMtYzE0biMiPjwvQ2Fub25pY2FsaXphdGlvbk1ldGhvZD48U2lnbmF0dXJlTWV0aG9kIEFsZ29yaXRobT0iaHR0cDovL3d3dy53My5vcmcvMjAwMC8wOS94bWxkc2lnI3JzYS1zaGExIj48L1NpZ25hdHVyZU1ldGhvZD48UmVmZXJlbmNlIFVSST0iI180NmU3ZGQwMy0yMGM3LTRiZWUtYTU3YS1kYjZhODEwOTA5ZDYiPjxUcmFuc2Zvcm1zPjxUcmFuc2Zvcm0gQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjZW52ZWxvcGVkLXNpZ25hdHVyZSI+PC9UcmFuc2Zvcm0+PFRyYW5zZm9ybSBBbGdvcml0aG09Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvMTAveG1sLWV4Yy1jMTRuIyI+PC9UcmFuc2Zvcm0+PC9UcmFuc2Zvcm1zPjxEaWdlc3RNZXRob2QgQWxnb3JpdGhtPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjc2hhMSI+PC9EaWdlc3RNZXRob2Q+PERpZ2VzdFZhbHVlPlQ2QmZhUDB2bXgwRitsT3JrRDVja0h4U2lYRT08L0RpZ2VzdFZhbHVlPjwvUmVmZXJlbmNlPjwvU2lnbmVkSW5mbz48U2lnbmF0dXJlVmFsdWU+VHBOalhUNnFMejZ5K2RYVU5yQlRQV0hqVitWbmVkTlNNNTNqdzB5N1RxK1NndEI1OEcvWjdKTEFoNUVLRTBqRERpMHRuQ3cvdmF3bGZ6TjU3VVBxeERzZVpmb1FobmJpQzVxVm5CNmZyOVFZRTlYQ0d1OG01bXhLYno2djl3QzVkVlFEMmxXenRFT0trcnZWL1kwRFVOR2drOEZpdFhmbk1rMVpvakdnNzUvaVFHYW4vUFlWaTBNZDYvc3JLZ1IzdkVsTTlUMm5GWVNkSmlrZUFvM3cweUlEZDNPbG5PL2UyNE1GTzQxdlE3d3lIZDBZUkdDZ2I1YVU4K0ZYelJRbXlyK00rU1RpQVlHT3MwcGRPVE9RNlBleGRITndFS1YzVzJkSUExaElIR2EvUmY0WWc0d0p2aTNublJHd2Z2b1h3RlZYckNsd1d4SVV4ODR2eGtDNitnPT08L1NpZ25hdHVyZVZhbHVlPjxLZXlJbmZvPjxvOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2UgeG1sbnM6bz0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzLzIwMDQvMDEvb2FzaXMtMjAwNDAxLXdzcy13c3NlY3VyaXR5LXNlY2V4dC0xLjAueHNkIj48bzpLZXlJZGVudGlmaWVyIFZhbHVlVHlwZT0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3NzL29hc2lzLXdzcy1zb2FwLW1lc3NhZ2Utc2VjdXJpdHktMS4xI1RodW1icHJpbnRTSEExIj5ZREJlRFNGM0Z4R2dmd3pSLzBwck11OTZoQ2M9PC9vOktleUlkZW50aWZpZXI+PC9vOlNlY3VyaXR5VG9rZW5SZWZlcmVuY2U+PC9LZXlJbmZvPjwvU2lnbmF0dXJlPjwvc2FtbDpBc3NlcnRpb24+"; - /* *****************************************************Authorizeandcapture P2PE******************************************** */ + /* *****************************************************Authorizeandcapture P2PE******************************************** */ try { From 878295c7edcc34a50c005b6bf74460eae6310ae4 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Wed, 22 Apr 2015 15:44:27 +0530 Subject: [PATCH 07/11] update readme.md --- README.md | 622 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 404 insertions(+), 218 deletions(-) diff --git a/README.md b/README.md index 6b0c448..6323385 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,7 @@ $identitytoken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPS $applicationprofileid = 14644; $merchantprofileid = "PrestaShop Global HC"; $workflowid = 2317000001; -$isTestAccount = true; - -Note: track1data and track2data optional. +$isTestAccount = true; try { $velocityProcessor = new Velocity_Processor($applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken); @@ -128,43 +126,54 @@ Below is an example of an authorize and capture with each of the different types #### Authorize and capture with token Method: try { + $response = $velocityProcessor->authorizeAndCapture( array( - 'amount' => 10.03, - 'avsdata' => array( 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' ), 'token' => $paymentAccountDataToken, 'order_id' => '629203', - 'entry_mode' => '˜Keyed', + 'entry_mode' => 'Keyed', 'IndustryType' =>'Ecommerce', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' + 'Reference' => 'xyz', + 'EmployeeId' => '11' ) ); + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'AuthorizeAndCapture Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } + $authCapTransactionid = $response['TransactionId']; } catch(Exception $e) { echo $e->getMessage(); } +``` -Note: $paymentAccountDataToken is get from verify response. - +#### Authorize and capture with keyed data -#### Authorize and capture without token Method: - - try { +``` +try { $response = $velocityProcessor->authorizeAndCapture( array( - 'amount' => 10.03, - 'avsdata' => array( 'Street' => 'xyz', + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', 'City' => 'cityname', 'StateProvince' => 'statecode', 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), + 'Country' => 'countrycode three letter' + ), 'carddata' => array( 'cardowner' => 'Jane Doe', 'cardtype' => 'Visa', @@ -174,46 +183,72 @@ Note: $paymentAccountDataToken is get from verify response. 'track1data' => '', 'track2data' => '' ), 'order_id' => '629203', - 'entry_mode' => '˜Keyed', + 'entry_mode' => 'Keyed', 'IndustryType' =>'Ecommerce', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' + 'Reference' => 'xyz', + 'EmployeeId' => '11' ) ); - $authCapTransactionid = $response['TransactionId']; + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'AuthorizeAndCapture Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } + + $authCapTransactionid = $response['TransactionId']; } catch(Exception $e) { echo $e->getMessage(); } +``` - OR +### Authorize and capture with swiped data - try { +``` + + try { $response = $velocityProcessor->authorizeAndCapture( array( - 'amount' => 10.03, - 'avsdata' => array( 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'carddata' => array( 'cardowner' => 'Jane Doe', - 'cardtype' => 'Visa', - 'pan' => '', - 'expire' => '', - 'cvv' => '' - 'track1data' => track1data, - 'track2data' => '˜' ), - 'order_id' => '629203', - 'entry_mode' => '˜TrackDataFromMSR', - 'IndustryType' =>'Retail', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' - ) - ); + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '%B4012000033330026^NAJEER/SHAIK ^0904101100001100000000123456780?', + 'track2data' => '' + ), + 'order_id' => '629203', + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + ) + ); - $authCapTransactionid = $response['TransactionId']; + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'AuthorizeAndCapture Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } + + $authCapTransactionid = $response['TransactionId']; } catch(Exception $e) { echo $e->getMessage(); @@ -235,26 +270,88 @@ Note: $paymentAccountDataToken is get from verify response. 'pan' => '', 'expire' => '', 'cvv' => '' - 'track1data' => '˜', - 'track2data' => track2data, + 'track1data' => '', + 'track2data' => '4012000033330026=09041011000012345678', ), 'order_id' => '629203', - 'entry_mode' => '˜TrackDataFromMSR', + 'entry_mode' => 'TrackDataFromMSR', 'IndustryType' =>'Retail', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' + 'Reference' => 'xyz', + 'EmployeeId' => '11' ) ); - $authCapTransactionid = $response['TransactionId']; + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'AuthorizeAndCapture Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } + + $authCapTransactionid = $response['TransactionId']; } catch(Exception $e) { echo $e->getMessage(); } +``` + +### Authorize and capture with encrypted data + +Before doing the actualy transaction, you must re-instantiate your processor with the proper workflow id (provided by your velocity representative): + +``` + $workflowid = 'BBBAAA0001'; + try { + $velocityProcessor = new VelocityProcessor( $applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken ); + } catch (Exception $e) { + echo $e->getMessage(); + } +``` -##### Authorize method with Token: - - try { +Then you can perform the transaction: + +``` + try{ + $response = $velocityProcessor->authorizeAndCapture( array( + 'amount' => $cash, + 'p2pedata' => array( + 'SecurePaymentAccountData' => $SecurePaymentAccountData, + 'EncryptionKeyId' => $EncryptionKeyId + ), + 'order_id' => '629203' + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'AuthorizeAndCapture Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } + + $authCapTransactionid = $response['TransactionId']; + } catch (Exception $ex) { + echo $e->getMessage(); + } +``` + +The rest of the payment methods can be found below: + +#### Authorize method with Token + +``` +try { $response = $velocityProcessor->authorize( array( 'amount' => 10, @@ -266,111 +363,102 @@ Note: $paymentAccountDataToken is get from verify response. ), 'token' => $paymentAccountDataToken, 'order_id' => '629203' - 'entry_mode' => '˜Keyed', + 'entry_mode' => 'Keyed', 'IndustryType' =>'Ecommerce', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); - $authTransactionid = $response['TransactionId']; + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Authorize Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } } catch (Exception $e) { echo $e->getMessage(); die; - } + } + +``` +#### Authorize with keyed data -##### Authorize method without Token: - - try { - - $response = $velocityProcessor->authorize( array( - 'amount' => 10, - 'avsdata' => array( 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'carddata' => array( 'cardowner' => 'Jane Doe', - 'cardtype' => 'Visa', - 'pan' => '4012888812348882', - 'expire' => '1215', - 'cvv' => '123' - 'track1data' => '', - 'track2data' => '˜' ), - 'order_id' => '629203' - 'entry_mode' => '˜Keyed', - 'IndustryType' =>'Ecommerce', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' - ) ); - - $authTransactionid = $response['TransactionId']; +``` +try { + $response = $velocityProcessor->authorize( array( + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( + 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '4012888812348882', + 'expire' => '1215', + 'cvv' => '123' + 'track1data' => '', + 'track2data' => '' + ), + 'order_id' => '629203', + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + ) + ); - } catch (Exception $e) { - echo $e->getMessage(); die; - } - - OR - - try { + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Authorize Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } - $response = $velocityProcessor->authorize( array( - 'amount' => 10, - 'avsdata' => array( 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'carddata' => array( 'cardowner' => 'Jane Doe', - 'cardtype' => 'Visa', - 'pan' => '', - 'expire' => '', - 'cvv' => '' - 'track1data' => track1data, - 'track2data' => '˜' - ), - 'order_id' => '629203' - 'entry_mode' => '˜TrackDataFromMSR', - 'IndustryType' =>'Retail', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' - )); - - $authTransactionid = $response['TransactionId']; + $authTransactionid = $response['TransactionId']; - } catch (Exception $e) { - echo $e->getMessage(); die; - } + } catch(Exception $e) { + echo $e->getMessage(); + } +``` -OR +### Authorize with swiped data - try { +``` - $response = $velocityProcessor->authorize( array( - 'amount' => 10, - 'avsdata' => array( 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' + try { + $response = $velocityProcessor->authorize( array( + 'amount' => 10.03, + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' ), - 'carddata' => array( 'cardowner' => 'Jane Doe', - 'cardtype' => 'Visa', - 'pan' => '', - 'expire' => '', - 'cvv' => '' - 'track1data' => '˜', - 'track2data' => track2data - ), - 'order_id' => '629203' - 'entry_mode' => '˜TrackDataFromMSR', - 'IndustryType' =>'Retail', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' - )); - - $authTransactionid = $response['TransactionId']; + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => '%B4012000033330026^NAJEER/SHAIK ^0904101100001100000000123456780?', + 'track2data' => '' ), + 'order_id' => '629203', + 'entry_mode' => 'TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + ) + ); } catch (Exception $e) { echo $e->getMessage(); die; @@ -440,6 +528,7 @@ OR ) ); + if (isset($response['Status']) && $response['Status'] == 'Successful') { echo 'Authorize Successful!
'; echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; @@ -583,24 +672,78 @@ try { $adjusttxnid = $response['TransactionId']; + $captxnid = $response['TransactionId']; + +} catch(Exception $e) { + echo $e->getMessage(); +} +#### Undo (Void/Reversal) - -##### ReturnById method: - - try { - $response = $velocityProcessor->returnById( array( - 'amount' => 5.03, - 'TransactionId' => $authCapTransactionid - ) - ); +try { - } catch (Exception $e) { - echo $e->getMessage(); + $response = $velocityProcessor->undo(array( + 'TransactionId' => $adjusttxnid + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Undo Successful!
'; + echo 'TransactionId: ' . $response['TransactionId'] . '

'; + } else { + // some error + print_r($response); } + +} catch (Exception $e) { + echo $e->getMessage(); +} + +#### Adjust +try { + + $response = $velocityProcessor->adjust(array( + 'amount' => 3.01, + 'TransactionId' => $captxnid + )); + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Adjust Successful!
'; + echo 'Amount: ' . $response['Amount'] . '

'; + $adjusttxnid = $response['TransactionId']; + } else { + // some error + print_r($response); + } + +} catch (Exception $e) { + echo $e->getMessage(); +} + + +#### ReturnById + +try { + $response = $velocityProcessor->returnById(array( + 'amount' => 5.03, + 'TransactionId' => $authCapTransactionid + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnById Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } + +} catch (Exception $e) { + echo $e->getMessage(); +} + +#### ReturnUnlinked with token: + try { $response = $velocityProcessor->returnUnlinked(array( @@ -624,10 +767,10 @@ try { } catch (Exception $e) { echo $e->getMessage(); } -``` + #### ReturnUnlinked with keyed data -``` + try { $response = $velocityProcessor->returnUnlinked( array( 'amount' => 1.03, @@ -657,12 +800,10 @@ try { } catch(Exception $e) { echo $e->getMessage(); } -``` + ### ReturnUnlinked with swiped data -``` - try { $response = $velocityProcessor->returnUnlinked( array( 'amount' => 1.03, @@ -696,9 +837,9 @@ try { OR + try { $response = $velocityProcessor->returnUnlinked( array( - 'amount' => 1.03, 'carddata' => array( 'cardowner' => 'Jane Doe', 'cardtype' => 'Visa', @@ -714,7 +855,6 @@ try { 'Reference' => 'xyz', 'EmployeeId' => '11' )); - $response = $velocityProcessor->verify(array( 'avsdata' => array( @@ -743,61 +883,107 @@ try { } -For below all credential provided by velocity gateway. -$SecurePaymentAccountData -$EncryptionKeyId + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } + + } catch(Exception $e) { + echo $e->getMessage(); + } -##### P2PE for Authorize: +### ReturnUnlinked with encrypted data - try{ - $response = $velocityProcessor->authorize( - array( - 'amount' => $cash, - 'p2pedata' => array( - 'SecurePaymentAccountData' => $SecurePaymentAccountData, - 'EncryptionKeyId' => $EncryptionKeyId - ), - 'order_id' => '629203' - 'entry_mode' => '˜Keyed', - 'IndustryType' =>'Ecommerce', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' - ) -); - } catch (Exception $ex) { - echo $e->getMessage(); -} +Before doing the actualy transaction, you must re-instantiate your processor with the proper workflow id (provided by your velocity representative): -#### P2PE for AuthorizeandCapture: + $workflowid = 'BBBAAA0001'; + try { + $velocityProcessor = new VelocityProcessor( $applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken ); + } catch (Exception $e) { + echo $e->getMessage(); + } - try{ - $response = $velocityProcessor->authorizeAndCapture( - array( - 'amount' => $cash, - 'p2pedata' => array( + +Then you can perform the transaction: + + try{ + $response = $velocityProcessor->returnUnlinked ( array( + 'amount' => $cash, + 'p2pedata' => array( 'SecurePaymentAccountData' => $SecurePaymentAccountData, 'EncryptionKeyId' => $EncryptionKeyId ), 'order_id' => '629203' - 'entry_mode' => '˜Keyed', + 'entry_mode' => 'Keyed', 'IndustryType' =>'Ecommerce', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } } catch (Exception $ex) { echo $e->getMessage(); } + +#### Verify with keyed data + try { + $response = $velocityProcessor->verify(array( + 'avsdata' => array( + 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( + 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '4012888812348882', + 'expire' => '1215', + 'cvv' => '123' + 'track1data' => '', + 'track2data' => '' + ), + 'order_id' => '629203' + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); -##### P2PE for ReturnUnlinked: + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Verify Successful!
'; + echo 'PostalCodeResult: ' . $response['AVSResult']['PostalCodeResult'] . '
'; + echo 'CVResult: ' . $response['CVResult']; + } else { + // some error + print_r($response); + } - try{ - $response = $velocityProcessor->returnUnlinked ( array( - 'amount' => $cash, - 'p2pedata' => array( - 'SecurePaymentAccountData' => $SecurePaymentAccountData, - 'EncryptionKeyId' => $EncryptionKeyId + } catch(Exception $e) { + echo $e->getMessage(); + } + + +### Verify with swiped data + + try { + $response = $velocityProcessor->verify( array( + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' ), 'order_id' => '629203' 'entry_mode' => '˜Keyed', @@ -819,24 +1005,22 @@ $EncryptionKeyId } catch(Exception $e) { echo $e->getMessage(); } -``` ### ReturnUnlinked with encrypted data Before doing the actualy transaction, you must re-instantiate your processor with the proper workflow id (provided by your velocity representative): -``` + $workflowid = 'BBBAAA0001'; try { $velocityProcessor = new VelocityProcessor( $applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken ); } catch (Exception $e) { echo $e->getMessage(); } -``` -Then you can perform the transaction: -``` +Then you can perform the transaction: + try{ $response = $velocityProcessor->returnUnlinked ( array( 'amount' => $cash, @@ -863,7 +1047,7 @@ Then you can perform the transaction: } #### Verify with keyed data -``` + try { $response = $velocityProcessor->verify(array( 'avsdata' => array( @@ -901,11 +1085,11 @@ Then you can perform the transaction: } catch(Exception $e) { echo $e->getMessage(); } -``` + #### Verify with swiped data -``` + try { $response = $velocityProcessor->verify( array( @@ -970,6 +1154,7 @@ Then you can perform the transaction: 'EmployeeId' => '11' )); + if (isset($response['Status']) && $response['Status'] == 'Successful') { echo 'Verify Successful!
'; echo 'PostalCodeResult: ' . $response['AVSResult']['PostalCodeResult'] . '
'; @@ -982,20 +1167,22 @@ Then you can perform the transaction: } catch(Exception $e) { echo $e->getMessage(); } -``` - + + #### CaptureAll Method: -``` + try{ $velocityProcessor->captureAll(); } catch (Exception $ex) { echo $e->getMessage(); } -``` + + #### QueryTransactionDetail Method: + ``` try { $response = $VelocityProcessor->queryTransactionsDetail(array( @@ -1033,4 +1220,3 @@ Then you can perform the transaction: } catch(Exception $e) { echo $e->getMessage(); } - From 103f01ebc52580372279ff73bff58e941f147148 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Mon, 24 Aug 2015 21:58:45 +0530 Subject: [PATCH 08/11] sdk curl header issue has been fixed. --- sdk/Velocity/Connection.php | 311 +++++++++++---------- sdk/Velocity/Processor.php | 526 ++++++++++++++++++------------------ sdk/Velocity/XmlCreator.php | 2 - sdk/Velocity/XmlParser.php | 134 ++++----- velocityClients.php | 31 ++- 5 files changed, 501 insertions(+), 503 deletions(-) diff --git a/sdk/Velocity/Connection.php b/sdk/Velocity/Connection.php index a8d8ac1..f0f9953 100644 --- a/sdk/Velocity/Connection.php +++ b/sdk/Velocity/Connection.php @@ -1,5 +1,4 @@ request('GET', $path, $data) gateway response for both success or failure. */ public function get($path, $data = array()) { - if (isset($path) && isset($data)) { - return $this->request('GET', $path, $data); - } else { - throw new Exception(VelocityMessage::$descriptions['errgetmethod']); - } + if (isset($path) && isset($data)) { + return $this->request('GET', $path, $data); + } else { + throw new Exception(VelocityMessage::$descriptions['errgetmethod']); + } } /* @@ -41,11 +40,11 @@ public function get($path, $data = array()) { * @return array $this->request('POST', $path, $data) gateway response for both success or failure. */ public function post($path, $data = array()) { - if (isset($path) && isset($data)) { - return $this->request('POST', $path, $data); - } else { - throw new Exception(VelocityMessage::$descriptions['errpostmethod']); - } + if (isset($path) && isset($data)) { + return $this->request('POST', $path, $data); + } else { + throw new Exception(VelocityMessage::$descriptions['errpostmethod']); + } } /* @@ -56,11 +55,11 @@ public function post($path, $data = array()) { * @return array $this->request('PUT', $path, $data) gateway response for both success or failure. */ public function put($path, $data = array()) { - if (isset($path) && isset($data)) { - return $this->request('PUT', $path, $data); - } else { - throw new Exception(VelocityMessage::$descriptions['errputmethod']); - } + if (isset($path) && isset($data)) { + return $this->request('PUT', $path, $data); + } else { + throw new Exception(VelocityMessage::$descriptions['errputmethod']); + } } /* @@ -68,24 +67,24 @@ public function put($path, $data = array()) { * @return array $this->handleResponse($error, $response) array of successfull or failure of gateway response. */ public function signOn() { - try { - - list($error, $response) = $this->get('SvcInfo/token', - array( - 'sessiontoken' => VelocityProcessor::$identitytoken, - 'xml' => '', - 'method' => 'SignOn' - ) - ); - if ( $error == NULL && $response != '' ) - - return $response; - else - throw new Exception( VelocityMessage::$descriptions['errsignon'] ); - } catch (Exception $e) { - throw new Exception( $e->getMessage() ); - } + try { + + list($error, $response) = $this->get('SvcInfo/token', + array( + 'sessiontoken' => VelocityProcessor::$identitytoken, + 'xml' => '', + 'method' => 'SignOn' + ) + ); + + if ( $error == NULL && $response != '' ) + return $response; + else + throw new Exception( VelocityMessage::$descriptions['errsignon'] ); + } catch (Exception $e) { + throw new Exception( $e->getMessage() ); + } } /* @@ -99,128 +98,128 @@ public function signOn() { */ private function request($method, $path, $data = array()) { - if (isset($data['sessiontoken']) && isset($path)) { - $body = $data['xml']; - $session_token = $data['sessiontoken']; - $rest_action = $method; - if ( VelocityProcessor::$isTestAccount ) { - $api_url = VelocityConfig::$baseurl_test . $path; - } else { - $api_url = VelocityConfig::$baseurl_live . $path; - } - $timeout = 60; - } else { - throw new Exception(VelocityMessage::$descriptions['errsessionxmlnotset']); - } + if (isset($data['sessiontoken']) && isset($path)) { + $body = $data['xml']; + $session_token = $data['sessiontoken']; + $rest_action = $method; + if ( VelocityProcessor::$isTestAccount ) { + $api_url = VelocityConfig::$baseurl_test . $path; + } else { + $api_url = VelocityConfig::$baseurl_live . $path; + } + $timeout = 60; + } else { + throw new Exception(VelocityMessage::$descriptions['errsessionxmlnotset']); + } - $user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; - - // Parse the full api_url for required pieces. - $strpos = strpos($api_url, '/', 8); // 8 denotes look after https:// - $host = mb_substr($api_url, 8, $strpos-8); + $user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $api_url); // set url to post to - curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return variable - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // connection timeout - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); - - if ($rest_action == 'POST') - curl_setopt($ch, CURLOPT_POST, true); - elseif ($rest_action == 'GET') - curl_setopt($ch, CURLOPT_HTTPGET, true); - elseif ($rest_action == 'PUT') - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); - elseif ($rest_action == 'DELETE') - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); - - // Header setup - $header[] = 'Authorization: Basic '. base64_encode($session_token.':'); - - if($data['method'] == 'SignOn' || $data['method'] == 'querytransactionsdetail') - $header[] = 'Content-Type: application/json'; - else - $header[] = 'Content-Type: application/xml'; - - $header[] = 'Accept: '; // Known issue: defining this causes server to reply with no content. - $header[] = 'Expect: 100-continue'; - $header[] = 'Host: '.$host; - - curl_setopt($ch, CURLOPT_HTTPHEADER, $header); - - //The following 3 will retrieve the header with the response. Remove if you do not want the response to contain the header. - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - //curl_setopt($ch, CURLOPT_VERBOSE, 1); // Will output network information to the Console - curl_setopt($ch, CURLOPT_HEADER, 1); - - if ($rest_action != 'GET') - curl_setopt($ch, CURLOPT_POSTFIELDS, $body); - - if ($rest_action == 'DELETE') - $expected_response = "204"; - elseif (($rest_action == 'POST') and (strpos($api_url, 'transactionsSummary') == true)) - $expected_response = "200"; - elseif (($rest_action == 'POST') and (strpos($api_url, 'transactionsFamily') == true)) - $expected_response = "200"; - elseif (($rest_action == 'POST') and (strpos($api_url, 'transactionsDetail') == true)) - $expected_response = "200"; - elseif ($rest_action == 'POST') - $expected_response = "201"; - else - $expected_response = "200"; - - try { - - $res = curl_exec($ch); + // Parse the full api_url for required pieces. + $strpos = strpos($api_url, '/', 8); // 8 denotes look after https:// + $host = mb_substr($api_url, 8, $strpos-8); - list($header, $body) = explode("\r\n\r\n", $res, 2); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $api_url); // set url to post to + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return variable + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // connection timeout + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); - $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - curl_close($ch); - } catch (Exception $ex) { - curl_close($ch); - echo $ex->getMessage(); - } - - if ( $statusCode == 5000 ) { // regenrate the sessiontoken if expired. - - $data['sessiontoken'] = $this->signOn(); - $this->request($method, $path, $data); - - } else { - $error = self::errorFromStatus($statusCode); // call exception classes according to error code. - } - - $match = null; - preg_match('/Content-Type: ([^;]*);/i', $body, $match); - $contentType; - if (isset($match[1])) { - $contentType = $match[1]; - } else { - preg_match('/Content-Type: ([^;]*);/i', $header, $match); - $contentType = $match[1]; - } - - if($data['method'] == 'querytransactionsdetail'){ - $res = explode('Path=/', $body); - $body = $res[1]; - if($res[1] == '') - $body = $res[0]; - } - // Parse response, depending on value of the Content-Type header. - $response = null; - if (preg_match('/json/', $contentType)) { - $response = json_decode($body, true); - } elseif (preg_match('/xml/', $contentType)) { - $arr = explode('Path=/', $body); - if(isset($arr[1])) - $response = VelocityXmlParser::parse($arr[1]); - else - $response = VelocityXmlParser::parse($body); - } + if ($rest_action == 'POST') + curl_setopt($ch, CURLOPT_POST, true); + elseif ($rest_action == 'GET') + curl_setopt($ch, CURLOPT_HTTPGET, true); + elseif ($rest_action == 'PUT') + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); + elseif ($rest_action == 'DELETE') + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); + + // Header setup + $header[] = 'Authorization: Basic '. base64_encode($session_token.':'); + + if($data['method'] == 'SignOn' || $data['method'] == 'querytransactionsdetail') + $header[] = 'Content-Type: application/json'; + else + $header[] = 'Content-Type: application/xml'; + + $header[] = 'Accept: '; // Known issue: defining this causes server to reply with no content. + $header[] = 'Expect: 100-continue'; + $header[] = 'Host: '.$host; + + curl_setopt($ch, CURLOPT_HTTPHEADER, $header); + //The following 3 will retrieve the header with the response. Remove if you do not want the response to contain the header. + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + //curl_setopt($ch, CURLOPT_VERBOSE, 1); // Will output network information to the Console + curl_setopt($ch, CURLOPT_HEADER, 1); + + if ($rest_action != 'GET') + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); + + if ($rest_action == 'DELETE') + $expected_response = "204"; + elseif (($rest_action == 'POST') and (strpos($api_url, 'transactionsSummary') == true)) + $expected_response = "200"; + elseif (($rest_action == 'POST') and (strpos($api_url, 'transactionsFamily') == true)) + $expected_response = "200"; + elseif (($rest_action == 'POST') and (strpos($api_url, 'transactionsDetail') == true)) + $expected_response = "200"; + elseif ($rest_action == 'POST') + $expected_response = "201"; + else + $expected_response = "200"; + + try { + + $res = curl_exec($ch); + list($header, $body) = explode("\r\n\r\n", $res, 2); + if (strpos($header,"100 Continue") !== false) { + list($header, $body) = explode("\r\n\r\n", $body, 2); + } + $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + } catch (Exception $ex) { + curl_close($ch); + throw new Exception($ex->getMessage()); + } + + if ( $statusCode == 5000 ) { // regenrate the sessiontoken if expired. + + $data['sessiontoken'] = $this->signOn(); + $this->request($method, $path, $data); + + } else { + $error = self::errorFromStatus($statusCode); // call exception classes according to error code. + } + + $match = null; + preg_match('/Content-Type: ([^;]*);/i', $body, $match); + $contentType; + if (isset($match[1])) { + $contentType = $match[1]; + } else { + preg_match('/Content-Type: ([^;]*);/i', $header, $match); + $contentType = $match[1]; + } + + if($data['method'] == 'querytransactionsdetail'){ + $res = explode('Path=/', $body); + $body = $res[1]; + if($res[1] == '') + $body = $res[0]; + } + // Parse response, depending on value of the Content-Type header. + $response = null; + if (preg_match('/json/', $contentType)) { + $response = json_decode($body, true); + } elseif (preg_match('/xml/', $contentType)) { + $arr = explode('Path=/', $body); + if(isset($arr[1])) + $response = VelocityXmlParser::parse($arr[1]); + else + $response = VelocityXmlParser::parse($body); + } - return array($error, $response); + return array($error, $response); } @@ -292,7 +291,7 @@ private static function errorFromStatus($status) { return new VelocityServiceUnavailableError(); case '504': return new VelocityGatewayTimeoutError(); - case '5005': + case '5005': return new VelocityInvalidTokenFault(); case '9999': return new VelocityCWSTransactionServiceUnavailableFault(); @@ -301,4 +300,4 @@ private static function errorFromStatus($status) { } } -} +} \ No newline at end of file diff --git a/sdk/Velocity/Processor.php b/sdk/Velocity/Processor.php index 21c5a1e..b45b0ee 100644 --- a/sdk/Velocity/Processor.php +++ b/sdk/Velocity/Processor.php @@ -21,17 +21,17 @@ class VelocityProcessor private $includeRelated = false; public function __construct($applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken = null, $sessiontoken = null ) { - $this->connection = VelocityConnection::instance(); // VelocityConnection class object store in private data member $connection. - self::$identitytoken = $identitytoken; - self::$applicationprofileid = $applicationprofileid; - self::$merchantprofileid = $merchantprofileid; - self::$workflowid = $workflowid; - self::$isTestAccount = $isTestAccount; - if(empty($sessiontoken) && !empty($identitytoken)){ - $this->sessionToken = $this->connection->signOn(); - } else { - $this->sessionToken = $sessiontoken; - } + $this->connection = VelocityConnection::instance(); // VelocityConnection class object store in private data member $connection. + self::$identitytoken = $identitytoken; + self::$applicationprofileid = $applicationprofileid; + self::$merchantprofileid = $merchantprofileid; + self::$workflowid = $workflowid; + self::$isTestAccount = $isTestAccount; + if(empty($sessiontoken) && !empty($identitytoken)){ + $this->sessionToken = $this->connection->signOn(); + } else { + $this->sessionToken = $sessiontoken; + } } @@ -47,29 +47,29 @@ public function __construct($applicationprofileid, $merchantprofileid, $workflow public function verify($options = array()) { - try { - - $xml = VelocityXmlCreator::verifyXML($options); // got Verify xml object. - $xml->formatOutput = TRUE; - $body = $xml->saveXML(); - //echo ''.$body.''; die; - list($error, $response) = $this->connection->post( - $this->path( - self::$workflowid, - self::$Txn_method[0], - self::$Txn_method[0] - ), - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[0] - ) - ); - return $this->handleResponse($error, $response); - //return $response; - } catch (Exception $e) { - throw new Exception( $e->getMessage() ); - } + try { + + $xml = VelocityXmlCreator::verifyXML($options); // got Verify xml object. + $xml->formatOutput = TRUE; + $body = $xml->saveXML(); + //echo ''.$body.''; die; + list($error, $response) = $this->connection->post( + $this->path( + self::$workflowid, + self::$Txn_method[0], + self::$Txn_method[0] + ), + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[0] + ) + ); + return $this->handleResponse($error, $response); + //return $response; + } catch (Exception $e) { + throw new Exception( $e->getMessage() ); + } } @@ -81,29 +81,29 @@ public function verify($options = array()) { */ public function authorizeAndCapture($options = array()) { - try { - - $xml = VelocityXmlCreator::authorizeandcaptureXML($options); // got authorizeandcapture xml object. - $xml->formatOutput = TRUE; - $body = $xml->saveXML(); - //echo ''.$body.''; - list($error, $response) = $this->connection->post( - $this->path( - self::$workflowid, - null, - self::$Txn_method[2] - ), - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[2] - ) - ); - return $this->handleResponse($error, $response); - //return $response; - } catch(Exception $e) { - throw new Exception($e->getMessage()); - } + try { + + $xml = VelocityXmlCreator::authorizeandcaptureXML($options); // got authorizeandcapture xml object. + $xml->formatOutput = TRUE; + $body = $xml->saveXML(); + //echo ''.$body.''; die; + list($error, $response) = $this->connection->post( + $this->path( + self::$workflowid, + null, + self::$Txn_method[2] + ), + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[2] + ) + ); + return $this->handleResponse($error, $response); + //return $response; + } catch(Exception $e) { + throw new Exception($e->getMessage()); + } } @@ -117,28 +117,28 @@ public function authorizeAndCapture($options = array()) { public function authorize($options = array()) { - try { - $xml = VelocityXmlCreator::authorizeXML($options); // got authorize xml object. - $xml->formatOutput = TRUE; - $body = $xml->saveXML(); - //echo ''.$body.''; - list($error, $response) = $this->connection->post( - $this->path( - self::$workflowid, - null, - self::$Txn_method[1] - ), - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[1] - ) - ); - return $this->handleResponse($error, $response); - //return $response; - } catch (Exception $e) { - throw new Exception( $e->getMessage() ); - } + try { + $xml = VelocityXmlCreator::authorizeXML($options); // got authorize xml object. + $xml->formatOutput = TRUE; + $body = $xml->saveXML(); + //echo ''.$body.''; + list($error, $response) = $this->connection->post( + $this->path( + self::$workflowid, + null, + self::$Txn_method[1] + ), + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[1] + ) + ); + return $this->handleResponse($error, $response); + //return $response; + } catch (Exception $e) { + throw new Exception( $e->getMessage() ); + } } @@ -150,34 +150,34 @@ public function authorize($options = array()) { */ public function capture($options = array()) { - if(isset($options['amount']) && isset($options['TransactionId'])) { - $amount = number_format($options['amount'], 2, '.', ''); - try { - $xml = VelocityXmlCreator::captureXML($options['TransactionId'], $amount); // got capture xml object. - $xml->formatOutput = TRUE; - $body = $xml->saveXML(); - //echo ''.$body.''; die; - list($error, $response) = $this->connection->put( - $this->path( - self::$workflowid, - $options['TransactionId'], - self::$Txn_method[3] - ), - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[3] - ) - ); - //return $response; - return $this->handleResponse($error, $response); - } catch(Exception $e) { - throw new Exception($e->getMessage()); - } - - } else { - throw new Exception(VelocityMessage::$descriptions['errcapsesswfltransid']); - } + if(isset($options['amount']) && isset($options['TransactionId'])) { + $amount = number_format($options['amount'], 2, '.', ''); + try { + $xml = VelocityXmlCreator::captureXML($options['TransactionId'], $amount); // got capture xml object. + $xml->formatOutput = TRUE; + $body = $xml->saveXML(); + //echo ''.$body.''; die; + list($error, $response) = $this->connection->put( + $this->path( + self::$workflowid, + $options['TransactionId'], + self::$Txn_method[3] + ), + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[3] + ) + ); + //return $response; + return $this->handleResponse($error, $response); + } catch(Exception $e) { + throw new Exception($e->getMessage()); + } + + } else { + throw new Exception(VelocityMessage::$descriptions['errcapsesswfltransid']); + } } /* @@ -217,34 +217,34 @@ public function captureAll($options = array()) { */ public function adjust($options = array()) { - if( isset($options['amount']) && isset($options['TransactionId']) ) { - $amount = number_format($options['amount'], 2, '.', ''); - try { - $xml = VelocityXmlCreator::adjustXML($options['TransactionId'], $amount); // got adjust xml object. - $xml->formatOutput = TRUE; - $body = $xml->saveXML(); - //echo ''.$body.''; die; - list($error, $response) = $this->connection->put( - $this->path( - self::$workflowid, - $options['TransactionId'], - self::$Txn_method[4] - ), - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[4] - ) - ); - return $this->handleResponse($error, $response); - //return $response; - } catch (Exception $e) { - throw new Exception($e->getMessage()); - } - - } else { - throw new Exception(VelocityMessage::$descriptions['erradjustsesswfltransid']); - } + if( isset($options['amount']) && isset($options['TransactionId']) ) { + $amount = number_format($options['amount'], 2, '.', ''); + try { + $xml = VelocityXmlCreator::adjustXML($options['TransactionId'], $amount); // got adjust xml object. + $xml->formatOutput = TRUE; + $body = $xml->saveXML(); + //echo ''.$body.''; die; + list($error, $response) = $this->connection->put( + $this->path( + self::$workflowid, + $options['TransactionId'], + self::$Txn_method[4] + ), + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[4] + ) + ); + return $this->handleResponse($error, $response); + //return $response; + } catch (Exception $e) { + throw new Exception($e->getMessage()); + } + + } else { + throw new Exception(VelocityMessage::$descriptions['erradjustsesswfltransid']); + } } /* @@ -255,33 +255,33 @@ public function adjust($options = array()) { */ public function undo($options = array()) { - if ( isset($options['TransactionId']) ) { - - try { - $xml = VelocityXmlCreator::undoXML($options['TransactionId']); // got undo xml object. - $xml->formatOutput = TRUE; - $body = $xml->saveXML(); - list($error, $response) = $this->connection->put( - $this->path( - self::$workflowid, - $options['TransactionId'], - self::$Txn_method[5] - ), - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[5] - ) - ); - //return $response; - return $this->handleResponse($error, $response); - } catch (Exception $e) { - throw new Exception($e->getMessage()); - } - - } else { - throw new Exception(VelocityMessage::$descriptions['errundosesswfltransid']); - } + if ( isset($options['TransactionId']) ) { + + try { + $xml = VelocityXmlCreator::undoXML($options['TransactionId']); // got undo xml object. + $xml->formatOutput = TRUE; + $body = $xml->saveXML(); + list($error, $response) = $this->connection->put( + $this->path( + self::$workflowid, + $options['TransactionId'], + self::$Txn_method[5] + ), + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[5] + ) + ); + //return $response; + return $this->handleResponse($error, $response); + } catch (Exception $e) { + throw new Exception($e->getMessage()); + } + + } else { + throw new Exception(VelocityMessage::$descriptions['errundosesswfltransid']); + } } @@ -293,34 +293,34 @@ public function undo($options = array()) { */ public function returnById($options = array()) { - if(isset($options['amount']) && isset($options['TransactionId'])) { - $amount = number_format($options['amount'], 2, '.', ''); - try { - $xml = VelocityXmlCreator::returnByIdXML($amount, $options['TransactionId']); // got ReturnById xml object. - $xml->formatOutput = TRUE; - $body = $xml->saveXML(); - //echo ''.$body.''; die; - list($error, $response) = $this->connection->post( - $this->path( - self::$workflowid, - null, - self::$Txn_method[6] - ), - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[6] - ) - ); - return $this->handleResponse($error, $response); - //return $response; - } catch (Exception $e) { - throw new Exception($e->getMessage()); - } - - } else { - throw new Exception(VelocityMessage::$descriptions['errreturntranidwid']); - } + if(isset($options['amount']) && isset($options['TransactionId'])) { + $amount = number_format($options['amount'], 2, '.', ''); + try { + $xml = VelocityXmlCreator::returnByIdXML($amount, $options['TransactionId']); // got ReturnById xml object. + $xml->formatOutput = TRUE; + $body = $xml->saveXML(); + //echo ''.$body.''; die; + list($error, $response) = $this->connection->post( + $this->path( + self::$workflowid, + null, + self::$Txn_method[6] + ), + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[6] + ) + ); + return $this->handleResponse($error, $response); + //return $response; + } catch (Exception $e) { + throw new Exception($e->getMessage()); + } + + } else { + throw new Exception(VelocityMessage::$descriptions['errreturntranidwid']); + } } @@ -332,28 +332,28 @@ public function returnById($options = array()) { */ public function returnUnlinked($options = array()) { - try { - $xml = VelocityXmlCreator::returnUnlinkedXML($options); // got ReturnById xml object. - $xml->formatOutput = TRUE; - $body = $xml->saveXML(); - //echo ''.$body.''; - list($error, $response) = $this->connection->post( - $this->path( - self::$workflowid, - null, - self::$Txn_method[7] - ), - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[7] - ) - ); - return $this->handleResponse($error, $response); - //return $response; - } catch (Exception $e) { - throw new Exception($e->getMessage()); - } + try { + $xml = VelocityXmlCreator::returnUnlinkedXML($options); // got ReturnById xml object. + $xml->formatOutput = TRUE; + $body = $xml->saveXML(); + //echo ''.$body.''; die; + list($error, $response) = $this->connection->post( + $this->path( + self::$workflowid, + null, + self::$Txn_method[7] + ), + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[7] + ) + ); + return $this->handleResponse($error, $response); + //return $response; + } catch (Exception $e) { + throw new Exception($e->getMessage()); + } } @@ -365,25 +365,25 @@ public function returnUnlinked($options = array()) { */ public function queryTransactionsDetail($guerytxndetail) { - try { + try { - $Qtxnparams = new QueryTransactionsParameters($guerytxndetail['querytransactionparam']); - $pagingParameters = new PagingParameters($guerytxndetail['PagingParameters']); - $qtd = new QueryTransactionsDetail($this->includeRelated, $pagingParameters, $Qtxnparams, $this->transactionDetailFormat); - $body = (string)json_encode($qtd); - //echo '
'.$body.'
'; die; - list($error, $response) = $this->connection->post('DataServices/TMS/transactionsDetail', - array( - 'sessiontoken' => $this->sessionToken, - 'xml' => $body, - 'method' => self::$Txn_method[8] - ) - ); + $Qtxnparams = new QueryTransactionsParameters($guerytxndetail['querytransactionparam']); + $pagingParameters = new PagingParameters($guerytxndetail['PagingParameters']); + $qtd = new QueryTransactionsDetail($this->includeRelated, $pagingParameters, $Qtxnparams, $this->transactionDetailFormat); + $body = (string)json_encode($qtd); + //echo '
'.$body.'
'; die; + list($error, $response) = $this->connection->post('DataServices/TMS/transactionsDetail', + array( + 'sessiontoken' => $this->sessionToken, + 'xml' => $body, + 'method' => self::$Txn_method[8] + ) + ); - return $response; - } catch (Exception $e) { - throw new Exception($e->getMessage()); - } + return $response; + } catch (Exception $e) { + throw new Exception($e->getMessage()); + } } @@ -394,15 +394,15 @@ public function queryTransactionsDetail($guerytxndetail) { * @return array $this->handleResponse($error, $response) array of successfull or failure of gateway response. */ private function path($arg1, $arg2, $rtype) { - if(isset($arg1) && isset($arg2) && isset($rtype) && ( $rtype == self::$Txn_method[3] || $rtype == self::$Txn_method[4] || $rtype == self::$Txn_method[5] || $rtype == self::$Txn_method[0] ) ) { - $path = 'Txn/'.$arg1.'/'.$arg2; - return $path; - } else if(isset($arg1) && isset($rtype) && ($rtype == self::$Txn_method[2] || $rtype == self::$Txn_method[6] || $rtype == self::$Txn_method[7] || $rtype == self::$Txn_method[1]) ) { - $path = 'Txn/'.$arg1; - return $path; - } else { - throw new Exception(VelocityMessage::$descriptions['errcapadjpath']); - } + if(isset($arg1) && isset($arg2) && isset($rtype) && ( $rtype == self::$Txn_method[3] || $rtype == self::$Txn_method[4] || $rtype == self::$Txn_method[5] || $rtype == self::$Txn_method[0] ) ) { + $path = 'Txn/'.$arg1.'/'.$arg2; + return $path; + } else if(isset($arg1) && isset($rtype) && ($rtype == self::$Txn_method[2] || $rtype == self::$Txn_method[6] || $rtype == self::$Txn_method[7] || $rtype == self::$Txn_method[1]) ) { + $path = 'Txn/'.$arg1; + return $path; + } else { + throw new Exception(VelocityMessage::$descriptions['errcapadjpath']); + } } @@ -417,19 +417,19 @@ private function path($arg1, $arg2, $rtype) { */ public function handleResponse($error, $response) { - if ($error) { - return $this->processError($error, $response); - } else { - if(!empty($response)) { - if ( isset($response['BankcardTransactionResponsePro']) ) { - return $response['BankcardTransactionResponsePro']; - } else if ( isset($response['BankcardCaptureResponse']) ) { - return $response['BankcardCaptureResponse']; - } else { - return $this->processError($error, $response); - } - } - } + if ($error) { + return $this->processError($error, $response); + } else { + if(!empty($response)) { + if ( isset($response['BankcardTransactionResponsePro']) ) { + return $response['BankcardTransactionResponsePro']; + } else if ( isset($response['BankcardCaptureResponse']) ) { + return $response['BankcardCaptureResponse']; + } else { + return $this->processError($error, $response); + } + } + } } /* @@ -439,17 +439,17 @@ public function handleResponse($error, $response) { * @return object $error detail created on the basis of gateway error status. */ private function processError($error, $response) { - if ( isset($response) ) { - $valerr = ''; - $reson = isset($response['ErrorResponse']['Reason']) ? $response['ErrorResponse']['Reason'] : NULL; - $valError = is_array($response['ErrorResponse']['ValidationErrors']) ? $response['ErrorResponse']['ValidationErrors'] : array(); - $valerr .= $reson . '
'; - foreach ($valError as $key => $value) { - $valerr .= $value['RuleMessage'] . '
'; - } - return $valerr; - } else - return $error; - + if ( isset($response) ) { + $valerr = ''; + $reson = isset($response['ErrorResponse']['Reason']) ? $response['ErrorResponse']['Reason'] : NULL; + $valError = is_array($response['ErrorResponse']['ValidationErrors']) ? $response['ErrorResponse']['ValidationErrors'] : array(); + $valerr .= $reson . '
'; + foreach ($valError as $key => $value) { + $valerr .= $value['RuleMessage'] . '
'; + } + return $valerr; + } else + return $error; + } } \ No newline at end of file diff --git a/sdk/Velocity/XmlCreator.php b/sdk/Velocity/XmlCreator.php index ef20d42..d9d236a 100644 --- a/sdk/Velocity/XmlCreator.php +++ b/sdk/Velocity/XmlCreator.php @@ -82,7 +82,6 @@ public static function transaction_XML($xml, $root, $data) { if(isset($data['billingdata']['address'])) { $n3 = $xml->createElement("ns2:Address"); $n2->appendChild($n3); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('street', "ns2:Street1", $xml, $n3, $data['billingdata']['address']); VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street2', "ns2:Street2", $xml, $n3, $data['billingdata']['address']); VelocityXmlCreator::populate_XML_element_if_array_value_isset('City', "ns2:City", $xml, $n3, $data['billingdata']['address']); @@ -94,7 +93,6 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('phone', "ns2:Phone", $xml, $n1, $data['billingdata']); VelocityXmlCreator::populate_XML_element_if_array_value_isset('fax', "ns2:Fax", $xml, $n1, $data['billingdata']); VelocityXmlCreator::populate_XML_element_if_array_value_isset('email', "ns2:Email", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_id', "ns2:CustomerId", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_tax_id', "ns2:CustomerTaxId", $xml, $n1, $data); } diff --git a/sdk/Velocity/XmlParser.php b/sdk/Velocity/XmlParser.php index 8caae94..81a815b 100644 --- a/sdk/Velocity/XmlParser.php +++ b/sdk/Velocity/XmlParser.php @@ -12,10 +12,10 @@ private function __wakeup() {} * @return array $result xml tags converted into array keys and values. */ public static function parse($string) { - $xml = simplexml_load_string($string); - $result = array(); - $result[$xml->getName()] = self::normalize($xml); - return $result; + $xml = simplexml_load_string($string); + $result = array(); + $result[$xml->getName()] = self::normalize($xml); + return $result; } /* @@ -24,79 +24,79 @@ public static function parse($string) { * @return array $result xml tags converted into array keys and values. */ private static function normalize($object, $inArray = false) { - $result = array(); + $result = array(); - foreach ($object->children() as $node) { - $name = $node->getName(); - $type = $node['type']; + foreach ($object->children() as $node) { + $name = $node->getName(); + $type = $node['type']; - switch ($type) { - case 'boolean': - $res = (string) $node === 'true'; - break; + switch ($type) { + case 'boolean': + $res = (string) $node === 'true'; + break; - case 'datetime': - // Our JSON deserialization doesn't include conversion of time - // values to native types, so skip this until we have - // something resembling an identity map. - // $res = new DateTime($node); - $res = (string) $node; - break; + case 'datetime': + // Our JSON deserialization doesn't include conversion of time + // values to native types, so skip this until we have + // something resembling an identity map. + // $res = new DateTime($node); + $res = (string) $node; + break; - case 'integer': - $res = (integer) $node; - break; + case 'integer': + $res = (integer) $node; + break; - case 'array': - $res = self::normalize($node, true); - break; + case 'array': + $res = self::normalize($node, true); + break; - default: - if (count($node->children())) { - $res = self::normalize($node); - } else { - // Deal with items that should just be an array of - // attributes (like most items). - if ($node->attributes()) { - $res = array(); - foreach ($node->attributes() as $k => $v) { - $res[$k] = (string) $v; - } - // Sometimes a would include a text node with - // the optional description of the message. - $text = (string) $node; - if (!empty($text)) { - $res['$t'] = $text; - } - } else { - $res = (string) $node; - } - } - break; - } + default: + if (count($node->children())) { + $res = self::normalize($node); + } else { + // Deal with items that should just be an array of + // attributes (like most items). + if ($node->attributes()) { + $res = array(); + foreach ($node->attributes() as $k => $v) { + $res[$k] = (string) $v; + } + // Sometimes a would include a text node with + // the optional description of the message. + $text = (string) $node; + if (!empty($text)) { + $res['$t'] = $text; + } + } else { + $res = (string) $node; + } + } + break; + } - // If we're dealing with an array, create one. Note that the - // wrapping tags of array items will be left out. In other words, - // if you have a ... - // structure, you'll get an array('messages' => array(0 => firstItem, - // 1 => secondItem)) array. + // If we're dealing with an array, create one. Note that the + // wrapping tags of array items will be left out. In other words, + // if you have a ... + // structure, you'll get an array('messages' => array(0 => firstItem, + // 1 => secondItem)) array. - if (array_key_exists($name, $result) || $inArray) { - $inArray = true; + if (array_key_exists($name, $result) || $inArray) { + $inArray = true; - // A hacky way of figuring out whether we're already dealing - // with the indexed array, or still referencing the assoc array - // with the list of attributes. - if (!isset($result[0]) && isset($result[$name])) { - $result = array($result[$name]); - } - $result[] = $res; - } else { - $result[$name] = $res; - } - } + // A hacky way of figuring out whether we're already dealing + // with the indexed array, or still referencing the assoc array + // with the list of attributes. + if (!isset($result[0]) && isset($result[$name])) { + $result = array($result[$name]); + } + $result[] = $res; + } else { + $result[$name] = $res; + } + } - return $result; + return $result; } } diff --git a/velocityClients.php b/velocityClients.php index a45098b..9f8e61c 100644 --- a/velocityClients.php +++ b/velocityClients.php @@ -118,7 +118,7 @@ $response = $velocityProcessor->authorizeAndCapture(array( 'amount' => 10.03, 'avsdata' => $avsData, - 'carddata' => $cardDataKeyed, + 'carddata' => $cardData, 'order_id' => '629203', )); @@ -144,7 +144,7 @@ $response = $velocityProcessor->authorizeAndCapture(array( 'amount' => 10.03, 'avsdata' => $avsData, - 'carddata' => $cardDataSwiped, + 'carddata' => $cardData, 'order_id' => '629203', )); @@ -289,13 +289,14 @@ try { $response = $velocityProcessor->returnUnlinked(array( - 'amount' => 1.03, - 'token' => $paymentAccountDataToken, - 'order_id' => '629203', - 'entry_mode' => 'Keyed', - 'IndustryType' =>'Ecommerce', - 'Reference' => 'xyz', - 'EmployeeId' => '11' + 'amount' => 1.03, + 'avsdata' => $avsData, + 'carddata' => $cardData, + 'order_id' => '629203', + 'entry_mode' => 'Keyed', + 'IndustryType' => 'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' )); @@ -325,8 +326,8 @@ 'ApprovalCodes' => array('VI0000'), 'BatchIds' => array('0539'), 'CaptureDateRange' => array( - 'EndDateTime' => '2015-03-17 02:03:40', - 'StartDateTime' => '2015-03-13 02:03:40' + 'EndDateTime' => '2015-07-17 02:03:40', + 'StartDateTime' => '2015-07-13 02:03:40' ), 'CaptureStates' => array('ReadyForCapture'), 'CardTypes' => array('Visa'), @@ -340,8 +341,8 @@ ) ), 'TransactionDateRange' => array( - 'EndDateTime' => '2015-03-17 02:03:40', - 'StartDateTime' => '2015-03-13 02:03:40' + 'EndDateTime' => '2015-07-17 02:03:40', + 'StartDateTime' => '2015-07-13 02:03:40' ), 'TransactionIds' => array('9B935E96763F43C3866F603319BE7B52'), 'TransactionStates' => array('Authorized') @@ -404,7 +405,7 @@ try { - $response = $VelocityProcessor->authorizeAndCapture(array( + $response = $velocityProcessor->authorizeAndCapture(array( 'amount' => 10.03, 'avsdata' => $avsData, 'p2pedata' => array( @@ -438,7 +439,7 @@ try { - $response = $VelocityProcessor->returnUnlinked(array( + $response = $velocityProcessor->returnUnlinked(array( 'amount' => 1.03, 'p2pedata' => array( 'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88', From 2ae72b045382486539efbe86b7c03d6911b70c7d Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Wed, 10 Feb 2016 17:55:16 +0530 Subject: [PATCH 09/11] update the SDK after fix the class name and Contradictory issue --- sdk/Velocity/Connection.php | 14 ++-- sdk/Velocity/XmlCreator.php | 125 +++++++++++++++++++++++------------- 2 files changed, 88 insertions(+), 51 deletions(-) diff --git a/sdk/Velocity/Connection.php b/sdk/Velocity/Connection.php index f0f9953..f88fc00 100644 --- a/sdk/Velocity/Connection.php +++ b/sdk/Velocity/Connection.php @@ -9,7 +9,7 @@ class VelocityConnection public static function instance() { if (!isset(self::$instance)) { - self::$instance = new self(); + self::$instance = new self(); } return self::$instance; } @@ -212,11 +212,13 @@ private function request($method, $path, $data = array()) { if (preg_match('/json/', $contentType)) { $response = json_decode($body, true); } elseif (preg_match('/xml/', $contentType)) { - $arr = explode('Path=/', $body); - if(isset($arr[1])) - $response = VelocityXmlParser::parse($arr[1]); - else - $response = VelocityXmlParser::parse($body); + // $arr = explode('Path=/', $body); + // if(isset($arr[1])) + // $response = VelocityXmlParser::parse($arr[1]); + // else + // $response = VelocityXmlParser::parse($body); + preg_match('/<.*/', $body, $matches, PREG_OFFSET_CAPTURE); + $response = VelocityXmlParser::parse($matches[0][0]); } return array($error, $response); diff --git a/sdk/Velocity/XmlCreator.php b/sdk/Velocity/XmlCreator.php index d9d236a..d457644 100644 --- a/sdk/Velocity/XmlCreator.php +++ b/sdk/Velocity/XmlCreator.php @@ -45,8 +45,8 @@ public static function verifyXML($data) { return VelocityXmlCreator::transaction_XML($xml, $root, $data); } - public static function transaction_XML($xml, $root, $data) { - + public static function transaction_XML($xml, $root, $data) { + if (empty($data['amount'])) { throw new Exception(VelocityMessage::$descriptions['erramtnotset']); }else{ @@ -57,6 +57,12 @@ public static function transaction_XML($xml, $root, $data) { throw new Exception(VelocityMessage::$descriptions['errcarddatatokennotset']); } + if ( empty($data['entry_mode']) && (isset($data['carddata']['pan']) || isset($data['token'])) ) { + $data['entry_mode'] = 'Keyed'; + } + if ( empty($data['entry_mode']) && isset($data['carddata']['track2data']) ) { + $data['entry_mode'] = 'TrackDataFromMSR'; + } $n = $xml->createElement("ApplicationProfileId"); $idText = $xml->createTextNode(VelocityProcessor::$applicationprofileid); $n->appendChild($idText); @@ -75,36 +81,37 @@ public static function transaction_XML($xml, $root, $data) { $n1 = $xml->createElement("temp"); if( isset($data['billingdata']) ) { - $n2 = $xml->createElement("ns2:BillingData"); + $n2 = $xml->createElement("txn:BillingData"); $n1->appendChild($n2); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('name', "ns2:Name", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('name', "txn:Name", $xml, $n1, $data['billingdata']); + if(isset($data['billingdata']['address'])) { - $n3 = $xml->createElement("ns2:Address"); + $n3 = $xml->createElement("txn:Address"); $n2->appendChild($n3); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('street', "ns2:Street1", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street2', "ns2:Street2", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('City', "ns2:City", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('StateProvince', "ns2:StateProvince", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('PostalCode', "ns2:PostalCode", $xml, $n3, $data['billingdata']['address']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('Country', "ns2:CountryCode", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('street', "txn:Street1", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street2', "txn:Street2", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('City', "txn:City", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('StateProvince', "txn:StateProvince", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('PostalCode', "txn:PostalCode", $xml, $n3, $data['billingdata']['address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Country', "txn:CountryCode", $xml, $n3, $data['billingdata']['address']); } - VelocityXmlCreator::populate_XML_element_if_array_value_isset('business_name', "ns2:BusinessName", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('phone', "ns2:Phone", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('fax', "ns2:Fax", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('email', "ns2:Email", $xml, $n1, $data['billingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_id', "ns2:CustomerId", $xml, $n1, $data); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_tax_id', "ns2:CustomerTaxId", $xml, $n1, $data); + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('business_name', "txn:BusinessName", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('phone', "txn:Phone", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('fax', "txn:Fax", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('email', "txn:Email", $xml, $n1, $data['billingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_id', "txn:CustomerId", $xml, $n1, $data); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_tax_id', "txn:CustomerTaxId", $xml, $n1, $data); } - if ( isset($data['reportingdata']) ){ - $n1 = $xml->createElement("ns2:ReportingData"); + $n1 = $xml->createElement("txn:ReportingData"); $n->appendChild($n1); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('comment', "ns2:Comment", $xml, $n1, $data['reportingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('description', "ns2:Description", $xml, $n1, $data['reportingdata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('reference', "ns2:Reference", $xml, $n1, $data['reportingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('comment', "txn:Comment", $xml, $n1, $data['reportingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('description', "txn:Description", $xml, $n1, $data['reportingdata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('reference', "txn:Reference", $xml, $n1, $data['reportingdata']); } $n1 = $xml->createElement("bcp:TenderData"); @@ -112,22 +119,24 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('token', "txn:PaymentAccountDataToken", $xml, $n1, $data); - if ( isset($data['p2pedata'])) { - VelocityXmlCreator::populate_XML_element_if_array_value_isset('SecurePaymentAccountData', "txn:SecurePaymentAccountData", $xml, $n1, $data['p2pedata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('EncryptionKeyId', "txn:EncryptionKeyId", $xml, $n1, $data['p2pedata']); - } + if ( isset($data['p2pedata'])) { + VelocityXmlCreator::populate_XML_element_if_array_value_isset('SecurePaymentAccountData', "txn:SecurePaymentAccountData", $xml, $n1, $data['p2pedata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('EncryptionKeyId', "txn:EncryptionKeyId", $xml, $n1, $data['p2pedata']); + } if ( isset($data['carddata']) ) { $n2 = $xml->createElement("bcp:CardData"); $n1->appendChild($n2); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('cardtype', "bcp:CardType", $xml, $n2, $data['carddata']); - if( $data['carddata']['track1data'] != '' || $data['carddata']['track2data'] != '') { - VelocityXmlCreator::populate_XML_element_if_array_value_isset('track1data', "bcp:Track1Data", $xml, $n2, $data['carddata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('track2data', "bcp:Track2Data", $xml, $n2, $data['carddata']); - } else { - VelocityXmlCreator::populate_XML_element_if_array_value_isset('pan', "bcp:PAN", $xml, $n2, $data['carddata']); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('expire', "bcp:Expire", $xml, $n2, $data['carddata']); - } + + if( $data['carddata']['track1data'] != '' || $data['carddata']['track2data'] != '') { + VelocityXmlCreator::populate_XML_element_if_array_value_isset('track1data', "bcp:Track1Data", $xml, $n2, $data['carddata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('track2data', "bcp:Track2Data", $xml, $n2, $data['carddata']); + } else { + VelocityXmlCreator::populate_XML_element_if_array_value_isset('pan', "bcp:PAN", $xml, $n2, $data['carddata']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('expire', "bcp:Expire", $xml, $n2, $data['carddata']); + } } if (isset($data['avsdata']) || (isset($data['carddata']) && isset($data['cvdata']['cvv']))){ @@ -154,17 +163,16 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('Country', "bcp:CountryCode", $xml, $n3, $data['avsdata']); } - if (isset($data['carddata']) && isset($data['carddata']['cvv'])) { - - if( $data['carddata']['track1data'] == '' && $data['carddata']['track2data'] == '') { - $n3 = $xml->createElement("bcp:CVDataProvided"); - $idText = $xml->createTextNode('Provided'); - $n3->appendChild($idText); - $n2->appendChild($n3); - - VelocityXmlCreator::populate_XML_element_if_array_value_isset('cvv', "bcp:CVData", $xml, $n2, $data['carddata']); - } - } + if (isset($data['carddata']) && isset($data['carddata']['cvv'])) { + if( $data['carddata']['track1data'] == '' && $data['carddata']['track2data'] == '' ) { + $n3 = $xml->createElement("bcp:CVDataProvided"); + $idText = $xml->createTextNode('Provided'); + $n3->appendChild($idText); + $n2->appendChild($n3); + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('cvv', "bcp:CVData", $xml, $n2, $data['carddata']); + } + } } $n1 = $xml->createElement("bcp:TransactionData"); @@ -174,7 +182,34 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('currency_code', "txn:CurrencyCode", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_if_array_value_isset('transaction_datetime', "txn:TransactionDateTime", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_if_array_value_isset('campaign_id', "txn:CampaignId", $xml, $n1, $data); - VelocityXmlCreator::populate_XML_element_if_array_value_isset('Reference', "txn:Reference", $xml, $n1, $data); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('IgnoreDuplicateCheck', "txn:IgnoreDuplicateCheck", $xml, $n1, $data); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('AccountType', "txn:AccountType", $xml, $n1, $data); + + if (isset($data['AlternativeMerchantData'])) { + $n2 = $xml->createElement("bcp:AlternativeMerchantData"); + $n1->appendChild($n2); + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('CustomerServiceInternet', "txn:CustomerServiceInternet", $xml, $n2, $data['AlternativeMerchantData']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('CustomerServicePhone', "txn:CustomerServicePhone", $xml, $n2, $data['AlternativeMerchantData']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Description', "txn:Description", $xml, $n2, $data['AlternativeMerchantData']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('SIC', "txn:SIC", $xml, $n2, $data['AlternativeMerchantData']); + + if (isset($data['AlternativeMerchantData']['Address'])) { + $n3 = $xml->createElement("txn:Address"); + $n2->appendChild($n3); + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street1', "txn:Street1", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Street2', "txn:Street2", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('City', "txn:City", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('StateProvince', "txn:StateProvince", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('PostalCode', "txn:PostalCode", $xml, $n1, $data['AlternativeMerchantData']['Address']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('CountryCode', "txn:CountryCode", $xml, $n1, $data['AlternativeMerchantData']['Address']); + } + + VelocityXmlCreator::populate_XML_element_if_array_value_isset('MerchantId', "txn:MerchantId", $xml, $n2, $data['AlternativeMerchantData']); + VelocityXmlCreator::populate_XML_element_if_array_value_isset('Name', "txn:Name", $xml, $n2, $data['AlternativeMerchantData']); + } + VelocityXmlCreator::populate_XML_element_if_array_value_isset('approval_code', "bcp:ApprovalCode", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_with_amount_if_array_value_isset('cash_back_amount', "bcp:CashBackAmount", $xml, $n1, $data); VelocityXmlCreator::populate_XML_element_if_array_value_isset('customer_present', "bcp:CustomerPresent", $xml, $n1, $data); From 36f6b32c13a78a7a363e56fc37f334e6606908c0 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Thu, 11 Feb 2016 16:00:51 +0530 Subject: [PATCH 10/11] fixed the track1data & track2data issue. --- sdk/Velocity/XmlCreator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/Velocity/XmlCreator.php b/sdk/Velocity/XmlCreator.php index d457644..0dd0990 100644 --- a/sdk/Velocity/XmlCreator.php +++ b/sdk/Velocity/XmlCreator.php @@ -130,7 +130,7 @@ public static function transaction_XML($xml, $root, $data) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('cardtype', "bcp:CardType", $xml, $n2, $data['carddata']); - if( $data['carddata']['track1data'] != '' || $data['carddata']['track2data'] != '') { + if( (array_key_exists('track1data', $data['carddata']) && $data['carddata']['track1data'] != '') || (array_key_exists('track2data', $data['carddata']) && $data['carddata']['track2data'] != '')) { VelocityXmlCreator::populate_XML_element_if_array_value_isset('track1data', "bcp:Track1Data", $xml, $n2, $data['carddata']); VelocityXmlCreator::populate_XML_element_if_array_value_isset('track2data', "bcp:Track2Data", $xml, $n2, $data['carddata']); } else { @@ -164,7 +164,7 @@ public static function transaction_XML($xml, $root, $data) { } if (isset($data['carddata']) && isset($data['carddata']['cvv'])) { - if( $data['carddata']['track1data'] == '' && $data['carddata']['track2data'] == '' ) { + if ((!array_key_exists('track1data', $data['carddata']) || $data['carddata']['track1data'] == '') && (!array_key_exists('track2data', $data['carddata']) || $data['carddata']['track2data'] == '')) { $n3 = $xml->createElement("bcp:CVDataProvided"); $idText = $xml->createTextNode('Provided'); $n3->appendChild($idText); From 5660f31d8769e97d6f8971bbca730a75ecf75e32 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Thu, 11 Feb 2016 18:08:46 +0530 Subject: [PATCH 11/11] update README.md after rebase --- README.md | 335 ++++++++++++++++++++++++++---------------------------- 1 file changed, 163 insertions(+), 172 deletions(-) diff --git a/README.md b/README.md index 6323385..3c5098a 100644 --- a/README.md +++ b/README.md @@ -45,50 +45,50 @@ Below is an example of an authorize and capture with each of the different types try { - $response = $velocityProcessor->authorizeAndCapture(array( - 'amount' => 10.03, - 'avsdata' => array( - 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'token' => $paymentAccountDataToken, - 'order_id' => '629203', - )); + $response = $velocityProcessor->authorizeAndCapture(array( + 'amount' => 10.03, + 'avsdata' => array( + 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'token' => $paymentAccountDataToken, + 'order_id' => '629203', + )); - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'AuthorizeAndCapture Successful!
'; - echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; - echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; - echo 'Amount: ' . $response['Amount'] . '
'; - echo 'TransactionId: ' . $response['TransactionId']; - } else { - // some error - print_r($response); - } + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'AuthorizeAndCapture Successful!
'; + echo 'Masked PAN: ' . $response['MaskedPAN'] . '
'; + echo 'Approval Code: ' . $response['ApprovalCode'] . '
'; + echo 'Amount: ' . $response['Amount'] . '
'; + echo 'TransactionId: ' . $response['TransactionId']; + } else { + // some error + print_r($response); + } - $response = $velocityProcessor->verify( array( - 'avsdata' => array( 'Street' => 'xyz', - 'City' => 'cityname', - 'StateProvince' => 'statecode', - 'PostalCode' => 'postcode', - 'Country' => 'countrycode three letter' - ), - 'carddata' => array( 'cardowner' => 'Jane Doe', - 'cardtype' => 'Visa', - 'pan' => '', - 'expire' => '', - 'cvv' => '' - 'track1data' => $track1data, - 'track2data' => '˜' - ) - 'entry_mode' => '˜TrackDataFromMSR', - 'IndustryType' =>'Retail', - 'Reference' => '˜xyz', - 'EmployeeId' => '˜11' - )); + $response = $velocityProcessor->verify( array( + 'avsdata' => array( 'Street' => 'xyz', + 'City' => 'cityname', + 'StateProvince' => 'statecode', + 'PostalCode' => 'postcode', + 'Country' => 'countrycode three letter' + ), + 'carddata' => array( 'cardowner' => 'Jane Doe', + 'cardtype' => 'Visa', + 'pan' => '', + 'expire' => '', + 'cvv' => '' + 'track1data' => $track1data, + 'track2data' => '˜' + ) + 'entry_mode' => '˜TrackDataFromMSR', + 'IndustryType' =>'Retail', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); } catch(Exception $e) { echo $e->getMessage(); @@ -160,12 +160,9 @@ Below is an example of an authorize and capture with each of the different types } catch(Exception $e) { echo $e->getMessage(); } -``` #### Authorize and capture with keyed data - -``` -try { + try { $response = $velocityProcessor->authorizeAndCapture( array( 'amount' => 10.03, 'avsdata' => array( 'Street' => 'xyz', @@ -383,12 +380,9 @@ try { } catch (Exception $e) { echo $e->getMessage(); die; } - -``` -#### Authorize with keyed data -``` -try { +#### Authorize with keyed data + try { $response = $velocityProcessor->authorize( array( 'amount' => 10.03, 'avsdata' => array( 'Street' => 'xyz', @@ -615,163 +609,160 @@ Then you can perform the transaction: try { $response = $velocityProcessor->adjust(array( - 'amount' => 3.01, - 'TransactionId' => $captxnid - )); - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'Adjust Successful!
'; - echo 'Amount: ' . $response['Amount'] . '

'; - $adjusttxnid = $response['TransactionId']; - } else { - // some error - print_r($response); - - } catch (Exception $e) { - echo $e->getMessage(); - } - - $adjusttxnid = $response['TransactionId']; - - $captxnid = $response['TransactionId']; + 'amount' => 3.01, + 'TransactionId' => $captxnid + )); + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Adjust Successful!
'; + echo 'Amount: ' . $response['Amount'] . '

'; + $adjusttxnid = $response['TransactionId']; + } else { + // some error + print_r($response); + + } catch (Exception $e) { + echo $e->getMessage(); + } + $adjusttxnid = $response['TransactionId']; + $captxnid = $response['TransactionId']; -} catch(Exception $e) { - echo $e->getMessage(); -} + } catch(Exception $e) { + echo $e->getMessage(); + } -try { - $response = $velocityProcessor->undo(array( - 'TransactionId' => $adjusttxnid - )); + try { + $response = $velocityProcessor->undo(array( + 'TransactionId' => $adjusttxnid + )); - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'Undo Successful!
'; - echo 'TransactionId: ' . $response['TransactionId'] . '

'; - } else { - // some error - print_r($response); - } + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Undo Successful!
'; + echo 'TransactionId: ' . $response['TransactionId'] . '

'; + } else { + // some error + print_r($response); + } -} catch (Exception $e) { - echo $e->getMessage(); -} - -try { - $response = $velocityProcessor->adjust(array( - 'amount' => 3.01, - 'TransactionId' => $captxnid - )); - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'Adjust Successful!
'; - echo 'Amount: ' . $response['Amount'] . '

'; - $adjusttxnid = $response['TransactionId']; - } else { - // some error - print_r($response); + } catch (Exception $e) { + echo $e->getMessage(); + } - } + try { + $response = $velocityProcessor->adjust(array( + 'amount' => 3.01, + 'TransactionId' => $captxnid + )); + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Adjust Successful!
'; + echo 'Amount: ' . $response['Amount'] . '

'; + $adjusttxnid = $response['TransactionId']; + } else { + // some error + print_r($response); + + } $adjusttxnid = $response['TransactionId']; $captxnid = $response['TransactionId']; -} catch(Exception $e) { - echo $e->getMessage(); -} + } catch(Exception $e) { + echo $e->getMessage(); + } #### Undo (Void/Reversal) -try { + try { - $response = $velocityProcessor->undo(array( - 'TransactionId' => $adjusttxnid - )); + $response = $velocityProcessor->undo(array( + 'TransactionId' => $adjusttxnid + )); - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'Undo Successful!
'; - echo 'TransactionId: ' . $response['TransactionId'] . '

'; - } else { - // some error - print_r($response); - } + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Undo Successful!
'; + echo 'TransactionId: ' . $response['TransactionId'] . '

'; + } else { + // some error + print_r($response); + } -} catch (Exception $e) { - echo $e->getMessage(); -} + } catch (Exception $e) { + echo $e->getMessage(); + } #### Adjust -try { + try { - $response = $velocityProcessor->adjust(array( - 'amount' => 3.01, - 'TransactionId' => $captxnid - )); - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'Adjust Successful!
'; - echo 'Amount: ' . $response['Amount'] . '

'; - $adjusttxnid = $response['TransactionId']; - } else { - // some error - print_r($response); - } + $response = $velocityProcessor->adjust(array( + 'amount' => 3.01, + 'TransactionId' => $captxnid + )); + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'Adjust Successful!
'; + echo 'Amount: ' . $response['Amount'] . '

'; + $adjusttxnid = $response['TransactionId']; + } else { + // some error + print_r($response); + } -} catch (Exception $e) { - echo $e->getMessage(); -} + } catch (Exception $e) { + echo $e->getMessage(); + } #### ReturnById -try { - $response = $velocityProcessor->returnById(array( - 'amount' => 5.03, - 'TransactionId' => $authCapTransactionid - )); - - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'ReturnById Successful!
'; - echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; - } else { - // some error - print_r($response); - } + try { + $response = $velocityProcessor->returnById(array( + 'amount' => 5.03, + 'TransactionId' => $authCapTransactionid + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnById Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } -} catch (Exception $e) { - echo $e->getMessage(); -} + } catch (Exception $e) { + echo $e->getMessage(); + } #### ReturnUnlinked with token: -try { + try { - $response = $velocityProcessor->returnUnlinked(array( - 'amount' => 1.03, - 'token' => $paymentAccountDataToken, - 'order_id' => '629203' - 'entry_mode' => 'Keyed', - 'IndustryType' =>'Ecommerce', - 'Reference' => 'xyz', - 'EmployeeId' => '11' - )); - - if (isset($response['Status']) && $response['Status'] == 'Successful') { - echo 'ReturnUnlinked Successful!
'; - echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; - } else { - // some error - print_r($response); - } + $response = $velocityProcessor->returnUnlinked(array( + 'amount' => 1.03, + 'token' => $paymentAccountDataToken, + 'order_id' => '629203' + 'entry_mode' => 'Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => 'xyz', + 'EmployeeId' => '11' + )); + + if (isset($response['Status']) && $response['Status'] == 'Successful') { + echo 'ReturnUnlinked Successful!
'; + echo 'ApprovalCode: ' . $response['ApprovalCode'] . '

'; + } else { + // some error + print_r($response); + } -} catch (Exception $e) { - echo $e->getMessage(); -} + } catch (Exception $e) { + echo $e->getMessage(); + } #### ReturnUnlinked with keyed data - -try { + try { $response = $velocityProcessor->returnUnlinked( array( 'amount' => 1.03, 'carddata' => array( 'cardowner' => 'Jane Doe',