This repository was archived by the owner on Jul 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexemplo_venda_simplificada.php
More file actions
66 lines (51 loc) · 1.52 KB
/
Copy pathexemplo_venda_simplificada.php
File metadata and controls
66 lines (51 loc) · 1.52 KB
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
<?php
// https://github.com/JotJunior/Braspag-PHP-SDK#venda-simplificada
$path = dirname(dirname(dirname(__FILE__)));
$fileName = $path . "/vendor/autoload.php";
//echo $fileName;
require_once($fileName);
use Braspag\ApiService;
use Braspag\Model\Sale\Sale;
$data = [
'merchantOrderId' => 2016080600,
'customer' => [
'name' => 'Comprador de Testes',
],
'payment' => [
'type' => 'CreditCard',
'amount' => 100,
'provider' => 'Simulado',
'installments' => 1,
'creditCard' => [
'cardNumber' => '4532117080573700',
'holder' => 'Test T S Testando',
'expirationDate' => '12/2021',
'securityCode' => '000',
'brand' => 'Visa'
]
]
];
$sale = new Sale($data);
$service = new ApiService([
'merchantId' => '00000000-0000-0000-0000-000000000000',
'merchantKey' => '0000000000000000000000000000000000000000',
]);
// retorna Braspag\Model\Sale
$result = $service->authorize($sale);
if ($result->isValid()) {
// Braspag\Model\Payment
$payment = $result->getPayment();
// Array do pagamento
$paymentArray = $result->getPayment()->toArray();
// Braspag\Model\Customer
$customer = $result->getCustomer();
// Array do cliente
$customerArray = $result->getCustomer()->toArray();
// Array do pedido completo
$saleArray = $result->toArray();
print_r($saleArray);
} else {
$messages = $result->getMessages();
// mensagens de alerta e erros
print_r($messages);
}