This repository has been archived by the owner on Oct 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds purchase with customer info tests
- Loading branch information
Craig Paul
committed
Oct 26, 2016
1 parent
01846f8
commit fbff9e7
Showing
2 changed files
with
114 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,20 @@ | |
|
||
class GatewayTest extends TestCase | ||
{ | ||
/** | ||
* The billing / shipping info for customer info requests. | ||
* | ||
* @var array | ||
*/ | ||
protected $billing; | ||
|
||
/** | ||
* The customer info for customer info requests. | ||
* | ||
* @var array | ||
*/ | ||
protected $customer; | ||
|
||
/** | ||
* The Moneris gateway. | ||
* | ||
|
@@ -31,6 +45,7 @@ public function setUp() | |
{ | ||
parent::setUp(); | ||
|
||
$faker = Faker::create(); | ||
$params = ['environment' => $this->environment]; | ||
$this->gateway = Moneris::create($this->id, $this->token, $params); | ||
$this->params = [ | ||
|
@@ -39,6 +54,28 @@ public function setUp() | |
'credit_card' => $this->visa, | ||
'expdate' => '2012', | ||
]; | ||
$this->billing = [ | ||
'first_name' => $faker->firstName, | ||
'last_name' => $faker->lastName, | ||
'company_name' => $faker->company, | ||
'address' => $faker->streetAddress, | ||
'city' => $faker->city, | ||
'province' => 'SK', | ||
'postal_code' => 'X0X0X0', | ||
'country' => 'Canada', | ||
'phone_number' => '555-555-5555', | ||
'fax' => '555-555-5555', | ||
'tax1' => '1.01', | ||
'tax2' => '1.02', | ||
'tax3' => '1.03', | ||
'shipping_cost' => '9.99', | ||
]; | ||
$this->customer = [ | ||
'email' => '[email protected]', | ||
'instructions' => $faker->sentence(mt_rand(3, 6)), | ||
'billing' => $this->billing, | ||
'shipping' => $this->billing | ||
]; | ||
} | ||
|
||
/** @test */ | ||
|
@@ -69,6 +106,23 @@ public function it_can_make_a_purchase_and_receive_a_response() | |
$this->assertTrue($response->successful); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_make_a_purchase_with_provided_customer_information_and_receive_a_response() | ||
{ | ||
$params = array_merge($this->params, [ | ||
'cust_id' => uniqid('customer-', true), | ||
'cust_info' => $this->customer, | ||
]); | ||
|
||
$response = $this->gateway->purchase($params); | ||
$receipt = $response->receipt(); | ||
|
||
$this->assertEquals(Response::class, get_class($response)); | ||
$this->assertTrue($response->successful); | ||
$this->assertTrue($receipt->read('complete')); | ||
$this->assertNotNull($receipt->read('transaction')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_make_a_cvd_secured_purchase_and_receive_a_response() | ||
{ | ||
|
@@ -119,32 +173,11 @@ public function it_can_pre_authorize_a_purchase_and_receive_a_response() | |
/** @test */ | ||
public function it_can_pre_authorize_a_purchase_with_provided_customer_information_and_receive_a_response() | ||
{ | ||
$faker = Faker::create(); | ||
$customer = [ | ||
'first_name' => $faker->firstName, | ||
'last_name' => $faker->lastName, | ||
'company_name' => $faker->company, | ||
'address' => $faker->streetAddress, | ||
'city' => $faker->city, | ||
'province' => 'SK', | ||
'postal_code' => 'X0X0X0', | ||
'country' => 'Canada', | ||
'phone_number' => '555-555-5555', | ||
'fax' => '555-555-5555', | ||
'tax1' => '1.01', | ||
'tax2' => '1.02', | ||
'tax3' => '1.03', | ||
'shipping_cost' => '9.99', | ||
]; | ||
$params = array_merge($this->params, [ | ||
'cust_id' => uniqid('customer-', true), | ||
'cust_info' => [ | ||
'email' => '[email protected]', | ||
'instructions' => $faker->sentence(mt_rand(3, 6)), | ||
'billing' => $customer, | ||
'shipping' => $customer | ||
], | ||
'cust_info' => $this->customer, | ||
]); | ||
|
||
$response = $this->gateway->preauth($params); | ||
$receipt = $response->receipt(); | ||
|
||
|
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 |
---|---|---|
|
@@ -8,11 +8,25 @@ | |
|
||
class VaultTest extends TestCase | ||
{ | ||
/** | ||
* The billing / shipping info for customer info requests. | ||
* | ||
* @var array | ||
*/ | ||
protected $billing; | ||
|
||
/** | ||
* @var \CraigPaul\Moneris\CreditCard | ||
*/ | ||
protected $card; | ||
|
||
/** | ||
* The customer info for customer info requests. | ||
* | ||
* @var array | ||
*/ | ||
protected $customer; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
|
@@ -32,12 +46,35 @@ public function setUp() | |
{ | ||
parent::setUp(); | ||
|
||
$faker = Faker::create(); | ||
$this->card = CreditCard::create($this->visa, '2012'); | ||
$this->params = [ | ||
'order_id' => uniqid('1234-567890', true), | ||
'amount' => '1.00', | ||
]; | ||
$this->vault = Vault::create($this->id, $this->token, $this->environment); | ||
$this->billing = [ | ||
'first_name' => $faker->firstName, | ||
'last_name' => $faker->lastName, | ||
'company_name' => $faker->company, | ||
'address' => $faker->streetAddress, | ||
'city' => $faker->city, | ||
'province' => 'SK', | ||
'postal_code' => 'X0X0X0', | ||
'country' => 'Canada', | ||
'phone_number' => '555-555-5555', | ||
'fax' => '555-555-5555', | ||
'tax1' => '1.01', | ||
'tax2' => '1.02', | ||
'tax3' => '1.03', | ||
'shipping_cost' => '9.99', | ||
]; | ||
$this->customer = [ | ||
'email' => '[email protected]', | ||
'instructions' => $faker->sentence(mt_rand(3, 6)), | ||
'billing' => $this->billing, | ||
'shipping' => $this->billing | ||
]; | ||
} | ||
|
||
/** @test */ | ||
|
@@ -245,6 +282,26 @@ public function it_can_make_a_purchase_with_a_credit_card_stored_in_the_moneris_ | |
$this->assertEquals(true, $receipt->read('complete')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_make_a_purchase_with_a_credit_card_stored_in_the_moneris_vault_and_attach_customer_info() | ||
{ | ||
$response = $this->vault->add($this->card); | ||
$key = $response->receipt()->read('key'); | ||
|
||
$params = array_merge($this->params, [ | ||
'data_key' => $key, | ||
'cust_id' => uniqid('customer-', true), | ||
'cust_info' => $this->customer, | ||
]); | ||
|
||
$response = $this->vault->purchase($params); | ||
$receipt = $response->receipt(); | ||
|
||
$this->assertTrue($response->successful); | ||
$this->assertEquals($key, $receipt->read('key')); | ||
$this->assertEquals(true, $receipt->read('complete')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_submit_a_cvd_secured_purchase_with_a_credit_card_stored_in_the_moneris_vault() | ||
{ | ||
|
@@ -315,32 +372,10 @@ public function it_can_pre_authorize_a_credit_card_stored_in_the_moneris_vault_a | |
$response = $this->vault->add($this->card); | ||
$key = $response->receipt()->read('key'); | ||
|
||
$faker = Faker::create(); | ||
$customer = [ | ||
'first_name' => $faker->firstName, | ||
'last_name' => $faker->lastName, | ||
'company_name' => $faker->company, | ||
'address' => $faker->streetAddress, | ||
'city' => $faker->city, | ||
'province' => 'SK', | ||
'postal_code' => 'X0X0X0', | ||
'country' => 'Canada', | ||
'phone_number' => '555-555-5555', | ||
'fax' => '555-555-5555', | ||
'tax1' => '1.01', | ||
'tax2' => '1.02', | ||
'tax3' => '1.03', | ||
'shipping_cost' => '9.99', | ||
]; | ||
$params = array_merge($this->params, [ | ||
'data_key' => $key, | ||
'cust_id' => uniqid('customer-', true), | ||
'cust_info' => [ | ||
'email' => '[email protected]', | ||
'instructions' => $faker->sentence(mt_rand(3, 6)), | ||
'billing' => $customer, | ||
'shipping' => $customer | ||
], | ||
'cust_info' => $this->customer, | ||
]); | ||
|
||
$response = $this->vault->preauth($params); | ||
|