|
6 | 6 |
|
7 | 7 | use Answear\Payum\Model\PaidForInterface; |
8 | 8 | use Answear\Payum\PayU\Action\ConvertPaymentAction; |
| 9 | +use Answear\Payum\PayU\Enum\ModelFields; |
9 | 10 | use Answear\Payum\PayU\Service\UserIpService; |
10 | 11 | use Answear\Payum\PayU\Tests\Payment; |
11 | 12 | use Payum\Core\Model\CreditCard; |
@@ -41,13 +42,13 @@ public function convertWithLowInfoTest(): void |
41 | 42 |
|
42 | 43 | self::assertSame( |
43 | 44 | [ |
| 45 | + 'customerIp' => null, |
44 | 46 | 'totalAmount' => null, |
45 | 47 | 'currencyCode' => null, |
46 | 48 | 'extOrderId' => null, |
47 | 49 | 'description' => null, |
48 | 50 | 'clientEmail' => null, |
49 | 51 | 'clientId' => null, |
50 | | - 'customerIp' => null, |
51 | 52 | 'creditCardMaskedNumber' => null, |
52 | 53 | 'validityTime' => 259200, |
53 | 54 | 'configKey' => 'pos2', |
@@ -107,13 +108,84 @@ public function convertWithFullDataTest(): void |
107 | 108 |
|
108 | 109 | self::assertSame( |
109 | 110 | [ |
| 111 | + 'customerIp' => '127.0.0.1', |
| 112 | + 'totalAmount' => 1001, |
| 113 | + 'currencyCode' => 'PLN', |
| 114 | + 'extOrderId' => 'extOrderId', |
| 115 | + 'description' => 'Some description', |
| 116 | + 'clientEmail' => 'email@test.fake', |
| 117 | + 'clientId' => '2874', |
| 118 | + 'creditCardMaskedNumber' => $creditCard->getMaskedNumber(), |
| 119 | + 'validityTime' => 259200, |
| 120 | + 'configKey' => 'pos2', |
| 121 | + 'buyer' => [ |
| 122 | + 'email' => 'email2@test.fake', |
| 123 | + 'firstName' => 'Firstname', |
| 124 | + 'lastName' => 'Surname', |
| 125 | + 'phone' => '123123123', |
| 126 | + 'customerId' => null, |
| 127 | + 'extCustomerId' => '2874', |
| 128 | + 'nin' => null, |
| 129 | + 'language' => 'pl', |
| 130 | + 'delivery' => null, |
| 131 | + ], |
| 132 | + 'status' => 'NEW', |
| 133 | + ], |
| 134 | + $convert->getResult() |
| 135 | + ); |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * @test |
| 140 | + */ |
| 141 | + public function convertButKeepCustomerIp(): void |
| 142 | + { |
| 143 | + $convertAction = new ConvertPaymentAction(new UserIpService()); |
| 144 | + |
| 145 | + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; |
| 146 | + |
| 147 | + $creditCard = new CreditCard(); |
| 148 | + $creditCard->setMaskedNumber('masked-number'); |
| 149 | + |
| 150 | + $paidFor = $this->createMock(PaidForInterface::class); |
| 151 | + $paidFor->method('getEmail') |
| 152 | + ->willReturn('email2@test.fake'); |
| 153 | + $paidFor->method('getFirstName') |
| 154 | + ->willReturn('Firstname'); |
| 155 | + $paidFor->method('getSurname') |
| 156 | + ->willReturn('Surname'); |
| 157 | + $paidFor->method('getPhone') |
| 158 | + ->willReturn('123123123'); |
| 159 | + |
| 160 | + $payment = new Payment(); |
| 161 | + $payment->setTotalAmount(1001); |
| 162 | + $payment->setCurrencyCode('PLN'); |
| 163 | + $payment->setNumber('extOrderId'); |
| 164 | + $payment->setDescription('Some description'); |
| 165 | + $payment->setClientEmail('email@test.fake'); |
| 166 | + $payment->setClientId('2874'); |
| 167 | + $payment->setCreditCard($creditCard); |
| 168 | + $payment->setLanguage('pl'); |
| 169 | + $payment->setConfigKey('pos2'); |
| 170 | + $payment->setPaidFor($paidFor); |
| 171 | + $payment->setDetails( |
| 172 | + [ |
| 173 | + ModelFields::CUSTOMER_IP => '111.222.333.444' |
| 174 | + ] |
| 175 | + ); |
| 176 | + $convert = new Convert($payment, 'array'); |
| 177 | + |
| 178 | + $convertAction->execute($convert); |
| 179 | + |
| 180 | + self::assertSame( |
| 181 | + [ |
| 182 | + 'customerIp' => '111.222.333.444', |
110 | 183 | 'totalAmount' => 1001, |
111 | 184 | 'currencyCode' => 'PLN', |
112 | 185 | 'extOrderId' => 'extOrderId', |
113 | 186 | 'description' => 'Some description', |
114 | 187 | 'clientEmail' => 'email@test.fake', |
115 | 188 | 'clientId' => '2874', |
116 | | - 'customerIp' => '127.0.0.1', |
117 | 189 | 'creditCardMaskedNumber' => $creditCard->getMaskedNumber(), |
118 | 190 | 'validityTime' => 259200, |
119 | 191 | 'configKey' => 'pos2', |
|
0 commit comments