From fb5f2abd6df869849677db6a7b71b7edbe1796e3 Mon Sep 17 00:00:00 2001 From: Sena Date: Thu, 3 Sep 2020 14:53:29 -0300 Subject: [PATCH] Workshop commit --- composer.json | 5 +- detail-boleto.php | 251 +++++++++++++++++++++++++++++++++++++ detail.php | 179 +++++++++++++++++++++++++- process_payment/boleto.php | 25 ++++ process_payment/index.php | 32 +++++ 5 files changed, 490 insertions(+), 2 deletions(-) create mode 100644 detail-boleto.php create mode 100644 process_payment/boleto.php create mode 100644 process_payment/index.php diff --git a/composer.json b/composer.json index 3e70409..7b436f8 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,8 @@ { "name": "mp-ecommerce-php", "type": "project", - "require": {} + "require": { + "mercadopago/dx-php": "2.0.0", + "ext-json": "*" + } } diff --git a/detail-boleto.php b/detail-boleto.php new file mode 100644 index 0000000..b8c7bb0 --- /dev/null +++ b/detail-boleto.php @@ -0,0 +1,251 @@ + + + + E-commerce sample + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+

+
+
+

+
+
+
+
Quantity :
+ +
+
+
+
+
+

Detalhe do comprador

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+
+
+

+
+
+
+ +
| Workshop Resource
+
+
+
+ + --> + + \ No newline at end of file diff --git a/detail.php b/detail.php index ade1f5c..6b6f31d 100644 --- a/detail.php +++ b/detail.php @@ -11,6 +11,7 @@ + @@ -44,7 +45,75 @@


- +
+

Detalhe do comprador

+
+
+ + +
+
+ + +
+
+ + +
+
+

Detalhes do cartão

+
+
+ + +
+
+ +
+ + / + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ +
+
+
+
+
@@ -60,5 +129,113 @@ + + \ No newline at end of file diff --git a/process_payment/boleto.php b/process_payment/boleto.php new file mode 100644 index 0000000..d356ebe --- /dev/null +++ b/process_payment/boleto.php @@ -0,0 +1,25 @@ +transaction_amount = (float)$_POST['transactionAmount']; +$payment->description = $_POST['description']; +$payment->payment_method_id = "bolbradesco"; +$payment->payer = array( + "email" => $_POST['email'], + "first_name" => $_POST['nome'], + "last_name" => $_POST['sobrenome'], + "identification" => array( + "type" => $_POST['docType'], + "number" => $_POST['docNumber'] + ), +); + +$payment->save(); +echo $payment->transaction_details->external_resource_url; \ No newline at end of file diff --git a/process_payment/index.php b/process_payment/index.php new file mode 100644 index 0000000..dd186ac --- /dev/null +++ b/process_payment/index.php @@ -0,0 +1,32 @@ +transaction_amount = (float)$_POST['transactionAmount']; + $payment->token = $_POST['token']; + $payment->description = $_POST['description']; + $payment->installments = (int)$_POST['installments']; + $payment->payment_method_id = $_POST['paymentMethodId']; + + $payer = new MercadoPago\Payer(); + $payer->email = $_POST['email']; + $payer->identification = array( + "type" => $_POST['docType'], + "number" => $_POST['docNumber'] + ); + $payment->payer = $payer; + + $payment->save(); + + $response = array( + 'status' => $payment->status, + 'status_detail' => $payment->status_detail, + 'id' => $payment->id + ); + echo json_encode($response); \ No newline at end of file