-
Notifications
You must be signed in to change notification settings - Fork 3
/
GatewayTest.php
168 lines (136 loc) · 5.26 KB
/
GatewayTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
namespace Wirecard\Functional;
use Wirecard\Element\Action\BookBack;
use Wirecard\Element\Action\Capture;
use Wirecard\Element\Action\Preauthorization;
use Wirecard\Element\Action\Query;
use Wirecard\Element\Amount;
use Wirecard\Element\BillingAddress;
use Wirecard\Element\CreditCardData;
use Wirecard\Element\Job;
use Wirecard\Element\Request;
use Wirecard\Element\Transaction;
use Wirecard\Element\TrustCenterData;
use Wirecard\Element\WireCard;
class GatewayTest extends GatewayTestCase
{
const SIGNATURE = '56501';
protected function setUp()
{
parent::setUp();
$this->params['auth'] = ['56501', 'TestXAPTER'];
}
/**
* @large
*/
public function testPreauthorizationRequest()
{
$creditCard = new CreditCardData();
$creditCard->creditCardNumber = 4200000000000000;
$creditCard->setExpirationDate('2019-01');
$creditCard->cardHolderName = 'John Doe';
$creditCard->secureCode = 471;
$address = new BillingAddress(
'John',
'Doe',
'550 South Winchester blvd.',
'P.O. Box 850',
'San Jose',
'95128',
'CA',
'US',
'+1(202)555-1234',
'John.Doe@email.com'
);
$trustCenter = new TrustCenterData($address);
$transaction = new Transaction();
$transaction->mode = Transaction::MODE_DEMO;
$transaction->id = '9457892347623478';
$transaction->amount = new Amount(500);
$transaction->currency = 'USD';
$transaction->countryCode = 'US';
$transaction->creditCardData = $creditCard;
$transaction->trustCenterData = $trustCenter;
$preauthorization = new Preauthorization($transaction);
$job = Job::createPreauthorizationJob(self::SIGNATURE, $preauthorization);
$request = new Request($job);
/** @var WireCard $wireCard */
$wireCard = WireCard::createWithRequest($request);
$body = $this->serializer->serialize($wireCard, 'xml');
$response = $this->client->send($this->createRequest($body));
$wireCard = $this->serializer->deserialize($response->getBody(true), 'Wirecard\Element\WireCard', 'xml');
$response = $wireCard->response;
$this->assertTrue($response->isSuccessful());
$this->assertNull($response->getMessage());
return $response->getProcessingGuWid();
}
/**
* @depends testPreauthorizationRequest
* @large
* @param string $guWid
* @return string
*/
public function testCaptureRequest($guWid)
{
$transaction = new Transaction();
$transaction->id = '9457892347623478';
$transaction->guWid = $guWid;
$capture = new Capture($transaction);
$job = Job::createCaptureJob(self::SIGNATURE, $capture);
$request = new Request($job);
$body = $this->serializer->serialize(WireCard::createWithRequest($request), 'xml');
$response = $this->client->send($this->createRequest($body));
/** @var WireCard $wireCard */
$wireCard = $this->serializer->deserialize($response->getBody(true), 'Wirecard\Element\WireCard', 'xml');
$response = $wireCard->response;
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertNull($response->getMessage());
return $wireCard->response->getProcessingGuWid();
}
/**
* @depends testCaptureRequest
* @large
* @param string $guWid
* @return string
*/
public function testQueryRequest($guWid)
{
$transaction = new Transaction();
$transaction->id = '9457892347623478';
$transaction->guWid = $guWid;
$query = new Query($transaction);
$job = Job::createQueryJob(self::SIGNATURE, $query);
$request = new Request($job);
$body = $this->serializer->serialize(WireCard::createWithRequest($request), 'xml');
$response = $this->client->send($this->createRequest($body));
/** @var WireCard $wireCard */
$wireCard = $this->serializer->deserialize($response->getBody(true), 'Wirecard\Element\WireCard', 'xml');
$response = $wireCard->response;
$this->assertTrue($response->isSuccessful());
$this->assertNull($response->getMessage());
}
/**
* @depends testCaptureRequest
* @large
* @param string $guWid
* @return string
*/
public function testBookBackRequest($guWid)
{
$transaction = new Transaction();
$transaction->id = '9457892347623478';
$transaction->guWid = $guWid;
$transaction->amount = new Amount(500);
$bookBack = new BookBack($transaction);
$job = Job::createBookBackJob(self::SIGNATURE, $bookBack);
$request = new Request($job);
$body = $this->serializer->serialize(WireCard::createWithRequest($request), 'xml');
$response = $this->client->send($this->createRequest($body));
/** @var WireCard $wireCard */
$wireCard = $this->serializer->deserialize($response->getBody(true), 'Wirecard\Element\WireCard', 'xml');
$response = $wireCard->response;
$this->assertTrue($response->isSuccessful());
$this->assertNull($response->getMessage());
}
}