|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Tests\Gateways\Providers\Romcard; |
|
4
|
|
|
|
|
5
|
|
|
use Paytic\Omnipay\Romcard\Message\PurchaseResponse; |
|
6
|
|
|
use ByTIC\Payments\Gateways\Providers\Romcard\Gateway; |
|
7
|
|
|
use ByTIC\Payments\Gateways\Providers\Romcard\Message\CompletePurchaseRequest; |
|
8
|
|
|
use Paytic\Omnipay\Romcard\Message\SaleRequest; |
|
9
|
|
|
use Paytic\Payments\Tests\Gateways\GatewayTest as AbstractGatewayTest; |
|
10
|
|
|
use ByTIC\Payments\Tests\Fixtures\Records\Gateways\Providers\Romcard\RomcardData; |
|
11
|
|
|
use Paytic\Payments\Tests\Fixtures\Records\PaymentMethods\PaymentMethod; |
|
12
|
|
|
use Http\Discovery\Psr17FactoryDiscovery; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class GatewayTest |
|
16
|
|
|
* @package ByTIC\Payments\Tests\Gateways\Providers\Romcard |
|
17
|
|
|
*/ |
|
18
|
|
|
class GatewayTest extends AbstractGatewayTest |
|
19
|
|
|
{ |
|
20
|
|
|
public function testPurchaseResponse() |
|
21
|
|
|
{ |
|
22
|
|
|
// Debug::debug($this->gateway->getParameters()); |
|
23
|
|
|
$request = $this->gateway->purchaseFromModel($this->purchase); |
|
24
|
|
|
|
|
25
|
|
|
/** @var PurchaseResponse $response */ |
|
26
|
|
|
// Debug::debug($request->getParameters()); |
|
27
|
|
|
$response = $request->send(); |
|
28
|
|
|
self::assertInstanceOf(PurchaseResponse::class, $response); |
|
29
|
|
|
|
|
30
|
|
|
$data = $response->getRedirectData(); |
|
31
|
|
|
self::assertSame('000000060001099', $data['MERCHANT']); |
|
32
|
|
|
|
|
33
|
|
|
$gatewayResponse = $this->client->request( |
|
34
|
|
|
'POST', |
|
35
|
|
|
$response->getRedirectUrl(), |
|
36
|
|
|
['Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8'], |
|
37
|
|
|
Psr17FactoryDiscovery::findStreamFactory()->createStream(http_build_query($data, '', '&')) |
|
38
|
|
|
); |
|
39
|
|
|
self::assertSame(200, $gatewayResponse->getStatusCode()); |
|
40
|
|
|
|
|
41
|
|
|
//Validate first Response |
|
42
|
|
|
$body = $gatewayResponse->getBody()->__toString(); |
|
43
|
|
|
|
|
44
|
|
|
self::assertMatchesRegularExpression('/Tranzactie Aprobata/', $body); |
|
|
|
|
|
|
45
|
|
|
self::assertMatchesRegularExpression('/value="Aproba" name="SEND_BUTTON"/', $body); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testCompletePurchaseRequest() |
|
49
|
|
|
{ |
|
50
|
|
|
/** @var CompletePurchaseRequest $request */ |
|
51
|
|
|
$request = $this->gateway->completePurchase([]); |
|
52
|
|
|
|
|
53
|
|
|
self::assertInstanceOf(CompletePurchaseRequest::class, $request); |
|
54
|
|
|
self::assertInstanceOf(SaleRequest::class, $request->getSaleRequest()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function testIsActive() |
|
58
|
|
|
{ |
|
59
|
|
|
$gateway = new Gateway(); |
|
60
|
|
|
self::assertFalse($gateway->isActive()); |
|
61
|
|
|
|
|
62
|
|
|
$gateway->setTerminal('999999'); |
|
63
|
|
|
$gateway->setKey('999999'); |
|
64
|
|
|
$gateway->setMerchantName('999999'); |
|
65
|
|
|
$gateway->setMerchantEmail('999999'); |
|
66
|
|
|
|
|
67
|
|
|
self::assertFalse($gateway->isActive()); |
|
68
|
|
|
|
|
69
|
|
|
$gateway->setMerchantUrl('9'); |
|
70
|
|
|
|
|
71
|
|
|
self::assertFalse($gateway->isActive()); |
|
72
|
|
|
|
|
73
|
|
|
$gateway->setMerchantUrl('999999'); |
|
74
|
|
|
|
|
75
|
|
|
self::assertTrue($gateway->isActive()); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
protected function setUp() : void |
|
79
|
|
|
{ |
|
80
|
|
|
parent::setUp(); |
|
81
|
|
|
|
|
82
|
|
|
/** @var PaymentMethod $paymentMethod */ |
|
83
|
|
|
$paymentMethod = $this->purchase->getPaymentMethod(); |
|
|
|
|
|
|
84
|
|
|
$paymentMethod->options = trim(RomcardData::getMethodOptions()); |
|
85
|
|
|
|
|
86
|
|
|
$this->purchase->created = date('Y-m-d H:i:s'); |
|
87
|
|
|
|
|
88
|
|
|
$this->gateway = $paymentMethod->getType()->getGateway(); |
|
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.