diff --git a/README.md b/README.md index 964a530..3c5098a 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,92 @@ 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 { + $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); + } + + $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 { + + $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 token Method: + + try { -``` -try { $response = $velocityProcessor->authorizeAndCapture( array( 'amount' => 10.03, 'avsdata' => array( 'Street' => 'xyz', @@ -78,12 +160,9 @@ try { } 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', @@ -301,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', @@ -378,16 +454,40 @@ 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); - } + } catch (Exception $e) { + echo $e->getMessage(); die; + } + + OR + + $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); + } + + $captxnid = $response['TransactionId']; + + } catch (Exception $e) { + echo $e->getMessage(); die; + } + +#### Capture method: + + try { + + + $response = $velocityProcessor->undo(array( + 'TransactionId' => $adjusttxnid + )); + $authTransactionid = $response['TransactionId']; @@ -422,6 +522,7 @@ try { ) ); + if (isset($response['Status']) && $response['Status'] == 'Successful') { echo 'Authorize Successful!'; echo 'Masked PAN: ' . $response['MaskedPAN'] . ''; @@ -504,111 +605,164 @@ Then you can perform the transaction: print_r($response); } +#### Adjust method: + + 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']; + + } catch(Exception $e) { + echo $e->getMessage(); + } + + 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(); + } + + 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 { +#### 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); - } + $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); - } +#### ReturnById -} catch (Exception $e) { - echo $e->getMessage(); -} -``` + 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 { + 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', @@ -637,12 +791,10 @@ try { } catch(Exception $e) { echo $e->getMessage(); } -``` + ### ReturnUnlinked with swiped data -``` - try { $response = $velocityProcessor->returnUnlinked( array( 'amount' => 1.03, @@ -676,6 +828,7 @@ try { OR + try { $response = $velocityProcessor->returnUnlinked( array( 'amount' => 1.03, @@ -694,6 +847,33 @@ try { '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' => '4012888812348882', + 'expire' => '1215', + 'cvv' => '123' + ) + )); + + 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); + } + + if (isset($response['Status']) && $response['Status'] == 'Successful') { echo 'ReturnUnlinked Successful!'; echo 'ApprovalCode: ' . $response['ApprovalCode'] . ''; @@ -705,24 +885,133 @@ try { } 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' + ), + 'order_id' => '629203' + 'entry_mode' => '˜Keyed', + 'IndustryType' =>'Ecommerce', + 'Reference' => '˜xyz', + 'EmployeeId' => '˜11' + )); + } 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, @@ -749,7 +1038,7 @@ Then you can perform the transaction: } #### Verify with keyed data -``` + try { $response = $velocityProcessor->verify(array( 'avsdata' => array( @@ -787,11 +1076,11 @@ Then you can perform the transaction: } catch(Exception $e) { echo $e->getMessage(); } -``` + #### Verify with swiped data -``` + try { $response = $velocityProcessor->verify( array( @@ -826,8 +1115,12 @@ Then you can perform the transaction: } catch(Exception $e) { echo $e->getMessage(); + } + +####QueryTransactionDetail Method: + OR try { @@ -852,6 +1145,7 @@ Then you can perform the transaction: 'EmployeeId' => '11' )); + if (isset($response['Status']) && $response['Status'] == 'Successful') { echo 'Verify Successful!'; echo 'PostalCodeResult: ' . $response['AVSResult']['PostalCodeResult'] . ''; @@ -864,20 +1158,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( @@ -915,4 +1211,3 @@ Then you can perform the transaction: } catch(Exception $e) { echo $e->getMessage(); } -``` 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..0dd0990 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( (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 { + 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 ((!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); + $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); diff --git a/velocityClients.php b/velocityClients.php index 91326e8..9f8e61c 100644 --- a/velocityClients.php +++ b/velocityClients.php @@ -37,6 +37,10 @@ * 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', @@ -54,7 +58,7 @@ $response = $velocityProcessor->verify(array( 'avsdata' => $avsData, - 'carddata' => $cardData, + 'carddata' => $cardDataKeyed, 'entry_mode' => 'Keyed', 'IndustryType' =>'Ecommerce', 'Reference' => 'xyz', @@ -165,7 +169,7 @@ $response = $velocityProcessor->authorize(array( 'amount' => 10, - 'carddata' => $cardData, + 'carddata' => $cardDataKeyed, 'order_id' => '629203', 'entry_mode' => 'Keyed', 'IndustryType' =>'Ecommerce', @@ -374,7 +378,7 @@ 'p2pedata' => array( 'SecurePaymentAccountData' => '576F2E197D5804F2B6201FB2578DCD1DDDC7BAE692FE48E9C368E678914233561FB953DF47E29F88', 'EncryptionKeyId' => '9010010B257DC7000084' - ), + ), 'order_id' => '629203', 'entry_mode' => 'TrackDataFromMSR', 'IndustryType' =>'Retail', @@ -464,9 +468,77 @@ } - /* *****************************************************CaptureAll******************************************************************************** */ + /* *****************************************************CaptureAll******************************************************************************** */ $identitytoken = "PHNhbWw6QXNzZXJ0aW9uIE1ham9yVmVyc2lvbj0iMSIgTWlub3JWZXJzaW9uPSIxIiBBc3NlcnRpb25JRD0iXzQ2ZTdkZDAzLTIwYzctNGJlZS1hNTdhLWRiNmE4MTA5MDlkNiIgSXNzdWVyPSJJcGNBdXRoZW50aWNhdGlvbiIgSXNzdWVJbnN0YW50PSIyMDE0LTExLTA3VDIxOjQ5OjU2Ljg3N1oiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjEuMDphc3NlcnRpb24iPjxzYW1sOkNvbmRpdGlvbnMgTm90QmVmb3JlPSIyMDE0LTExLTA3VDIxOjQ5OjU2Ljg3N1oiIE5vdE9uT3JBZnRlcj0iMjA0NC0xMS0wN1QyMTo0OTo1Ni44NzdaIj48L3NhbWw6Q29uZGl0aW9ucz48c2FtbDpBZHZpY2U+PC9zYW1sOkFkdmljZT48c2FtbDpBdHRyaWJ1dGVTdGF0ZW1lbnQ+PHNhbWw6U3ViamVjdD48c2FtbDpOYW1lSWRlbnRpZmllcj4xQzA4MTc1OEVFNzAwMDAxPC9zYW1sOk5hbWVJZGVudGlmaWVyPjwvc2FtbDpTdWJqZWN0PjxzYW1sOkF0dHJpYnV0ZSBBdHRyaWJ1dGVOYW1lPSJTQUsiIEF0dHJpYnV0ZU5hbWVzcGFjZT0iaHR0cDovL3NjaGVtYXMuaXBjb21tZXJjZS5jb20vSWRlbnRpdHkiPjxzYW1sOkF0dHJpYnV0ZVZhbHVlPjFDMDgxNzU4RUU3MDAwMDE8L3NhbWw6QXR0cmlidXRlVmFsdWU+PC9zYW1sOkF0dHJpYnV0ZT48c2FtbDpBdHRyaWJ1dGUgQXR0cmlidXRlTmFtZT0iU2VyaWFsIiBBdHRyaWJ1dGVOYW1lc3BhY2U9Imh0dHA6Ly9zY2hlbWFzLmlwY29tbWVyY2UuY29tL0lkZW50aXR5Ij48c2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RFNGM0Z4R2dmd3pSLzBwck11OTZoQ2M9PC9vOktleUlkZW50aWZpZXI+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";