-
Notifications
You must be signed in to change notification settings - Fork 92
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 #117 from alberto1el/master
CIM Add ability to create Customer Profile with OpaqueData from Accept.js
- Loading branch information
Showing
5 changed files
with
145 additions
and
14 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 |
---|---|---|
|
@@ -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', | ||
|
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