Skip to content

Commit 74477f4

Browse files
RGOPS-5175: Support scheme id portability on xsell transactions (#76)
* RGOPS-5175: Add USE_PRIMARY_SCHEME_ID request parameter * RGOPS-5175: Added code example * RGOPS-5175: Delete .idea folder content * RGOPS-5175: Replaced card details with card hash * RGOPS-5175: Updated request key used in conditional check * RGOPS-5175: Reverted unnecessary change * RGOPS-5175: Added invoiceId lookup to the example * RGOPS-5175: Changed example file name and updated invoice suffix * RGOPS-5175: Recalculated checksum after request class edit
1 parent c710e73 commit 74477f4

File tree

3 files changed

+206
-2
lines changed

3 files changed

+206
-2
lines changed

examples/UsePrimaySchemeID.php

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
<?php
2+
/*
3+
* Copyright notice:
4+
* (c) Copyright 2018 RocketGate
5+
* All rights reserved.
6+
*
7+
* The copyright notice must not be removed without specific, prior
8+
* written permission from RocketGate.
9+
*
10+
* This software is protected as an unpublished work under the U.S. copyright
11+
* laws. The above copyright notice is not intended to effect a publication of
12+
* this work.
13+
* This software is the confidential and proprietary information of RocketGate.
14+
* Neither the binaries nor the source code may be redistributed without prior
15+
* written permission from RocketGate.
16+
*
17+
* The software is provided "as-is" and without warranty of any kind, express, implied
18+
* or otherwise, including without limitation, any warranty of merchantability or fitness
19+
* for a particular purpose. In no event shall RocketGate be liable for any direct,
20+
* special, incidental, indirect, consequential or other damages of any kind, or any damages
21+
* whatsoever arising out of or in connection with the use or performance of this software,
22+
* including, without limitation, damages resulting from loss of use, data or profits, and
23+
* whether or not advised of the possibility of damage, regardless of the theory of liability.
24+
*
25+
*/
26+
namespace RocketGate\examples;
27+
28+
require '../vendor/autoload.php';
29+
30+
use RocketGate\Sdk\GatewayRequest;
31+
use RocketGate\Sdk\GatewayResponse;
32+
use RocketGate\Sdk\GatewayService;
33+
34+
//
35+
// Allocate the objects we need for the test.
36+
//
37+
$request = new GatewayRequest();
38+
$response = new GatewayResponse();
39+
$service = new GatewayService();
40+
41+
//
42+
// Setup the original transaction request.
43+
//
44+
$request->Set(GatewayRequest::MERCHANT_ID(), "1");
45+
$request->Set(GatewayRequest::MERCHANT_PASSWORD(), "testpassword");
46+
47+
// For example/testing, we set the order id and customer as the unix timestamp as a convienent sequencing value
48+
// appending a test name to the order id to facilitate some clarity when reviewing the tests
49+
$time = time();
50+
$inv_id = $time . '.UsePrySchemeID';
51+
$request->Set(GatewayRequest::MERCHANT_CUSTOMER_ID(), $time . '.PHPTest');
52+
$request->Set(GatewayRequest::MERCHANT_INVOICE_ID(), $inv_id);
53+
54+
$request->Set(GatewayRequest::AMOUNT(), "9.99");
55+
$request->Set(GatewayRequest::CURRENCY(), "USD");
56+
$request->Set(GatewayRequest::CARDNO(), "4111111111111111");
57+
$request->Set(GatewayRequest::EXPIRE_MONTH(), "02");
58+
$request->Set(GatewayRequest::EXPIRE_YEAR(), "2010");
59+
$request->Set(GatewayRequest::CVV2(), "999");
60+
61+
$request->Set(GatewayRequest::CUSTOMER_FIRSTNAME(), "Joe");
62+
$request->Set(GatewayRequest::CUSTOMER_LASTNAME(), "PHPTester");
63+
$request->Set(GatewayRequest::EMAIL(), "[email protected]");
64+
$request->Set(GatewayRequest::IPADDRESS(), $_SERVER['REMOTE_ADDR']);
65+
66+
$request->Set(GatewayRequest::BILLING_ADDRESS(), "123 Main St");
67+
$request->Set(GatewayRequest::BILLING_CITY(), "Las Vegas");
68+
$request->Set(GatewayRequest::BILLING_STATE(), "NV");
69+
$request->Set(GatewayRequest::BILLING_ZIPCODE(), "89141");
70+
$request->Set(GatewayRequest::BILLING_COUNTRY(), "US");
71+
72+
// Risk/Scrub Request Setting
73+
$request->Set(GatewayRequest::SCRUB(), "IGNORE");
74+
$request->Set(GatewayRequest::CVV2_CHECK(), "IGNORE");
75+
$request->Set(GatewayRequest::AVS_CHECK(), "IGNORE");
76+
77+
78+
//
79+
// Setup test parameters in the service and request.
80+
//
81+
$service->SetTestMode(TRUE);
82+
83+
//
84+
// Step 1: Perform an Auth-Only transaction.
85+
//
86+
if ($service->PerformAuthOnly($request, $response)) {
87+
print "Original transaction succeeded\n";
88+
print "Response Code: " . $response->Get(GatewayResponse::RESPONSE_CODE()) . "\n";
89+
print "Reason Code: " . $response->Get(GatewayResponse::REASON_CODE()) . "\n";
90+
print "Scheme TransactionId: " . $response->Get(GatewayResponse::SCHEME_TRANSACTION_ID()) . "\n";
91+
print "Scheme SettlementDate: " . $response->Get(GatewayResponse::SCHEME_SETTLEMENT_DATE()) . "\n";
92+
93+
// Compose a request to lookup the invoiceId
94+
$request = new GatewayRequest();
95+
$request->Set(GatewayRequest::MERCHANT_ID(), "1");
96+
$request->Set(GatewayRequest::MERCHANT_PASSWORD(), "testpassword");
97+
98+
$request->Set(GatewayRequest::MERCHANT_INVOICE_ID(), $inv_id);
99+
100+
// Step 2: Perform Lookup to fetch scheme transactionId and settlementDate
101+
if ($service->PerformLookup($request, $response)) {
102+
103+
$lookupTransactionId = $response->Get(GatewayResponse::SCHEME_TRANSACTION_ID());
104+
$lookupSettlementDate = $response->Get(GatewayResponse::SCHEME_SETTLEMENT_DATE());
105+
106+
print "\nLookup succeeded\n";
107+
print "Reason Code: " . $response->Get(GatewayResponse::REASON_CODE()) . "\n";
108+
print "GUID: " . $response->Get(GatewayResponse::TRANSACT_ID()) . "\n";
109+
print "Account: " . $response->Get(GatewayResponse::MERCHANT_ACCOUNT()) . "\n";
110+
print "Scheme TransactionId: " . $lookupTransactionId . "\n";
111+
print "Scheme SettlementDate: " . $lookupSettlementDate . "\n";
112+
113+
//Create a new request to use the scheme transactionId and settlementDate of the original transaction to create a Xsell transaction
114+
$request = new GatewayRequest();
115+
$service = new GatewayService();
116+
117+
$request->Set(GatewayRequest::MERCHANT_ID(), "1");
118+
$request->Set(GatewayRequest::MERCHANT_PASSWORD(), "testpassword");
119+
120+
// For example/testing, we set the order id and customer as the unix timestamp as a convienent sequencing value
121+
// appending a test name to the order id to facilitate some clarity when reviewing the tests
122+
$request->Set(GatewayRequest::MERCHANT_CUSTOMER_ID(), $time . '.PHPTest');
123+
124+
$time += 1;
125+
$request->Set(GatewayRequest::MERCHANT_INVOICE_ID(), $time . '.UsePrySchemeID');
126+
127+
$request->Set(GatewayRequest::AMOUNT(), "3.00");
128+
$request->Set(GatewayRequest::CURRENCY(), "USD");
129+
$request->Set(GatewayRequest::CARD_HASH(), $response->Get(GatewayResponse::CARD_HASH()));
130+
131+
$request->Set(GatewayRequest::CUSTOMER_FIRSTNAME(), "Joe");
132+
$request->Set(GatewayRequest::CUSTOMER_LASTNAME(), "PHPTester");
133+
$request->Set(GatewayRequest::EMAIL(), "[email protected]");
134+
$request->Set(GatewayRequest::IPADDRESS(), $_SERVER['REMOTE_ADDR']);
135+
136+
$request->Set(GatewayRequest::BILLING_ADDRESS(), "123 Main St");
137+
$request->Set(GatewayRequest::BILLING_CITY(), "Las Vegas");
138+
$request->Set(GatewayRequest::BILLING_STATE(), "NV");
139+
$request->Set(GatewayRequest::BILLING_ZIPCODE(), "89141");
140+
$request->Set(GatewayRequest::BILLING_COUNTRY(), "US");
141+
142+
// Risk/Scrub Request Setting
143+
$request->Set(GatewayRequest::SCRUB(), "IGNORE");
144+
$request->Set(GatewayRequest::AVS_CHECK(), "IGNORE");
145+
146+
//Set necessary parameters required for RocketGate to port previous transaction's scheme transactionId and settlementDate
147+
$request->Set(GatewayRequest::USE_PRIMARY_SCHEMEID(), "TRUE");
148+
$request->Set(GatewayRequest::BILLING_TYPE(), "T");
149+
$request->Set(GatewayRequest::REFERENCE_SCHEME_TRANSACTION_ID(), $lookupTransactionId);
150+
$request->Set(GatewayRequest::REFERENCE_SCHEME_SETTLEMENT_DATE(), $lookupSettlementDate);
151+
152+
$response = new GatewayResponse();
153+
154+
//Step 3: Send a transaction to utilize the scheme transactionId and settlementDate
155+
if ($service->PerformAuthOnly($request, $response)) {
156+
157+
if($request->Get(GatewayRequest::REFERENCE_SCHEME_TRANSACTION_ID()) == null || $response->Get(GatewayResponse::SCHEME_TRANSACTION_ID()) == $lookupTransactionId){
158+
$areSchemeTransactionIdSame = "true";
159+
}else{
160+
$areSchemeTransactionIdSame = "false";
161+
}
162+
163+
if($request->Get(GatewayRequest::REFERENCE_SCHEME_SETTLEMENT_DATE()) == null || $response->Get(GatewayResponse::SCHEME_SETTLEMENT_DATE()) == $lookupSettlementDate){
164+
$areSchemeSettlementDateSame = "true";
165+
}else{
166+
$areSchemeSettlementDateSame = "false";
167+
}
168+
169+
print "Xsell transaction succeeded\n";
170+
print "Response Code: " . $response->Get(GatewayResponse::RESPONSE_CODE()) . "\n";
171+
print "Reason Code: " . $response->Get(GatewayResponse::REASON_CODE()) . "\n";
172+
print "Lookup & Xsell transaction response Scheme transactionIds are the same? " . $areSchemeTransactionIdSame . "\n";
173+
print "Lookup & Xsell transaction response Scheme settlementDates are the same? " . $areSchemeSettlementDateSame . "\n";
174+
}else{
175+
print "Xsell transaction failed\n";
176+
print "GUID: " . $response->Get(GatewayResponse::TRANSACT_ID()) . "\n";
177+
print "Transaction time: " . $response->Get(GatewayResponse::TRANSACTION_TIME()) . "\n";
178+
print "Response Code: " . $response->Get(GatewayResponse::RESPONSE_CODE()) . "\n";
179+
print "Reason Code: " . $response->Get(GatewayResponse::REASON_CODE()) . "\n";
180+
print "Exception: " . $response->Get(GatewayResponse::EXCEPTION()) . "\n";
181+
print "Scrub: " . $response->Get(GatewayResponse::SCRUB_RESULTS()) . "\n";
182+
}
183+
184+
} else {
185+
print "\nLookup failed\n";
186+
print "GUID: " . $response->Get(GatewayResponse::TRANSACT_ID()) . "\n";
187+
print "Reason Code: " . $response->Get(GatewayResponse::REASON_CODE()) . "\n";
188+
print "Exception: " . $response->Get(GatewayResponse::EXCEPTION()) . "\n";
189+
}
190+
191+
} else {
192+
print "Original transaction failed\n";
193+
print "GUID: " . $response->Get(GatewayResponse::TRANSACT_ID()) . "\n";
194+
print "Transaction time: " . $response->Get(GatewayResponse::TRANSACTION_TIME()) . "\n";
195+
print "Response Code: " . $response->Get(GatewayResponse::RESPONSE_CODE()) . "\n";
196+
print "Reason Code: " . $response->Get(GatewayResponse::REASON_CODE()) . "\n";
197+
print "Exception: " . $response->Get(GatewayResponse::EXCEPTION()) . "\n";
198+
print "Scrub: " . $response->Get(GatewayResponse::SCRUB_RESULTS()) . "\n";
199+
}

src/GatewayChecksum.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
class GatewayChecksum
1212
{
13-
private const VERSION = "P8.16";
13+
private const VERSION = "P8.17";
1414
public static $checksum = "";
15-
public static $baseChecksum = "f23b94cc9ee73502ed35284d963c5bec";
15+
public static $baseChecksum = "8319bb8eaf745fdea06fa133f81d3483";
1616
public static $versionNo = GatewayChecksum::VERSION;
1717

1818
//////////////////////////////////////////////////////////////////////

src/GatewayRequest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,4 +790,9 @@ static function REFERRER_URL()
790790
return "referrerURL";
791791
}
792792

793+
static function USE_PRIMARY_SCHEMEID()
794+
{
795+
return "usePrimarySchemeID";
796+
}
797+
793798
}

0 commit comments

Comments
 (0)