-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
411aade
commit 76ea24a
Showing
14 changed files
with
420 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,2 @@ | ||
# Build and Release Folders | ||
bin/ | ||
bin-debug/ | ||
bin-release/ | ||
[Oo]bj/ # FlashDevelop obj | ||
[Bb]in/ # FlashDevelop bin | ||
|
||
# Other files and folders | ||
.settings/ | ||
|
||
# Executables | ||
*.swf | ||
*.air | ||
*.ipa | ||
*.apk | ||
|
||
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` | ||
# should NOT be excluded as they contain compiler settings and other important | ||
# information for Eclipse / Flash Builder. | ||
vendor/ | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"require": { | ||
"mundipagg/mundiapi": "^3.0", | ||
"guzzlehttp/guzzle": "^6.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require ('client.php'); | ||
|
||
try { | ||
|
||
$chargeId = 'ch_id'; | ||
|
||
$response = $client->request('DELETE', 'charges/'.$chargeId); | ||
|
||
$result = json_decode($response->getBody()); | ||
|
||
DumpData($result); | ||
|
||
} catch (Exception $e) { | ||
|
||
DumpData($e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require ('client.php'); | ||
|
||
try { | ||
|
||
$chargeId = 'ch_id'; | ||
|
||
$response = $client->request('POST', 'charges/'.$chargeId.'/capture'); | ||
|
||
$result = json_decode($response->getBody()); | ||
|
||
DumpData($result); | ||
|
||
} catch (Exception $e) { | ||
|
||
DumpData($e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
require ('client.php'); | ||
|
||
try { | ||
|
||
$address = [ | ||
'street' => 'Rua Guilhermina Guinle', | ||
'number' => '272', | ||
'complement' => 'Some information', | ||
'neighborhood' => 'Boatafogo', | ||
'city' => 'Rio de Janeiro', | ||
'state' => 'RJ', | ||
'country' => 'BR', | ||
'zip_code' => '22270060', | ||
'metadata' => [ | ||
'address_attr' => 'data' | ||
] | ||
]; | ||
|
||
$homePhone = [ | ||
'country_code' => '55', | ||
'area_code' => '21', | ||
'number' => '55554444' | ||
]; | ||
|
||
$mobilePhone = [ | ||
'country_code' => '55', | ||
'area_code' => '21', | ||
'number' => '988887777' | ||
]; | ||
|
||
$phones = [ | ||
'home_phone' => $homePhone, | ||
'mobile_phone' => $mobilePhone | ||
]; | ||
|
||
$customer = [ | ||
'address' => $address, | ||
'phones' => $phones, | ||
'code' => 'CUSTOMER_INTEGRATION_CODE', | ||
'type' => 'individual', | ||
'name' => 'Fabiano Couto', | ||
'email' => 'fabianocouto@domain.com', | ||
'document' => '34435132630', // Generated by https://www.geradordecpf.org/ | ||
'gender' => 'male', | ||
'birthdate' => '1982-06-03', | ||
'metadata' => [ | ||
'customer_attr' => 'data' | ||
] | ||
]; | ||
|
||
$creditCard = [ | ||
'number' => '30513940605542', // Generated by https://names.igopaygo.com/credit-card | ||
'holder_name' => 'Fabiano Couto', | ||
'exp_month' => '05', | ||
'exp_year' => '2021', | ||
'cvv' => '038', | ||
'metadata' => [ | ||
'card_attr' => 'data-edt' | ||
] | ||
]; | ||
|
||
$creditCardPayment = [ | ||
'capture' => false, // true for auth and capture | ||
'installments' => 1, | ||
'statement_descriptor' => 'Credit Card Payment', | ||
'card' => $creditCard, | ||
]; | ||
|
||
$payment = [ | ||
'payment_method' => 'credit_card', | ||
'credit_card' => $creditCardPayment, | ||
// 'metadata' => [ | ||
// 'payment_attr' => 'data' | ||
// ] | ||
]; | ||
|
||
$request = [ | ||
'code' => 'CHARGE_INTEGRATION_CODE', | ||
'amount' => '100', // In cents | ||
'currency' => 'BRL', | ||
'due_at' => date('Y-m-d H:i:s', time()), | ||
'customer' => $customer, | ||
'payment' => $payment, | ||
'metadata' => [ | ||
'charge_attr' => 'data' | ||
] | ||
]; | ||
|
||
$response = $client->request('POST', 'charges', ['json' => $request]); | ||
|
||
$result = json_decode($response->getBody()); | ||
|
||
DumpData($result); | ||
|
||
} catch (Exception $e) { | ||
|
||
DumpData($e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require ('client.php'); | ||
|
||
try { | ||
|
||
$chargeId = 'ch_id'; | ||
|
||
$response = $client->request('GET', 'charges/'.$chargeId); | ||
|
||
$result = json_decode($response->getBody()); | ||
|
||
DumpData($result); | ||
|
||
} catch (Exception $e) { | ||
|
||
DumpData($e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
require ('client.php'); | ||
|
||
try { | ||
|
||
$query = [ | ||
'code' => null, // Integration code | ||
'status' => null, // pending, paid, canceled, processing, failed, overpaid ou underpaid | ||
'payment_method' => null, // credit_card, boleto, bank_transfer, safetypay ou voucher | ||
'customer_id' => null, | ||
'order_id' => null, | ||
'created_since' => null, // Date or DateTime string | ||
'created_until' => null, // Date or DateTime string | ||
'page' => 1, | ||
'size' => 10, | ||
]; | ||
|
||
$response = $client->request('GET', 'charges', ['query' => $query]); | ||
|
||
$result = json_decode($response->getBody()); | ||
|
||
DumpData($result); | ||
|
||
} catch (Exception $e) { | ||
|
||
DumpData($e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
const BASIC_AUTH_USER = 'sk_test_id'; | ||
const BASIC_AUTH_PASS = null; | ||
|
||
if (!is_dir(dirname(__FILE__) . '/../vendor')) { | ||
die ('Please, execute composer install.'); | ||
} | ||
|
||
if (empty(BASIC_AUTH_USER)) { | ||
die ('Please, set basic auth user in ' . __FILE__); | ||
} | ||
|
||
function DumpData ($data) | ||
{ | ||
print '<pre>'; | ||
print json_encode((array) $data); | ||
print '</pre>'; | ||
} | ||
|
||
require dirname(__FILE__).'/../vendor/autoload.php'; | ||
|
||
use GuzzleHttp\Promisse; | ||
use GuzzleHttp\Psr7; | ||
use GuzzleHttp\Client; | ||
|
||
$client = new Client([ | ||
'base_uri' => 'https://api.mundipagg.com/core/v1/', | ||
'auth' => [BASIC_AUTH_USER, BASIC_AUTH_PASS] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
require ('client.php'); | ||
|
||
try { | ||
|
||
$charges = $client->getCharges(); | ||
|
||
$result = $charges->cancelCharge('ch_id'); | ||
|
||
DumpData($result); | ||
|
||
} catch (Exception $e) { | ||
|
||
DumpData($e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
require ('client.php'); | ||
|
||
try { | ||
|
||
$charges = $client->getCharges(); | ||
|
||
$result = $charges->captureCharge('ch_id'); | ||
|
||
DumpData($result); | ||
|
||
} catch (Exception $e) { | ||
|
||
DumpData($e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
require ('client.php'); | ||
|
||
try { | ||
|
||
// CUSTOMER | ||
|
||
$createAddressRequest = new MundiAPILib\Models\CreateAddressRequest(); | ||
$createAddressRequest->street = 'Rua Guilhermina Guinle'; | ||
$createAddressRequest->number = '272'; | ||
$createAddressRequest->complement = 'Some information'; | ||
$createAddressRequest->neighborhood = 'Boatafogo'; | ||
$createAddressRequest->city = 'Rio de Janeiro'; | ||
$createAddressRequest->state = 'RJ'; | ||
$createAddressRequest->country = 'BR'; | ||
$createAddressRequest->zipCode = '22270060'; | ||
$createAddressRequest->metadata = ['address_attr' => 'data']; | ||
|
||
$createHomePhoneRequest = new MundiAPILib\Models\CreatePhoneRequest(); | ||
$createHomePhoneRequest->countryCode = '55'; | ||
$createHomePhoneRequest->areaCode = '21'; | ||
$createHomePhoneRequest->number = '55554444'; | ||
|
||
$createMobilePhoneRequest = new MundiAPILib\Models\CreatePhoneRequest(); | ||
$createMobilePhoneRequest->countryCode = '55'; | ||
$createMobilePhoneRequest->areaCode = '21'; | ||
$createMobilePhoneRequest->number = '988887777'; | ||
|
||
$createPhonesRequest = new MundiAPILib\Models\CreatePhonesRequest(); | ||
$createPhonesRequest->homePhone = $createHomePhoneRequest; | ||
$createPhonesRequest->mobilePhone = $createMobilePhoneRequest; | ||
|
||
$createCustomerRequest = new MundiAPILib\Models\CreateCustomerRequest(); | ||
$createCustomerRequest->address = $createAddressRequest; | ||
$createCustomerRequest->phones = $createPhonesRequest; | ||
$createCustomerRequest->code = 'CUSTOMER_INTEGRATION_CODE'; | ||
$createCustomerRequest->type = 'individual'; | ||
$createCustomerRequest->name = 'Fabiano Couto'; | ||
$createCustomerRequest->email = 'fabianocouto@domain.com'; | ||
$createCustomerRequest->document = '34435132630'; // Generated by https://www.geradordecpf.org/ | ||
$createCustomerRequest->gender = 'male'; | ||
$createCustomerRequest->birthdate = '1982-06-03'; | ||
$createCustomerRequest->metadata = ['customer_attr' => 'data']; | ||
|
||
// DUE DATE | ||
|
||
$dueDate = new DateTime('now'); | ||
$dueDate->add(new DateInterval('P5D')); // Add 5 days | ||
|
||
// CREDIT CARD | ||
|
||
$createCardRequest = new MundiAPILib\Models\CreateCardRequest(); | ||
$createCardRequest->number = '30513940605542'; // Generated by https://names.igopaygo.com/credit-card | ||
$createCardRequest->holderName = 'Fabiano Couto'; | ||
$createCardRequest->expMonth = '08'; | ||
$createCardRequest->expYear = '2021'; | ||
$createCardRequest->cvv = '038'; | ||
|
||
$createCreditCardPaymentRequest = new MundiAPILib\Models\CreateCreditCardPaymentRequest(); | ||
$createCreditCardPaymentRequest->card = $createCardRequest; | ||
$createCreditCardPaymentRequest->installments = 1; | ||
$createCreditCardPaymentRequest->capture = true; // true for auth and capture | ||
|
||
$createPaymnentRequest = new MundiAPILib\Models\CreatePaymentRequest(); | ||
$createPaymnentRequest->creditCard = $createCreditCardPaymentRequest; | ||
$createPaymnentRequest->paymentMethod = 'credit_card'; | ||
$createPaymnentRequest->metadata = ['payment_attr' => 'data']; | ||
|
||
// BANK SLIP | ||
|
||
// $createSlipPaymentRequest = new MundiAPILib\Models\CreateBoletoPaymentRequest(); | ||
// $createSlipPaymentRequest->bank = '341'; | ||
// $createSlipPaymentRequest->instructions = 'Favor, não receber após o vencimento.'; | ||
// $createSlipPaymentRequest->dueAt = $dueDate; | ||
// $createSlipPaymentRequest->metadata = ['slip_attr' => 'data']; | ||
|
||
// $createPaymnentRequest = new MundiAPILib\Models\CreatePaymentRequest(); | ||
// $createPaymnentRequest->boleto = $createSlipPaymentRequest; | ||
// $createPaymnentRequest->paymentMethod = 'boleto'; | ||
// $createPaymnentRequest->metadata = ['payment_attr' => 'data']; | ||
|
||
// CHARGE | ||
|
||
$createChargeRequest = new MundiAPILib\Models\CreateChargeRequest(); | ||
$createChargeRequest->customer = $createCustomerRequest; | ||
$createChargeRequest->payment = $createPaymnentRequest; | ||
$createChargeRequest->code = 'CHARGE_INTEGRATION_CODE'; // If not informed, a random code is generated | ||
$createChargeRequest->dueAt = $dueDate; | ||
$createChargeRequest->currency = 'BRL'; | ||
$createChargeRequest->amount = 100; // In cents | ||
$createChargeRequest->metadata = ['charge_attr' => 'data']; | ||
|
||
$charges = $client->getCharges(); | ||
|
||
$result = $charges->createCharge($createChargeRequest); | ||
|
||
DumpData($result); | ||
|
||
} catch (Exception $e) { | ||
|
||
DumpData($e); | ||
} |
Oops, something went wrong.