forked from Leojakas/mundipagg-php-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestScript.php
210 lines (168 loc) · 7.05 KB
/
TestScript.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
include_once $_SERVER["DOCUMENT_ROOT"] . "\\MundiPaggServiceConfiguration.php";
include_once $SERVICE_CLIENT . "MundiPaggSoapServiceClient.php";
$ENABLE_WSDL_CACHE = false; // In MundiPaggServiceConfiguration.php
//$client = new MundiPaggSoapServiceClient();
$client = new MundiPaggSoapServiceClient('LOCAL',null,true);
//$client = new MundiPaggSoapServiceClient(null, null, true);
$orderRequest = CreateCreateOrder(); // Creates an order
$orderResponse = $client->CreateOrder($orderRequest);
var_dump($orderResponse);
// var_dump($orderResponse->ErrorReport);
// $manageRequest = CreateManageOrder("fde8193b-583c-41b8-8479-a91ddd70ae00");
// $manageResponse = $client->ManageOrder($manageRequest);
// var_dump ($manageResponse);
// //$retryRequest = CreateRetryOrder($orderResponse->OrderKey);
// $retryRequest = CreateRetryOrder("c4759866-ccaf-4533-a959-ce7c57880886");
// $retryResponse = $client->RetryOrder($retryRequest);
// var_dump($retryResponse);
// $queryRequest = CreateQueryOrder("1708090b-b345-46d1-8af6-e7292f1f4bbb");
// //$queryRequest = CreateQueryOrder("c4759866-ccaf-4533-a959-ce7c57880881"); // Não existe.
// $queryResponse = $client->QueryOrder($queryRequest);
// var_dump($queryResponse, $queryResponse->OrderDataCollection[0]);
// $instantBuyDataRequest = CreateGetInstantBuyData("85126373-6eb2-4b6f-851b-80bd520bccdf");
// $instantBuyDataResponse = $client->GetInstantBuyData($instantBuyDataRequest);
// var_dump($instantBuyDataResponse);
// echo "Request:<br>";
// echo $client->GetRequestData();
// echo "<br><br><br>";
// echo "Response:<br>";
// echo $client->GetResponseData();
// $files = $client->SaveRequestResponseData('C:\\Users\\mriboli\\Desktop\\PHP-SDK XML\\');
// var_dump($files);
exit();
function CreateCreateOrder() {
$orderRequest = new CreateOrderRequest();
//$orderRequest = new stdClass();
// Campos principais do objeto CreateOrderRequest
$orderRequest->CurrencyIsoEnum = "BRL";
$orderRequest->AmountInCents = 9;
$orderRequest->AmountInCentsToConsiderPaid = 9;
$orderRequest->Retries = 0;
//$orderRequest->OrderReference = "SDK-PHP - Teste de Integracao - Matheus AR " . rand(0, 100000) ;
$orderRequest->OrderReference = "";
//$orderRequest->EmailUpdateToBuyerEnum = "No";
$buyer = new Buyer();
$buyer->Email = "[email protected]";
$buyer->GenderEnum = 'M';
$buyer->MobilePhone = '2122465273';
$buyer->Name = "Humberto da Silva";
$buyer->PersonTypeEnum = 'Person';
$buyer->TaxDocumentNumber = '21645798514';
$buyer->TaxDocumentTypeEnum = 'CPF';
$addr1 = new BuyerAddress();
$addr1->AddressTypeEnum = AddressTypeEnum::Residential;
$addr1->City = 'Rio de Janeiro';
$addr1->Complement = 'Apto 203';
$addr1->CountryEnum = CountryEnum::Brazil;
$addr1->Number = 223;
$addr1->State = 'RJ';
$addr1->Street = 'Rua da Quitanda';
$addr1->ZipCode = '14345709';
$addr2 = new BuyerAddress();
$addr2->AddressTypeEnum = AddressTypeEnum::Residential;
$addr2->City = 'Sao Paulo';
$addr2->Complement = 'Apto 501';
$addr2->CountryEnum = CountryEnum::Brazil;
$addr2->Number = 348;
$addr2->State = 'SP';
$addr2->Street = 'Rua da Qualquer Coisa';
$buyer->BuyerAddressCollection = array( $addr1, $addr2 );
$orderRequest->Buyer = $buyer;
//// CARTÃO 1
// Criação de uma transação de cartão de crédito
$ccTransaction1 = new CreditCardTransaction();
$ccTransaction1->AmountInCents = 9;
$ccTransaction1->CreditCardNumber = "518294741544019";
// Número do cartão de crédito
$ccTransaction1->HolderName = "Maria do Carmo";
$ccTransaction1->SecurityCode = 197;
$ccTransaction1->ExpMonth = 10;
$ccTransaction1->ExpYear = 17;
$ccTransaction1->CreditCardBrandEnum = 'Visa';
$ccTransaction1->PaymentMethodCode = 1;
// Define o tipo da autorização
$ccTransaction1->CreditCardOperationEnum = "AuthOnly";
//// CARTÃO 2
// Criação de uma transação de cartão de crédito
$ccTransaction2 = new CreditCardTransaction();
$ccTransaction2->AmountInCents = 20;
$ccTransaction2->CreditCardNumber = "65444454544112";
// Número do cartão de crédito
$ccTransaction2->HolderName = "Jose Farias";
$ccTransaction2->SecurityCode = 546;
$ccTransaction2->ExpMonth = 8;
$ccTransaction2->ExpYear = 19;
$ccTransaction2->CreditCardBrandEnum = 'Mastercard';
$ccTransaction2->PaymentMethodCode = 1;
// Define o tipo da autorização
$ccTransaction1->CreditCardOperationEnum = "AuthOnly";
//// CARTÃO 3
// Criação de uma transação de cartão de crédito
$ccTransaction3 = new CreditCardTransaction();
$ccTransaction3->AmountInCents = 15;
$ccTransaction3->CreditCardNumber = "331211415454441";
// Número do cartão de crédito
$ccTransaction3->HolderName = "Somebody da Silva";
$ccTransaction3->SecurityCode = 523;
$ccTransaction3->ExpMonth = 11;
$ccTransaction3->ExpYear = 17;
$ccTransaction3->CreditCardBrandEnum = 'Elo';
$ccTransaction3->PaymentMethodCode = 1;
// Define o tipo da autorização
$ccTransaction3->CreditCardOperationEnum = "AuthAndCapture";
/// BOLETO 1
// Criação de uma transação por boleto
$boletoTransaction1 = new BoletoTransaction();
$boletoTransaction1->AmountInCents = 3000;
$boletoTransaction1->BankNumber = 789;
$boletoTransaction1->Instructions = "Nao receber apos vencimento.";
$boletoTransaction1->NossoNumero = 47826;
$boletoTransaction1->DaysToAddInBoletoExpirationDate = 5;
/// BOLETO 2
// Criação de uma transação por boleto
$boletoTransaction2 = new BoletoTransaction();
$boletoTransaction2->AmountInCents = 5000;
$boletoTransaction2->BankNumber = 641;
$boletoTransaction2->Instructions = "Nao receber apos vencimento.";
$boletoTransaction2->NossoNumero = 55411;
$boletoTransaction2->DaysToAddInBoletoExpirationDate = 9;
// Adiciona as transações no OrderRequest
$orderRequest->CreditCardTransactionCollection = array ( $ccTransaction1, $ccTransaction2, $ccTransaction3 );
//$orderRequest->BoletoTransactionCollection = array ( $boletoTransaction1/*, $boletoTransaction2*/ );
$shopCart = new ShoppingCart();
$shopCart->FreighCostInCents = 1000;
$shopCartItem = new ShoppingCartItem();
$shopCartItem->Description = "Teste";
$shopCartItem->Name = "Teste";
$shopCartItem->Quantity = 3;
$shopCartItem->TotalCostInCents = 300;
$shopCartItem->UnitCostInCents = 100;
$shopCartItem->ItemReference = "Teste";
$shopCart->ShoppingCartItemCollection = array ( $shopCartItem );
$orderRequest->ShoppingCartCollection = array ( $shopCart );
return $orderRequest;
}
function CreateManageOrder($orderKey) {
$manageRequest = new ManageOrderRequest();
$manageRequest->OrderKey = $orderKey;
//$manageRequest->ManageOrderOperationEnum = ManageOrderOperationEnum::Capture;
$manageRequest->ManageOrderOperationEnum = ManageOrderOperationEnum::Void;
return $manageRequest;
}
function CreateRetryOrder($orderKey) {
$retryRequest = new RetryOrderRequest();
$retryRequest->OrderKey = $orderKey;
return $retryRequest;
}
function CreateQueryOrder($orderKey) {
$queryRequest = new QueryOrderRequest();
$queryRequest->OrderKey = $orderKey;
return $queryRequest;
}
function CreateGetInstantBuyData($buyerKey) {
$instantBuyRequest = new GetInstantBuyDataRequest();
$instantBuyRequest->BuyerKey = $buyerKey;
return $instantBuyRequest;
}
?>