Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Adds an expiring card stub
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 26, 2016
1 parent f4840fd commit d6c3cab
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/Stubs/VaultExpiringStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

class VaultExpiringStub
{
/**
* Render the stub.
*
* @param array $cards
*
* @return string
*/
public function render(array $cards)
{
$response = '<?xml version="1.0"?><response><receipt>';

foreach ($cards as $card) {
$receipt = $card->receipt();
$data = $receipt->read('data');
$expdate = $data['expiry_date']['year'].$data['expiry_date']['month'];

$response .= '<ResolveData>';
$response .= '<data_key>'.$receipt->read('key').'</data_key>';
$response .= '<payment_type>cc</payment_type><cust_id></cust_id><phone></phone><email></email><note></note>';
$response .= '<expdate>'.$expdate.'</expdate>';
$response .= '<masked_pan>'.$data['masked_pan'].'</masked_pan>';
$response .= '<crypt_type>'.$data['crypt'].'</crypt_type>';
$response .= '</ResolveData>';
}

$response .= '<DataKey></DataKey><ReceiptId></ReceiptId><ReferenceNum></ReferenceNum>';
$response .= '<ResponseCode>001</ResponseCode><ISO></ISO><AuthCode></AuthCode>';
$response .= '<Message>Successfully located '.count($cards).' expiring cards.</Message>';
$response .= '<TransTime></TransTime><TransDate>'.date('Y-m-d').'</TransDate>';
$response .= '<TransType>'.date('h:i:s').'</TransType><Complete>true</Complete>';
$response .= '<TransAmount></TransAmount><CardType></CardType><TransID></TransID><TimedOut></TimedOut>';
$response .= '<CorporateCard></CorporateCard><RecurSuccess></RecurSuccess><AvsResultCode></AvsResultCode>';
$response .= '<CvdResultCode></CvdResultCode><ResSuccess>true</ResSuccess><PaymentType></PaymentType>';
$response .= '</receipt></response>';

return $response;
}
}

0 comments on commit d6c3cab

Please sign in to comment.