|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright © 2016 Mozg. All rights reserved. |
|
5
|
|
|
* See LICENSE.txt for license details. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
$path = dirname(dirname(dirname(dirname(dirname(__FILE__))))); |
|
9
|
|
|
$fileName = $path . "/vendor/autoload.php"; |
|
10
|
|
|
//echo $fileName; |
|
11
|
|
|
require_once($fileName); |
|
12
|
|
|
|
|
13
|
|
|
/* |
|
|
|
|
|
|
14
|
|
|
echo ('<h2>spl_autoload_functions()</h2>'); |
|
15
|
|
|
\Zend\Debug\Debug::dump(spl_autoload_functions()); |
|
16
|
|
|
exit; |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
// 20/07/2016 |
|
21
|
|
|
// http://apidocs.braspag.com.br/ |
|
22
|
|
|
// https://developercielo.github.io/Webservice-3.0/ |
|
23
|
|
|
|
|
24
|
|
|
use Mozg\Cielo\ApiService; |
|
25
|
|
|
|
|
26
|
|
|
// |
|
27
|
|
|
|
|
28
|
|
|
function generateGuid(){ |
|
29
|
|
|
$hash = strtoupper(hash('ripemd128', uniqid('', true) . md5(time() . rand(0, time())))); |
|
30
|
|
|
$guid = ''.substr($hash, 0, 8).'-'.substr($hash, 8, 4).'-'.substr($hash, 12, 4).'-'.substr($hash, 16, 4).'-'.substr($hash, 20, 12).''; |
|
31
|
|
|
|
|
32
|
|
|
return $guid; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
// |
|
36
|
|
|
|
|
37
|
|
|
$parameters_cielo = ''; |
|
38
|
|
|
$parameters_braspag = ''; |
|
39
|
|
|
|
|
40
|
|
|
if (isset($_REQUEST['service_options']) && $_REQUEST['service_options'] != '') { |
|
41
|
|
|
$service_options = $_REQUEST['service_options']; |
|
42
|
|
|
|
|
43
|
|
|
$parameters = <<<EOF |
|
44
|
|
|
|
|
45
|
|
|
<p><a href="?service_options=$service_options¶meters=dados_venda_simplificada_credito"> dados_venda_simplificada_credito</a></p> |
|
46
|
|
|
|
|
47
|
|
|
<p><a href="?service_options=$service_options¶meters=dados_venda_completa_credito">dados_venda_completa_credito</a></p> |
|
48
|
|
|
|
|
49
|
|
|
<p><a href="?service_options=$service_options¶meters=dados_venda_autenticada_credito">dados_venda_autenticada_credito</a></p> |
|
50
|
|
|
|
|
51
|
|
|
<p><a href="?service_options=$service_options¶meters=dados_venda_analise_fraude_credito">dados_venda_analise_fraude_credito</a></p> |
|
52
|
|
|
|
|
53
|
|
|
<p><a href="?service_options=$service_options¶meters=dados_venda_simplificada_debito">dados_venda_simplificada_debito</a></p> |
|
54
|
|
|
|
|
55
|
|
|
<p><a href="?service_options=$service_options¶meters=dados_venda_simplificada_boleto">dados_venda_simplificada_boleto</a></p> |
|
56
|
|
|
|
|
57
|
|
|
<p><a href="?service_options=$service_options¶meters=dados_venda_completa_boleto">dados_venda_completa_boleto</a></p> |
|
58
|
|
|
|
|
59
|
|
|
EOF; |
|
60
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
$html = <<<EOF |
|
66
|
|
|
<table border="1"> |
|
67
|
|
|
<tr> |
|
68
|
|
|
<td><h1>Cielo</h1></td> |
|
69
|
|
|
<td><h1>Braspag</h1></td> |
|
70
|
|
|
</tr> |
|
71
|
|
|
<tr> |
|
72
|
|
|
<td> |
|
73
|
|
|
|
|
74
|
|
|
<p><a href="?service_options=service_sandbox_cielo">service_sandbox_cielo</a></p> |
|
75
|
|
|
|
|
76
|
|
|
<p><a href="?service_options=service_production_cielo">service_production_cielo</a></p> |
|
77
|
|
|
|
|
78
|
|
|
$parameters |
|
79
|
|
|
|
|
80
|
|
|
</td> |
|
81
|
|
|
<td> |
|
82
|
|
|
|
|
83
|
|
|
<p><a href="?service_options=service_sandbox_braspag">service_sandbox_braspag</a></p> |
|
84
|
|
|
|
|
85
|
|
|
<p><a href="?service_options=service_production_braspag">service_production_braspag</a></p> |
|
86
|
|
|
|
|
87
|
|
|
$parameters |
|
88
|
|
|
|
|
89
|
|
|
</td> |
|
90
|
|
|
</tr> |
|
91
|
|
|
</table> |
|
92
|
|
|
EOF; |
|
93
|
|
|
|
|
94
|
|
|
echo $html; |
|
95
|
|
|
|
|
96
|
|
|
// |
|
97
|
|
|
|
|
98
|
|
|
$service_production_braspag = [ |
|
99
|
|
|
'headers' => [ |
|
100
|
|
|
'MerchantId' => '1985000c-22f7-4429-9a92-fa5cb27de0e0', |
|
101
|
|
|
'MerchantKey' => 'VJGOUODUJMCLCDAVPIBSSAPMWCTQVQBTHOXRUZFS', |
|
102
|
|
|
'Content-Type' => 'application/json;charset=UTF-8' |
|
103
|
|
|
], |
|
104
|
|
|
'apiUri' => 'https://api.braspag.com.br/v2', |
|
105
|
|
|
'apiQueryUri' => 'https://apiquery.braspag.com.br/v2', |
|
106
|
|
|
]; |
|
107
|
|
|
|
|
108
|
|
|
$service_sandbox_braspag = [ |
|
109
|
|
|
'headers' => [ |
|
110
|
|
|
'MerchantId' => '1985000c-22f7-4429-9a92-fa5cb27de0e0', |
|
111
|
|
|
'MerchantKey' => 'VJGOUODUJMCLCDAVPIBSSAPMWCTQVQBTHOXRUZFS', |
|
112
|
|
|
'Content-Type' => 'application/json;charset=UTF-8' |
|
113
|
|
|
], |
|
114
|
|
|
'apiUri' => 'https://apisandbox.braspag.com.br/v2', |
|
115
|
|
|
'apiQueryUri' => 'https://apiquerysandbox.braspag.com.br/v2', |
|
116
|
|
|
]; |
|
117
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
$service_production_cielo = [ |
|
120
|
|
|
'headers' => [ |
|
121
|
|
|
'MerchantId' => 'a2133427-a0f8-4fe8-b605-6469161e7711', |
|
122
|
|
|
'MerchantKey' => 'XUMUBMGQBPNUAYIESMSHTCNLVTNEXIDPHXQRZYOC', |
|
123
|
|
|
'RequestId' => generateGuid(), |
|
124
|
|
|
'Content-Type' => 'application/json;charset=UTF-8' |
|
125
|
|
|
], |
|
126
|
|
|
'apiUri' => 'https://api.cieloecommerce.cielo.com.br/1', |
|
127
|
|
|
'apiQueryUri' => 'https://apiquery.cieloecommerce.cielo.com.br/1', |
|
128
|
|
|
]; |
|
129
|
|
|
|
|
130
|
|
|
$service_sandbox_cielo = [ |
|
131
|
|
|
'headers' => [ |
|
132
|
|
|
'MerchantId' => 'a2133427-a0f8-4fe8-b605-6469161e7711', |
|
133
|
|
|
'MerchantKey' => 'XUMUBMGQBPNUAYIESMSHTCNLVTNEXIDPHXQRZYOC', |
|
134
|
|
|
'RequestId' => generateGuid(), |
|
135
|
|
|
'Content-Type' => 'application/json;charset=UTF-8' |
|
136
|
|
|
], |
|
137
|
|
|
'apiUri' => 'https://apisandbox.cieloecommerce.cielo.com.br/1', |
|
138
|
|
|
'apiQueryUri' => 'https://apiquerysandbox.cieloecommerce.cielo.com.br/1', |
|
139
|
|
|
]; |
|
140
|
|
|
|
|
141
|
|
|
// |
|
142
|
|
|
|
|
143
|
|
|
$orderId = date('YmdHi'); |
|
144
|
|
|
|
|
145
|
|
|
$dados_venda_simplificada_credito = [ |
|
146
|
|
|
'merchantOrderId' => 2016080600, |
|
147
|
|
|
'customer' => [ |
|
148
|
|
|
'name' => 'Comprador de Testes', |
|
149
|
|
|
], |
|
150
|
|
|
'payment' => [ |
|
151
|
|
|
'type' => 'CreditCard', |
|
152
|
|
|
'amount' => 100, |
|
153
|
|
|
'provider' => 'Cielo', |
|
154
|
|
|
'installments' => 1, |
|
155
|
|
|
'creditCard' => [ |
|
156
|
|
|
'cardNumber' => '4532117080573700', |
|
157
|
|
|
'holder' => 'Test T S Testando', |
|
158
|
|
|
'expirationDate' => '12/2021', |
|
159
|
|
|
'securityCode' => '000', |
|
160
|
|
|
'brand' => 'Visa' |
|
161
|
|
|
] |
|
162
|
|
|
] |
|
163
|
|
|
]; |
|
164
|
|
|
|
|
165
|
|
|
$dados_venda_completa_credito = [ |
|
166
|
|
|
'merchantOrderId' => 2016060900, |
|
167
|
|
|
'customer' => [ |
|
168
|
|
|
'name' => 'Comprador de Testes', |
|
169
|
|
|
'identity' => '11225468954', |
|
170
|
|
|
'identityType' => 'CPF', |
|
171
|
|
|
'email' => '[email protected]', |
|
172
|
|
|
'birthDate' => '1991-01-02', |
|
173
|
|
|
'address' => [ |
|
174
|
|
|
'street' => 'Av. Marechal Câmara', |
|
175
|
|
|
'number' => 160, |
|
176
|
|
|
'complement' => 'Sala 934', |
|
177
|
|
|
'zipCode' => '20020-080', |
|
178
|
|
|
'district' => 'Centro', |
|
179
|
|
|
'city' => 'Rio de Janeiro', |
|
180
|
|
|
'state' => 'RJ', |
|
181
|
|
|
'country' => 'BRA', |
|
182
|
|
|
], |
|
183
|
|
|
'deliveryAddress' => [ |
|
184
|
|
|
'street' => 'Av. Marechal Câmara', |
|
185
|
|
|
'number' => 160, |
|
186
|
|
|
'complement' => 'Sala 934', |
|
187
|
|
|
'zipCode' => '20020-080', |
|
188
|
|
|
'district' => 'Centro', |
|
189
|
|
|
'city' => 'Rio de Janeiro', |
|
190
|
|
|
'state' => 'RJ', |
|
191
|
|
|
'country' => 'BRA', |
|
192
|
|
|
] |
|
193
|
|
|
], |
|
194
|
|
|
'payment' => [ |
|
195
|
|
|
'type' => 'CreditCard', |
|
196
|
|
|
'amount' => 100, |
|
197
|
|
|
'currency' => 'BRL', |
|
198
|
|
|
'country' => 'BRA', |
|
199
|
|
|
'provider' => 'Cielo', |
|
200
|
|
|
'serviceTaxAmount' => 0, |
|
201
|
|
|
'installments' => 1, |
|
202
|
|
|
'interest' => 'ByMerchant', |
|
203
|
|
|
'capture' => true, |
|
204
|
|
|
'authenticate' => false, |
|
205
|
|
|
'softDescriptor' => 'tst', |
|
206
|
|
|
'creditCard' => [ |
|
207
|
|
|
'cardNumber' => '4532117080573700', |
|
208
|
|
|
'holder' => 'Test T S Testando', |
|
209
|
|
|
'expirationDate' => '12/2021', |
|
210
|
|
|
'securityCode' => '000', |
|
211
|
|
|
'saveCard' => false, |
|
212
|
|
|
'brand' => 'Visa', |
|
213
|
|
|
], |
|
214
|
|
|
'extraDataCollection' => [ |
|
215
|
|
|
[ |
|
216
|
|
|
'name' => 'NomeDoCampo', |
|
217
|
|
|
'value' => '1234567' |
|
218
|
|
|
] |
|
219
|
|
|
] |
|
220
|
|
|
] |
|
221
|
|
|
]; |
|
222
|
|
|
|
|
223
|
|
|
$dados_venda_autenticada_credito = [ |
|
224
|
|
|
'merchantOrderId' => 2016080600, |
|
225
|
|
|
'customer' => [ |
|
226
|
|
|
'name' => 'Comprador de Testes', |
|
227
|
|
|
], |
|
228
|
|
|
'payment' => [ |
|
229
|
|
|
'type' => 'CreditCard', |
|
230
|
|
|
'amount' => 100, |
|
231
|
|
|
'provider' => 'Cielo', |
|
232
|
|
|
'installments' => 1, |
|
233
|
|
|
'authenticate' => true, |
|
234
|
|
|
'returnUrl' => 'http://www.braspag.com.br/', |
|
235
|
|
|
'creditCard' => [ |
|
236
|
|
|
'cardNumber' => '4532117080573700', |
|
237
|
|
|
'holder' => 'Test T S Testando', |
|
238
|
|
|
'expirationDate' => '12/2021', |
|
239
|
|
|
'securityCode' => '000', |
|
240
|
|
|
'brand' => 'Visa' |
|
241
|
|
|
] |
|
242
|
|
|
] |
|
243
|
|
|
]; |
|
244
|
|
|
|
|
245
|
|
|
$dados_venda_analise_fraude_credito = [ |
|
246
|
|
|
'merchantOrderId' => 2016060900, |
|
247
|
|
|
'customer' => [ |
|
248
|
|
|
'name' => 'Comprador de Testes', |
|
249
|
|
|
'identity' => '11225468954', |
|
250
|
|
|
'identityType' => 'CPF', |
|
251
|
|
|
'email' => '[email protected]', |
|
252
|
|
|
'birthDate' => '1991-01-02', |
|
253
|
|
|
'address' => [ |
|
254
|
|
|
'street' => 'Av. Marechal Câmara', |
|
255
|
|
|
'number' => 160, |
|
256
|
|
|
'complement' => 'Sala 934', |
|
257
|
|
|
'zipCode' => '20020-080', |
|
258
|
|
|
'district' => 'Centro', |
|
259
|
|
|
'city' => 'Rio de Janeiro', |
|
260
|
|
|
'state' => 'RJ', |
|
261
|
|
|
'country' => 'BRA', |
|
262
|
|
|
], |
|
263
|
|
|
'deliveryAddress' => [ |
|
264
|
|
|
'street' => 'Av. Marechal Câmara', |
|
265
|
|
|
'number' => 160, |
|
266
|
|
|
'complement' => 'Sala 934', |
|
267
|
|
|
'zipCode' => '20020-080', |
|
268
|
|
|
'district' => 'Centro', |
|
269
|
|
|
'city' => 'Rio de Janeiro', |
|
270
|
|
|
'state' => 'RJ', |
|
271
|
|
|
'country' => 'BRA', |
|
272
|
|
|
] |
|
273
|
|
|
], |
|
274
|
|
|
'payment' => [ |
|
275
|
|
|
'type' => 'CreditCard', |
|
276
|
|
|
'amount' => 100, |
|
277
|
|
|
'currency' => 'BRL', |
|
278
|
|
|
'country' => 'BRA', |
|
279
|
|
|
'provider' => 'Cielo', |
|
280
|
|
|
'serviceTaxAmount' => 0, |
|
281
|
|
|
'installments' => 1, |
|
282
|
|
|
'interest' => 'ByMerchant', |
|
283
|
|
|
'capture' => false, |
|
284
|
|
|
'authenticate' => false, |
|
285
|
|
|
'softDescriptor' => 'tst', |
|
286
|
|
|
'creditCard' => [ |
|
287
|
|
|
'cardNumber' => '4532117080573700', |
|
288
|
|
|
'holder' => 'Test T S Testando', |
|
289
|
|
|
'expirationDate' => '12/2021', |
|
290
|
|
|
'securityCode' => '000', |
|
291
|
|
|
'saveCard' => false, |
|
292
|
|
|
'brand' => 'Visa', |
|
293
|
|
|
], |
|
294
|
|
|
'extraDataCollection' => [ |
|
295
|
|
|
[ |
|
296
|
|
|
'name' => 'NomeDoCampo', |
|
297
|
|
|
'value' => '1234567' |
|
298
|
|
|
] |
|
299
|
|
|
], |
|
300
|
|
|
'fraudAnalysis' => [ |
|
301
|
|
|
'sequence' => 'AnalyseFirst', |
|
302
|
|
|
'sequenceCriteria' => 'Always', |
|
303
|
|
|
'fingerprintId' => '074c1ee676ed4998ab66491013c565e2', |
|
304
|
|
|
'captureOnLowRisk' => false, |
|
305
|
|
|
'voidOnHighRisk' => true, |
|
306
|
|
|
'browser' => [ |
|
307
|
|
|
'cookieAccepted' => false, |
|
308
|
|
|
'email' => '[email protected]', |
|
309
|
|
|
'ipAddress' => '200.242.30.253', |
|
310
|
|
|
'type' => 'Chrome', |
|
311
|
|
|
], |
|
312
|
|
|
'cart' => [ |
|
313
|
|
|
'isGift' => false, |
|
314
|
|
|
'returnsAccepted' => true, |
|
315
|
|
|
'items' => [ |
|
316
|
|
|
[ |
|
317
|
|
|
'giftCategory' => 'undefined', |
|
318
|
|
|
'hostHedge' => 'Off', |
|
319
|
|
|
'nonSensicalHedge' => 'Off', |
|
320
|
|
|
'obscenitiesHedge' => 'Off', |
|
321
|
|
|
'phoneHedge' => 'Off', |
|
322
|
|
|
'name' => 'ItemTeste', |
|
323
|
|
|
'quantity' => 1, |
|
324
|
|
|
'sku' => '201411170235134521346', |
|
325
|
|
|
'unitPrice' => 123, |
|
326
|
|
|
'risk' => 'High', |
|
327
|
|
|
'timeHedge' => 'Normal', |
|
328
|
|
|
'type' => 'AdultContent', |
|
329
|
|
|
'velocityHedge' => 'High', |
|
330
|
|
|
'passenger' => [ |
|
331
|
|
|
'email' => '[email protected]', |
|
332
|
|
|
'identity' => '11225468954', |
|
333
|
|
|
'name' => 'Comprador Accepted', |
|
334
|
|
|
'rating' => 'Adult', |
|
335
|
|
|
'phone' => '987654321', |
|
336
|
|
|
'status' => 'Accepted' |
|
337
|
|
|
] |
|
338
|
|
|
] |
|
339
|
|
|
] |
|
340
|
|
|
], |
|
341
|
|
|
'merchantDefinedFields' => [ |
|
342
|
|
|
[ |
|
343
|
|
|
'id' => '95', |
|
344
|
|
|
'value' => 'Eu defini isto' |
|
345
|
|
|
] |
|
346
|
|
|
], |
|
347
|
|
|
'shipping' => [ |
|
348
|
|
|
'addressee' => 'Sr. Comprador Teste', |
|
349
|
|
|
'method' => 'LowCost', |
|
350
|
|
|
'phone' => '987654321' |
|
351
|
|
|
], |
|
352
|
|
|
'travel' => [ |
|
353
|
|
|
'departureTime' => '2016-06-11', |
|
354
|
|
|
'journeyType' => 'Ida', |
|
355
|
|
|
'route' => 'MAO-RJO', |
|
356
|
|
|
'legs' => [ |
|
357
|
|
|
[ |
|
358
|
|
|
'destination' => 'GYN', |
|
359
|
|
|
'origin' => 'VCP' |
|
360
|
|
|
] |
|
361
|
|
|
] |
|
362
|
|
|
] |
|
363
|
|
|
|
|
364
|
|
|
] |
|
365
|
|
|
|
|
366
|
|
|
] |
|
367
|
|
|
|
|
368
|
|
|
]; |
|
369
|
|
|
|
|
370
|
|
|
$dados_venda_simplificada_debito = [ |
|
371
|
|
|
'merchantOrderId' => 2016080600, |
|
372
|
|
|
'customer' => [ |
|
373
|
|
|
'name' => 'Comprador de Testes', |
|
374
|
|
|
], |
|
375
|
|
|
'payment' => [ |
|
376
|
|
|
'type' => 'DebitCard', |
|
377
|
|
|
'amount' => 100, |
|
378
|
|
|
'ReturnUrl' => 'http://www.cielo.com.br', |
|
379
|
|
|
'debitCard' => [ |
|
380
|
|
|
'cardNumber' => '4532117080573700', |
|
381
|
|
|
'holder' => 'Test T S Testando', |
|
382
|
|
|
'expirationDate' => '12/2021', |
|
383
|
|
|
'securityCode' => '000', |
|
384
|
|
|
'brand' => 'Visa' |
|
385
|
|
|
] |
|
386
|
|
|
] |
|
387
|
|
|
]; |
|
388
|
|
|
|
|
389
|
|
|
$dados_venda_simplificada_boleto = [ |
|
390
|
|
|
'merchantOrderId' => 2016080600, |
|
391
|
|
|
'customer' => [ |
|
392
|
|
|
'name' => 'Comprador de Testes', |
|
393
|
|
|
], |
|
394
|
|
|
'payment' => [ |
|
395
|
|
|
'type' => 'Boleto', |
|
396
|
|
|
'amount' => 100, |
|
397
|
|
|
'provider' => 'Bradesco', |
|
398
|
|
|
] |
|
399
|
|
|
]; |
|
400
|
|
|
|
|
401
|
|
|
$dados_venda_completa_boleto = [ |
|
402
|
|
|
'merchantOrderId' => 2016080600, |
|
403
|
|
|
'customer' => [ |
|
404
|
|
|
'name' => 'Comprador de Testes', |
|
405
|
|
|
/*'identity' => '11225468954', |
|
|
|
|
|
|
406
|
|
|
'identityType' => 'CPF', |
|
407
|
|
|
'email' => '[email protected]', |
|
408
|
|
|
'birthDate' => '1991-01-02', |
|
409
|
|
|
'address' => [ |
|
410
|
|
|
'street' => 'Av. Marechal Câmara', |
|
411
|
|
|
'number' => 160, |
|
412
|
|
|
'complement' => 'Sala 934', |
|
413
|
|
|
'zipCode' => '20020-080', |
|
414
|
|
|
'district' => 'Centro', |
|
415
|
|
|
'city' => 'Rio de Janeiro', |
|
416
|
|
|
'state' => 'RJ', |
|
417
|
|
|
'country' => 'BRA', |
|
418
|
|
|
], |
|
419
|
|
|
'deliveryAddress' => [ |
|
420
|
|
|
'street' => 'Av. Marechal Câmara', |
|
421
|
|
|
'number' => 160, |
|
422
|
|
|
'complement' => 'Sala 934', |
|
423
|
|
|
'zipCode' => '20020-080', |
|
424
|
|
|
'district' => 'Centro', |
|
425
|
|
|
'city' => 'Rio de Janeiro', |
|
426
|
|
|
'state' => 'RJ', |
|
427
|
|
|
'country' => 'BRA', |
|
428
|
|
|
]*/ |
|
429
|
|
|
], |
|
430
|
|
|
'payment' => [ |
|
431
|
|
|
'type' => 'Boleto', |
|
432
|
|
|
'amount' => 100, |
|
433
|
|
|
'provider' => 'Bradesco', |
|
434
|
|
|
'Address' => 'Rua Teste', |
|
435
|
|
|
'BoletoNumber' => '123', |
|
436
|
|
|
'Assignor' => 'Empresa Teste', |
|
437
|
|
|
'Demonstrative' => 'Desmonstrative Teste', |
|
438
|
|
|
'ExpirationDate' => '2015-01-05', |
|
439
|
|
|
'Identification' => '11884926754', |
|
440
|
|
|
'Instructions' => 'Aceitar somente até a data de vencimento, após essa data juros de 1% dia.' |
|
441
|
|
|
] |
|
442
|
|
|
]; |
|
443
|
|
|
|
|
444
|
|
|
// |
|
445
|
|
|
|
|
446
|
|
|
$service_options = $service_production_braspag; |
|
447
|
|
|
$service_options = $service_sandbox_braspag; |
|
448
|
|
|
$service_options = $service_production_cielo; |
|
449
|
|
|
$service_options = $service_sandbox_cielo; |
|
450
|
|
|
|
|
451
|
|
|
// |
|
452
|
|
|
|
|
453
|
|
|
$parameters = $dados_venda_simplificada_credito; |
|
454
|
|
|
$parameters = $dados_venda_completa_credito; |
|
455
|
|
|
$parameters = $dados_venda_autenticada_credito; |
|
456
|
|
|
$parameters = $dados_venda_analise_fraude_credito; |
|
457
|
|
|
$parameters = $dados_venda_simplificada_debito; |
|
458
|
|
|
$parameters = $dados_venda_simplificada_boleto; |
|
459
|
|
|
$parameters = $dados_venda_completa_boleto; |
|
460
|
|
|
|
|
461
|
|
|
// |
|
462
|
|
|
|
|
463
|
|
|
$service = $service_sandbox_cielo; |
|
464
|
|
|
$parameters = $dados_venda_simplificada_credito; |
|
465
|
|
|
|
|
466
|
|
|
if (isset($_REQUEST['service_options']) && $_REQUEST['service_options'] != '') { |
|
467
|
|
|
$service_options = ${$_REQUEST['service_options']}; |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
if (isset($_REQUEST['parameters']) && $_REQUEST['parameters'] != '') { |
|
471
|
|
|
$parameters = ${$_REQUEST['parameters']}; |
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
|
|
/* |
|
|
|
|
|
|
475
|
|
|
\Zend\Debug\Debug::dump($_REQUEST['service']); |
|
476
|
|
|
\Zend\Debug\Debug::dump(${$_REQUEST['service']}); |
|
477
|
|
|
\Zend\Debug\Debug::dump($service); |
|
478
|
|
|
*/ |
|
479
|
|
|
|
|
480
|
|
|
|
|
481
|
|
|
// |
|
482
|
|
|
|
|
483
|
|
|
echo '<h2>request</h2>'; |
|
484
|
|
|
//\Zend\Debug\Debug::dump($service); |
|
|
|
|
|
|
485
|
|
|
echo '<h2>array</h2>'; |
|
486
|
|
|
\Zend\Debug\Debug::dump($parameters); |
|
487
|
|
|
echo '<h2>json</h2>'; |
|
488
|
|
|
\Zend\Debug\Debug::dump(\json_encode($parameters)); |
|
489
|
|
|
|
|
490
|
|
|
echo '<h2>authorize</h2>'; |
|
491
|
|
|
|
|
492
|
|
|
$service = new ApiService($service_options); |
|
493
|
|
|
$response = $service->authorize($parameters); |
|
494
|
|
|
|
|
495
|
|
|
// |
|
496
|
|
|
|
|
497
|
|
|
echo '<h2>response</h2>'; |
|
498
|
|
|
|
|
499
|
|
|
// isValid |
|
500
|
|
|
if (array_key_exists('Payment',$response)) { |
|
501
|
|
|
|
|
502
|
|
|
|
|
503
|
|
|
|
|
504
|
|
|
echo '<h2>isValid</h2>'; |
|
505
|
|
|
\Zend\Debug\Debug::dump($response); |
|
506
|
|
|
|
|
507
|
|
|
$_pspReference = $response['Payment']['PaymentId']; |
|
508
|
|
|
$_self = $response['Payment']['Links'][0]['Href']; |
|
509
|
|
|
$amount = 100; |
|
510
|
|
|
$captureRequest = [ |
|
511
|
|
|
'amount' => $amount, |
|
512
|
|
|
'serviceTaxAmount' => 0 |
|
513
|
|
|
]; |
|
514
|
|
|
|
|
515
|
|
|
|
|
516
|
|
|
\Zend\Debug\Debug::dump($_pspReference); |
|
517
|
|
|
\Zend\Debug\Debug::dump($_self); |
|
518
|
|
|
|
|
519
|
|
|
// |
|
520
|
|
|
|
|
521
|
|
|
echo '<h2>Consulta</h2>'; |
|
522
|
|
|
|
|
523
|
|
|
$response = $service->get($_pspReference); |
|
524
|
|
|
|
|
525
|
|
|
\Zend\Debug\Debug::dump($response); |
|
526
|
|
|
|
|
527
|
|
|
// |
|
528
|
|
|
|
|
529
|
|
|
echo '<h2>Captura</h2>'; |
|
530
|
|
|
|
|
531
|
|
|
$response = $service->capture($_pspReference, $captureRequest); |
|
532
|
|
|
|
|
533
|
|
|
\Zend\Debug\Debug::dump($response); |
|
534
|
|
|
|
|
535
|
|
|
// |
|
536
|
|
|
|
|
537
|
|
|
echo '<h2>Cancela</h2>'; |
|
538
|
|
|
|
|
539
|
|
|
$response = $service->void($_pspReference, $amount); |
|
540
|
|
|
|
|
541
|
|
|
\Zend\Debug\Debug::dump($response); |
|
542
|
|
|
|
|
543
|
|
|
// |
|
544
|
|
|
|
|
545
|
|
|
/* |
|
|
|
|
|
|
546
|
|
|
if($response['payment']['returnCode'] == 6){ |
|
547
|
|
|
printf("Transação autorizada com sucesso. TID=%s\n", $saleArray['payment']['tid']); |
|
548
|
|
|
} |
|
549
|
|
|
*/ |
|
550
|
|
|
|
|
551
|
|
|
} else { |
|
552
|
|
|
|
|
553
|
|
|
echo '<h2>Not isValid</h2>'; |
|
554
|
|
|
\Zend\Debug\Debug::dump($response); |
|
555
|
|
|
|
|
556
|
|
|
} |
|
557
|
|
|
|
|
558
|
|
|
|
|
559
|
|
|
/* |
|
560
|
|
|
|
|
561
|
|
|
curl --request POST "https://apisandbox.braspag.com.br/v2/sales/" --header "Content-Type: application/json" --header "MerchantId: 1985000c-22f7-4429-9a92-fa5cb27de0e0" --header "MerchantKey: VJGOUODUJMCLCDAVPIBSSAPMWCTQVQBTHOXRUZFS" --header "RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --data-binary '{ "MerchantOrderId":"2014111703", "Customer":{ "Name":"Comprador Teste" }, "Payment":{ "Type":"CreditCard", "Amount":15700, "Provider":"Cielo", "Installments":1, "CreditCard":{ "CardNumber":"1234123412341231", "Holder":"Teste Holder", "ExpirationDate":"12/2021", "SecurityCode":"123", "Brand":"Visa" } } }' --verbose |
|
562
|
|
|
|
|
563
|
|
|
|
|
564
|
|
|
curl --request POST "https://apisandbox.cieloecommerce.cielo.com.br/1/sales/" --header "Content-Type: application/json" --header "MerchantId: a2133427-a0f8-4fe8-b605-6469161e7711" --header "MerchantKey: XUMUBMGQBPNUAYIESMSHTCNLVTNEXIDPHXQRZYOC" --header "RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --data-binary '{ |
|
565
|
|
|
"MerchantOrderId":"2014111706", |
|
566
|
|
|
"Customer": |
|
567
|
|
|
{ |
|
568
|
|
|
"Name":"Comprador Teste" |
|
569
|
|
|
}, |
|
570
|
|
|
"Payment": |
|
571
|
|
|
{ |
|
572
|
|
|
"Type":"EletronicTransfer", |
|
573
|
|
|
"Amount":15700, |
|
574
|
|
|
"Provider":"Bradesco", |
|
575
|
|
|
"ReturnUrl":"http://www.cielo.com.br" |
|
576
|
|
|
} |
|
577
|
|
|
}' --verbose |
|
578
|
|
|
|
|
579
|
|
|
*/ |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.