-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2ff604
commit 27347a6
Showing
2 changed files
with
101 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
use Answear\Payum\Model\PaidForInterface; | ||
use Answear\Payum\PayU\Action\ConvertPaymentAction; | ||
use Answear\Payum\PayU\Enum\ModelFields; | ||
use Answear\Payum\PayU\Service\UserIpService; | ||
use Answear\Payum\PayU\Tests\Payment; | ||
use Payum\Core\Model\CreditCard; | ||
|
@@ -41,13 +42,13 @@ public function convertWithLowInfoTest(): void | |
|
||
self::assertSame( | ||
[ | ||
'customerIp' => null, | ||
'totalAmount' => null, | ||
'currencyCode' => null, | ||
'extOrderId' => null, | ||
'description' => null, | ||
'clientEmail' => null, | ||
'clientId' => null, | ||
'customerIp' => null, | ||
'creditCardMaskedNumber' => null, | ||
'validityTime' => 259200, | ||
'configKey' => 'pos2', | ||
|
@@ -107,13 +108,84 @@ public function convertWithFullDataTest(): void | |
|
||
self::assertSame( | ||
[ | ||
'customerIp' => '127.0.0.1', | ||
'totalAmount' => 1001, | ||
'currencyCode' => 'PLN', | ||
'extOrderId' => 'extOrderId', | ||
'description' => 'Some description', | ||
'clientEmail' => '[email protected]', | ||
'clientId' => '2874', | ||
'creditCardMaskedNumber' => $creditCard->getMaskedNumber(), | ||
'validityTime' => 259200, | ||
'configKey' => 'pos2', | ||
'buyer' => [ | ||
'email' => '[email protected]', | ||
'firstName' => 'Firstname', | ||
'lastName' => 'Surname', | ||
'phone' => '123123123', | ||
'customerId' => null, | ||
'extCustomerId' => '2874', | ||
'nin' => null, | ||
'language' => 'pl', | ||
'delivery' => null, | ||
], | ||
'status' => 'NEW', | ||
], | ||
$convert->getResult() | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function convertButKeepCustomerIp(): void | ||
{ | ||
$convertAction = new ConvertPaymentAction(new UserIpService()); | ||
|
||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; | ||
|
||
$creditCard = new CreditCard(); | ||
$creditCard->setMaskedNumber('masked-number'); | ||
|
||
$paidFor = $this->createMock(PaidForInterface::class); | ||
$paidFor->method('getEmail') | ||
->willReturn('[email protected]'); | ||
$paidFor->method('getFirstName') | ||
->willReturn('Firstname'); | ||
$paidFor->method('getSurname') | ||
->willReturn('Surname'); | ||
$paidFor->method('getPhone') | ||
->willReturn('123123123'); | ||
|
||
$payment = new Payment(); | ||
$payment->setTotalAmount(1001); | ||
$payment->setCurrencyCode('PLN'); | ||
$payment->setNumber('extOrderId'); | ||
$payment->setDescription('Some description'); | ||
$payment->setClientEmail('[email protected]'); | ||
$payment->setClientId('2874'); | ||
$payment->setCreditCard($creditCard); | ||
$payment->setLanguage('pl'); | ||
$payment->setConfigKey('pos2'); | ||
$payment->setPaidFor($paidFor); | ||
$payment->setDetails( | ||
[ | ||
ModelFields::CUSTOMER_IP => '111.222.333.444' | ||
] | ||
); | ||
$convert = new Convert($payment, 'array'); | ||
|
||
$convertAction->execute($convert); | ||
|
||
self::assertSame( | ||
[ | ||
'customerIp' => '111.222.333.444', | ||
'totalAmount' => 1001, | ||
'currencyCode' => 'PLN', | ||
'extOrderId' => 'extOrderId', | ||
'description' => 'Some description', | ||
'clientEmail' => '[email protected]', | ||
'clientId' => '2874', | ||
'customerIp' => '127.0.0.1', | ||
'creditCardMaskedNumber' => $creditCard->getMaskedNumber(), | ||
'validityTime' => 259200, | ||
'configKey' => 'pos2', | ||
|