-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from barrycarrjr/master
Added credit card token functionality
- Loading branch information
Showing
9 changed files
with
218 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php namespace Omnipay\Elavon\Message; | ||
|
||
class ConvergeGenerateTokenRequest extends ConvergeAbstractRequest | ||
{ | ||
protected $transactionType = 'ccgettoken'; | ||
|
||
public function getData() | ||
{ | ||
$data = array( | ||
'ssl_transaction_type' => $this->transactionType, | ||
'ssl_amount' => $this->getAmount(), | ||
'ssl_salestax' => $this->getSslSalesTax(), | ||
|
||
'ssl_card_number' => $this->getCard()->getNumber(), | ||
'ssl_exp_date' => $this->getCard()->getExpiryDate('my'), | ||
'ssl_cvv2cvc2' => $this->getCard()->getCvv(), | ||
'ssl_cvv2cvc2_indicator' => ($this->getCard()->getCvv()) ? 1 : 0, | ||
|
||
'ssl_verify' => 'N', | ||
|
||
'ssl_first_name' => $this->getCard()->getFirstName(), | ||
'ssl_last_name' => $this->getCard()->getLastName(), | ||
'ssl_avs_address' => $this->getCard()->getAddress1(), | ||
'ssl_address2' => $this->getCard()->getAddress2(), | ||
'ssl_city' => $this->getCard()->getCity(), | ||
'ssl_state' => $this->getCard()->getState(), | ||
'ssl_country' => $this->getCard()->getCountry(), | ||
'ssl_add_token' => 'Y', | ||
|
||
'ssl_show_form' => 'false', | ||
'ssl_result_format' => 'ASCII', | ||
); | ||
|
||
return array_merge($this->getBaseData(), $data); | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$httpResponse = $this->httpClient->post($this->getEndpoint() . '/process.do', null, http_build_query($data)) | ||
->setHeader('Content-Type', 'application/x-www-form-urlencoded') | ||
->send(); | ||
|
||
return $this->createResponse($httpResponse->getBody()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php namespace Omnipay\Elavon\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
class ConvergeGenerateTokenRequestTest extends TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->request = new ConvergeGenerateTokenRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize( | ||
array( | ||
'card' => $this->getValidCard(), | ||
'ssl_show_form' => 'false', | ||
'ssl_result_format' => 'ASCII', | ||
) | ||
); | ||
} | ||
|
||
public function testCreateCardSuccess() | ||
{ | ||
$this->setMockHttpResponse('ConvergeCreateCardResponse.txt'); | ||
$response = $this->request->send(); | ||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertSame('7595301425001111', $response->getCardToken()); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
HTTP/1.1 200 OK | ||
Date: Wed, 20 Feb 2013 13:55:50 GMT | ||
Server: Apache | ||
Content-Length: 214 | ||
Connection: close | ||
Content-Type: text/plain; charset=utf-8 | ||
|
||
ssl_status=TEST MODE | ||
ssl_result=0 | ||
ssl_token=7595301425001111 | ||
ssl_card_number=41**********1111 | ||
ssl_token_response=SUCCESS | ||
ssl_add_token_response=Card Updated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
HTTP/1.1 200 OK | ||
Date: Wed, 20 Feb 2013 13:55:50 GMT | ||
Server: Apache | ||
Content-Length: 214 | ||
Connection: close | ||
Content-Type: text/plain; charset=utf-8 | ||
|
||
ssl_status=TEST MODE | ||
ssl_card_number=41**********1111 | ||
ssl_exp_date=0117 | ||
ssl_amount=10.00 | ||
ssl_salestax=1.23 | ||
ssl_invoice_number=1 | ||
ssl_departure_date= | ||
ssl_completion_date= | ||
ssl_issue_points= | ||
ssl_promo_code= | ||
ssl_enrollment= | ||
ssl_result=0 | ||
ssl_result_message=APPROVED | ||
ssl_txn_id=00000000-0000-0000-0000-00000000000 | ||
ssl_approval_code=123456 | ||
ssl_cvv2_response=P | ||
ssl_avs_response=X | ||
ssl_account_balance=0.00 | ||
ssl_txn_time=05/13/2015 07:21:58 PM | ||
ssl_loyalty_account_balance= | ||
ssl_loyalty_program= | ||
ssl_access_code= | ||
ssl_tender_amount= | ||
ssl_account_status= |