{
"items": [
{
"amount": 2990,
"description": "Chaveiro do Tesseract",
"quantity": 1
}
],
"customer": {
"name": "Tony Stark",
"email": "[email protected] "
},
"payments": [
{
"payment_method": "credit_card",
"credit_card": {
"recurrence": false,
"installments": 1,
"statement_descriptor": "AVENGERS",
"card": {
"number": "4000000000000010",
"holder_name": "Tony Stark",
"exp_month": 1,
"exp_year": 20,
"cvv": "3531",
"billing_address": {
"line_1": "10880, Malibu Point, Malibu Central",
"zip_code": "90265",
"city": "Malibu",
"state": "CA",
"country": "US"
}
}
}
}
]
}
{
"id": "or_57oxkMntecE1P6JO",
"code": "PGW5F69IX6",
"amount": 2990,
"currency": "BRL",
"closed": true,
"items": [
{
"id": "oi_DZlmrdXfXQcmr5kO",
"description": "Chaveiro do Tesseract",
"amount": 2990,
"quantity": 1,
"status": "active",
"created_at": "2019-01-21T18:37:48Z",
"updated_at": "2019-01-21T18:37:48Z",
"order": {
"id": "or_57oxkMntecE1P6JO",
"code": "PGW5F69IX6",
"amount": 2990,
"closed": true,
"created_at": "2019-01-21T18:37:48Z",
"updated_at": "2019-01-21T18:37:48Z",
"closed_at": "2019-01-21T18:37:48Z",
"currency": "BRL",
"status": "paid",
"customer_id": "cus_n3bqEzdsZUmNA7Qp",
"items": [
{
"id": "oi_DZlmrdXfXQcmr5kO",
"description": "Chaveiro do Tesseract",
"amount": 2990,
"quantity": 1,
"status": "active"
}
]
}
}
],
"customer": {
"id": "cus_n3bqEzdsZUmNA7Qp",
"name": "Tony Stark",
"email": "[email protected] ",
"delinquent": false,
"created_at": "2019-01-21T18:36:30Z",
"updated_at": "2019-01-21T18:36:30Z",
"phones": {}
},
"status": "paid",
"created_at": "2019-01-21T18:37:48Z",
"updated_at": "2019-01-21T18:37:48Z",
"closed_at": "2019-01-21T18:37:48Z",
"charges": [
{
"id": "ch_PNbX8jDIPuL1p5nM",
"code": "PGW5F69IX6",
"amount": 2990,
"paid_amount": 2990,
"status": "paid",
"currency": "BRL",
"payment_method": "credit_card",
"paid_at": "2019-01-21T18:37:48Z",
"created_at": "2019-01-21T18:37:48Z",
"updated_at": "2019-01-21T18:37:48Z",
"customer": {
"id": "cus_n3bqEzdsZUmNA7Qp",
"name": "Tony Stark",
"email": "[email protected] ",
"delinquent": false,
"created_at": "2019-01-21T18:36:30Z",
"updated_at": "2019-01-21T18:36:30Z",
"phones": {}
},
"last_transaction": {
"id": "tran_G1byLaJUXHm5Eg4R",
"transaction_type": "credit_card",
"gateway_id": "82c0acb3-75b0-48b8-a3ac-0e51c4b3744c",
"amount": 2990,
"status": "captured",
"success": true,
"installments": 1,
"statement_descriptor": "AVENGERS",
"acquirer_tid": "a4cf3de1-beb2-4724-822d-ac7ad14fa306",
"acquirer_nsu": "a4cf3de1-beb2-4724-822d-ac7ad14fa306",
"acquirer_auth_code": "903",
"acquirer_message": "Transação capturada com sucesso",
"acquirer_return_code": "00",
"operation_type": "auth_and_capture",
"card": {
"id": "card_apxQeXJsV2fGVwPL",
"first_six_digits": "400000",
"last_four_digits": "0010",
"brand": "Visa",
"holder_name": "Tony Stark",
"exp_month": 1,
"exp_year": 2020,
"status": "active",
"type": "credit",
"created_at": "2019-01-21T18:37:48Z",
"updated_at": "2019-01-21T18:37:48Z",
"billing_address": {
"zip_code": "90265",
"city": "Malibu",
"state": "CA",
"country": "US",
"line_1": "10880, Malibu Point, Malibu Central"
}
},
"created_at": "2019-01-21T18:37:48Z",
"updated_at": "2019-01-21T18:37:48Z",
"gateway_response": {
"code": "200",
"errors": []
}
}
}
],
"checkouts": []
}
//This example was built using MundiAPI-PHP SDK.
//For more information, please refer to https://github.com/mundipagg/MundiAPI-PHP
$secretKey = 'sk_test_4tdVXpseumRmqbo'; //the secret key will be provided by MundiPagg.
$basicAuthPassword = ''; //fill it with an empty string
$apiClient = new \MundiAPILib\MundiAPIClient(
$secretKey,
$basicAuthPassword
);
$orderController = $apiClient->getOrders();
$customer = new \MundiAPILib\Models\CreateCustomerRequest();
$customer->name = "Tony Stark";
$creditCard = new \MundiAPILib\Models\CreateCreditCardPaymentRequest();
$creditCard->capture = true;
$creditCard->installments = 2;
$creditCard->card = new \MundiAPILib\Models\CreateCardRequest();
$creditCard->card->number = "4000000000000010";
$creditCard->card->holderName = "Tony Stark";
$creditCard->card->expMonth = 1;
$creditCard->card->expYear = 2020;
$creditCard->card->cvv = "123";
$request = new \MundiAPILib\Models\CreateOrderRequest();
$request->items = [new \MundiAPILib\Models\CreateOrderItemRequest()];
$request->items[0]->description = "Tesseract Bracelet";
$request->items[0]->quantity = 1;
$request->items[0]->amount = 2990; // this value should be in cents
$request->payments = [new \MundiAPILib\Models\CreatePaymentRequest()];
$request->payments[0]->paymentMethod = "credit_card";
$request->payments[0]->creditCard = $creditCard;
$request->customer = $customer;
$result = $orderController->createOrder($request);
echo json_encode($result, JSON_PRETTY_PRINT);
package examples.order;
import com.mundipagg.api.MundiAPIClient;
import com.mundipagg.api.controllers.OrdersController;
import com.mundipagg.api.http.client.*;
import com.mundipagg.api.models.*;
import java.util.ArrayList;
public class CreateOrderCreditCard {
public static void main(String[] args) {
String basicAuthUserName = "sk_test_4tdVXpseumRmqbo"; // The username to use with basic authentication
String basicAuthPassword = ""; // The password to use with basic authentication
MundiAPIClient client = new MundiAPIClient(basicAuthUserName, basicAuthPassword);
OrdersController orders_controller = new OrdersController();
CreateCustomerRequest customer = new CreateCustomerRequest();
customer.setName("sdk customer order");
customer.setEmail("[email protected] ");
CreateCreditCardPaymentRequest create_credit_card_payment_request = new CreateCreditCardPaymentRequest();
create_credit_card_payment_request.setCapture(true);
create_credit_card_payment_request.setInstallments(2);
create_credit_card_payment_request.setCard(new CreateCardRequest());
create_credit_card_payment_request.getCard().setNumber("4000000000000010");
create_credit_card_payment_request.getCard().setHolderName("Tony Stark");
create_credit_card_payment_request.getCard().setExpMonth(1);
create_credit_card_payment_request.getCard().setExpYear(2020);
create_credit_card_payment_request.getCard().setCvv("123");
CreateOrderRequest request = new CreateOrderRequest();
CreateOrderItemRequest orderItem = new CreateOrderItemRequest();
orderItem.setDescription("Tesseract Bracelet");
orderItem.setQuantity(3);
orderItem.setAmount(1490);
ArrayList<CreateOrderItemRequest> listOrderItem = new ArrayList<CreateOrderItemRequest>();
listOrderItem.add(orderItem);
request.setItems(listOrderItem);
CreatePaymentRequest paymentItem = new CreatePaymentRequest();
paymentItem.setPaymentMethod("credit_card");
paymentItem.setCreditCard(create_credit_card_payment_request);
request.setCustomer(customer);
ArrayList<CreatePaymentRequest> lisPaymentItem = new ArrayList<CreatePaymentRequest>();
lisPaymentItem.add(paymentItem);
request.setPayments(lisPaymentItem);
orders_controller.createOrderAsync(request, new APICallBack<GetOrderResponse>() {
public void onSuccess(HttpContext context, GetOrderResponse response) {
System.out.println("Order credit card create !");
System.out.println("Status response: " + context.getResponse().getStatusCode());
System.out.println("Order result status: " + response.getStatus());
System.out.println("Order id: " + response.getId());
}
public void onFailure(HttpContext context, Throwable error) {
System.out.println("Status response: " + context.getResponse().getStatusCode());
System.out.println(error.getMessage());
error.printStackTrace();
}
});
}
}
from mundiapi.mundiapi_client import MundiapiClient
from mundiapi.models import *
from mundiapi.controllers import *
from mundiapi.exceptions.error_exception import *
MundiapiClient.config.basic_auth_user_name = "SUA_SECRET_KEY:"
orders_controller = orders_controller.OrdersController()
customer = create_customer_request.CreateCustomerRequest()
customer.name = "sdk customer test"
customer.email = "[email protected] "
credit_card = create_credit_card_payment_request.CreateCreditCardPaymentRequest()
credit_card.capture = True
credit_card.installments = 2
credit_card.statement_descriptor = "test descriptor"
credit_card.card = create_card_request.CreateCardRequest()
credit_card.card.number = "4000000000000010"
credit_card.card.holder_name = "Tony Stark"
credit_card.card.exp_month = 1
credit_card.card.exp_year = 2025
credit_card.card.cvv = "123"
request = create_order_request.CreateOrderRequest()
request.items = [create_order_item_request.CreateOrderItemRequest()]
request.items[0].description = "Tesseract Bracelet"
request.items[0].quantity = 3
request.items[0].amount = 1490
request.payments = [create_payment_request.CreatePaymentRequest()]
request.payments[0].payment_method = "credit_card"
request.payments[0].credit_card = credit_card
request.customer = customer
try:
result = orders_controller.create_order(request)
assert result.status == "paid"
print("Order id is: ", result.id)
print("Order result status: ", result.status)
except ErrorException as ex:
print(ex.message)
print("Errors: ", ex.errors)
except Exception as ex:
raise ex