Skip to content

Commit

Permalink
Merge pull request #16 from djvaldez/nvp-support
Browse files Browse the repository at this point in the history
Update name-value pair client to automatically include the merchant I…
  • Loading branch information
brianmc committed Sep 23, 2015
2 parents b42b48e + 919a21e commit 8d9e0de
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/CybsNameValuePairClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function runTransaction($request)
if (!is_array($request)) {
throw new Exception('Name-value pairs must be in array');
}
if (!array_key_exists('merchantID', $request)) {
$request['merchantID'] = $this->getMerchantId();
}
$nvpRequest = "";
foreach($request as $k => $v) {
$nvpRequest .= ($k . "=" . $v ."\n");
Expand Down
4 changes: 3 additions & 1 deletion samples/AuthFollowOnCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
$reply = $client->runTransaction($request);

// This section will show all the reply fields.
echo '<pre>';
print("\nAUTH RESPONSE: " . print_r($reply, true));

if ($reply->decision != 'ACCEPT') {
Expand All @@ -76,4 +77,5 @@
$captureReply = $client->runTransaction($captureRequest);

// This section will show all the reply fields.
print("\nCAPTRUE RESPONSE: " . print_r($captureReply, true));
print("\nCAPTURE RESPONSE: " . print_r($captureReply, true));
echo '</pre>';
5 changes: 3 additions & 2 deletions samples/AuthFromNameValuePairs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Using Composer-generated autoload file.
require __DIR__ . '/../vendor/autoload.php';
// Or, uncomment the line below if you're not using Composer autoloader.
// require_once(__DIR__ . '/../lib/CybsSoapClient.php');
// require_once(__DIR__ . '/../lib/CybsNameValuePairClient.php');


// Before using this example, you can use your own reference code for the transaction.
Expand All @@ -15,7 +15,6 @@

$request = array();
$request['ccAuthService_run'] = 'true';
$request['merchantID'] = 'your_merchant_id';
$request['merchantReferenceCode'] = $referenceCode;
$request['billTo_firstName'] = 'Jane';
$request['billTo_lastName'] = 'Smith';
Expand All @@ -34,4 +33,6 @@
$reply = $client->runTransaction($request);

// This section will show all the reply fields.
echo '<pre>';
print("\nRESPONSE:\n" . $reply);
echo '</pre>';
2 changes: 2 additions & 0 deletions samples/AuthFromXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
$reply = $client->runTransactionFromFile(__DIR__ . '/xml/auth.xml', $referenceCode);

// This section will show all the reply fields.
echo '<pre>';
print("\nRESPONSE: " . print_r($reply, true));
echo '</pre>';
2 changes: 2 additions & 0 deletions samples/Sale.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@
$reply = $client->runTransaction($request);

// This section will show all the reply fields.
echo '<pre>';
print("\nRESPONSE: " . print_r($reply, true));
echo '</pre>';
3 changes: 2 additions & 1 deletion samples/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@
$reply = $client->runTransaction($request);

// This section will show all the reply fields.
echo '<pre>';
print("\nSUBSCRIPTION RESPONSE: " . print_r($reply, true));

if ($reply->decision != 'ACCEPT') {
print("\nFailed subscription request.\n");
return;
}
else
{
print("\n Subscription service request successful\n");
}
echo '</pre>';

0 comments on commit 8d9e0de

Please sign in to comment.