-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:thephpleague/omnipay-authorizenet…
… into issue123 Conflicts: README.md
- Loading branch information
Showing
8 changed files
with
188 additions
and
23 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
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 |
---|---|---|
|
@@ -31,6 +31,18 @@ public function setUp() | |
'forceCardUpdate' => true | ||
); | ||
|
||
$validCard = $this->getValidCard(); | ||
unset($validCard['number'],$validCard['expiryMonth'],$validCard['expiryYear'],$validCard['cvv']); | ||
//remove the actual card data since we are setting opaque values | ||
$this->createCardFromOpaqueDataOptions = array( | ||
'email' => "[email protected]", | ||
'card' => $validCard, | ||
'opaqueDataDescriptor' => 'COMMON.ACCEPT.INAPP.PAYMENT', | ||
'opaqueDataValue' => 'jb2RlIjoiNTB', | ||
'testMode' => true, | ||
'forceCardUpdate' => true | ||
); | ||
|
||
$this->authorizeOptions = array( | ||
'cardReference' => '{"customerProfileId":"28972084","customerPaymentProfileId":"26317840","customerShippingAddressId":"27057149"}', | ||
'amount' => 10.00, | ||
|
@@ -89,6 +101,20 @@ public function testCreateCardSuccess() | |
$this->assertSame('Successful.', $response->getMessage()); | ||
} | ||
|
||
public function testCreateCardFromOpaqueDataSuccess() | ||
{ | ||
$this->setMockHttpResponse(array('CIMCreateCardSuccess.txt','CIMGetPaymentProfileSuccess.txt')); | ||
|
||
$response = $this->gateway->createCard($this->createCardFromOpaqueDataOptions)->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertSame( | ||
'{"customerProfileId":"28972084","customerPaymentProfileId":"26485433"}', | ||
$response->getCardReference() | ||
); | ||
$this->assertSame('Successful.', $response->getMessage()); | ||
} | ||
|
||
public function testShouldCreateCardIfDuplicateCustomerProfileExists() | ||
{ | ||
$this->setMockHttpResponse(array('CIMCreateCardFailureWithDuplicate.txt', 'CIMCreatePaymentProfileSuccess.txt', | ||
|
@@ -104,6 +130,21 @@ public function testShouldCreateCardIfDuplicateCustomerProfileExists() | |
$this->assertSame('Successful.', $response->getMessage()); | ||
} | ||
|
||
public function testShouldCreateCardFromOpaqueDataIfDuplicateCustomerProfileExists() | ||
{ | ||
$this->setMockHttpResponse(array('CIMCreateCardFailureWithDuplicate.txt', 'CIMCreatePaymentProfileSuccess.txt', | ||
'CIMGetProfileSuccess.txt', 'CIMGetPaymentProfileSuccess.txt')); | ||
|
||
$response = $this->gateway->createCard($this->createCardFromOpaqueDataOptions)->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertSame( | ||
'{"customerProfileId":"28775801","customerPaymentProfileId":"26485433"}', | ||
$response->getCardReference() | ||
); | ||
$this->assertSame('Successful.', $response->getMessage()); | ||
} | ||
|
||
public function testShouldUpdateExistingPaymentProfileIfDuplicateExistsAndForceCardUpdateIsSet() | ||
{ | ||
// Duplicate **payment** profile | ||
|
@@ -120,6 +161,17 @@ public function testShouldUpdateExistingPaymentProfileIfDuplicateExistsAndForceC | |
$this->assertSame('Successful.', $response->getMessage()); | ||
} | ||
|
||
public function testDoesntUpdateExistingPaymentProfileFromOpaqueData() | ||
{ | ||
// Duplicate **payment** profile | ||
$this->setMockHttpResponse(array('CIMCreateCardFailureWithDuplicate.txt', 'CIMCreatePaymentProfileFailure.txt', | ||
'CIMGetProfileSuccess.txt', 'CIMUpdatePaymentProfileSuccess.txt', 'CIMGetPaymentProfileSuccess.txt')); | ||
|
||
$response = $this->gateway->createCard($this->createCardFromOpaqueDataOptions)->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
} | ||
|
||
public function testShouldUpdateExistingPaymentProfileIfDuplicateExistsAndMaxPaymentProfileLimitIsMet() | ||
{ | ||
$this->setMockHttpResponse(array('CIMCreateCardFailureWithDuplicate.txt', | ||
|
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 |
---|---|---|
|
@@ -59,4 +59,25 @@ public function testGetDataShouldSetValidationModeToNoneIfNoCvvProvided() | |
$this->assertFalse(isset($data->profile->paymentProfiles->payment->creditCard->cardCode)); | ||
$this->assertEquals(CIMCreatePaymentProfileRequest::VALIDATION_MODE_NONE, $this->request->getValidationMode()); | ||
} | ||
|
||
public function testGetDataOpaqueData() | ||
{ | ||
|
||
$validCard = $this->getValidCard(); | ||
unset($validCard['number'],$validCard['expiryMonth'],$validCard['expiryYear'],$validCard['cvv']); | ||
//remove the actual card data since we are setting opaque values | ||
$this->params = array( | ||
'email' => "[email protected]", | ||
'card' => $validCard, | ||
'opaqueDataDescriptor' => 'COMMON.ACCEPT.INAPP.PAYMENT', | ||
'opaqueDataValue' => 'jb2RlIjoiNTB', | ||
'developerMode' => true | ||
); | ||
$this->request->initialize($this->params); | ||
|
||
$data = $this->request->getData(); | ||
|
||
$this->assertEquals('COMMON.ACCEPT.INAPP.PAYMENT', $data->profile->paymentProfiles->payment->opaqueData->dataDescriptor); | ||
$this->assertEquals('jb2RlIjoiNTB', $data->profile->paymentProfiles->payment->opaqueData->dataValue); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -31,4 +31,25 @@ public function testGetData() | |
$this->assertEquals($card['number'], $data->paymentProfile->payment->creditCard->cardNumber); | ||
$this->assertEquals('testMode', $data->validationMode); | ||
} | ||
|
||
public function testGetDataOpaqueData() | ||
{ | ||
$validCard = $this->getValidCard(); | ||
unset($validCard['number'],$validCard['expiryMonth'],$validCard['expiryYear'],$validCard['cvv']); | ||
//remove the actual card data since we are setting opaque values | ||
$this->request->initialize( | ||
array( | ||
'customerProfileId' => '28775801', | ||
'email' => "[email protected]", | ||
'card' => $validCard, | ||
'opaqueDataDescriptor' => 'COMMON.ACCEPT.INAPP.PAYMENT', | ||
'opaqueDataValue' => 'jb2RlIjoiNTB', | ||
'developerMode' => true | ||
) | ||
); | ||
|
||
$data = $this->request->getData(); | ||
$this->assertEquals('COMMON.ACCEPT.INAPP.PAYMENT', $data->paymentProfile->payment->opaqueData->dataDescriptor); | ||
$this->assertEquals('jb2RlIjoiNTB', $data->paymentProfile->payment->opaqueData->dataValue); | ||
} | ||
} |