Skip to content

Commit ba820b5

Browse files
authored
Merge pull request #2359 from mercadopago/fix/bugs-1605-2
fix/bugs-1605-2
2 parents 1300086 + cfef894 commit ba820b5

File tree

1 file changed

+30
-244
lines changed

1 file changed

+30
-244
lines changed

guides/checkout-api-v2/integration-via-core-methods.pt.md

Lines changed: 30 additions & 244 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ Incluindo o elemento do tipo `select` com o id: `form-checkout__identificationTy
220220
```
221221
]]]
222222

223+
------------
224+
223225
## Obter métodos de pagamento do cartão
224226

225227
Nesta etapa ocorre a validação dos dados dos compradores no momento em que realizam o preenchimento dos campos necessários para efetuar o pagamento. Para que seja possível identificar o meio de pagamento utilizado pelo comprador, insira o código abaixo diretamente no projeto.
@@ -403,7 +405,6 @@ Com todas as informações coletadas no backend, envie um POST com os atributos
403405
>
404406
> Para aumentar as chances de aprovação do pagamento e evitar que a análise antifraude não autorize a transação, recomendamos inserir o máximo de informação sobre o comprador ao realizar a requisição. Para mais detalhes sobre como aumentar as chances de aprovação, veja [Como melhorar a aprovação dos pagamentos](/developers/pt/docs/checkout-api/how-tos/improve-payment-approval).
405407
406-
----[mla, mlb, mlu, mlc, mpe, mco]----
407408
[[[
408409
```php
409410
===
@@ -424,8 +425,8 @@ Encontre o status do pagamento no campo _status_.
424425

425426
$payer = new MercadoPago\Payer();
426427
$payer->email = $_POST['email'];
427-
$payer->identification = array(
428-
"type" => $_POST['identificationType'],
428+
$payer->identification = array(----[mla, mlb, mlu, mlc, mpe, mco]----
429+
"type" => $_POST['identificationType'],------------
429430
"number" => $_POST['identificationNumber']
430431
);
431432
$payment->payer = $payer;
@@ -458,8 +459,8 @@ var payment_data = {
458459
issuer_id: req.body.issuer,
459460
payer: {
460461
email: req.body.email,
461-
identification: {
462-
type: req.body.identificationType,
462+
identification: {----[mla, mlb, mlu, mlc, mpe, mco]----
463+
type: req.body.identificationType,------------
463464
number: req.body.identificationNumber
464465
}
465466
}
@@ -479,249 +480,32 @@ mercadopago.payment.save(payment_data)
479480
```
480481
```java
481482
===
482-
Encontre o estado do pagamento no campo _status_.
483-
===
484-
485-
PaymentClient client = new PaymentClient();
486-
487-
PaymentCreateRequest paymentCreateRequest =
488-
PaymentCreateRequest.builder()
489-
.transactionAmount(request.getTransactionAmount())
490-
.token(request.getToken())
491-
.description(request.getDescription())
492-
.installments(request.getInstallments())
493-
.paymentMethodId(request.getPaymentMethodId())
494-
.payer(
495-
PaymentPayerRequest.builder()
496-
.email(request.getPayer().getEmail())
497-
.firstName(request.getPayer().getFirstName())
498-
.identification(
499-
IdentificationRequest.builder()
500-
.type(request.getPayer().getIdentification().getType())
501-
.number(request.getPayer().getIdentification().getNumber())
502-
.build())
503-
.build())
504-
.build();
505-
506-
client.create(paymentCreateRequest);
507-
508-
```
509-
```ruby
510-
===
511-
Encontre o status do pagamento no campo _status_.
512-
===
513-
require 'mercadopago'
514-
sdk = Mercadopago::SDK.new('YOUR_ACCESS_TOKEN')
515-
516-
payment_data = {
517-
transaction_amount: params[:transactionAmount].to_f,
518-
token: params[:token],
519-
description: params[:description],
520-
installments: params[:installments].to_i,
521-
payment_method_id: params[:paymentMethodId],
522-
payer: {
523-
email: params[:email],
524-
identification: {
525-
type: params[:identificationType],
526-
number: params[:identificationNumber]
527-
}
528-
}
529-
}
530-
531-
payment_response = sdk.payment.create(payment_data)
532-
payment = payment_response[:response]
533-
534-
puts payment
535-
536-
```
537-
```csharp
538-
===
539-
Encontre o status do pagamento no campo _status_.
540-
===
541-
using System;
542-
using MercadoPago.Client.Common;
543-
using MercadoPago.Client.Payment;
544-
using MercadoPago.Config;
545-
using MercadoPago.Resource.Payment;
546-
547-
MercadoPagoConfig.AccessToken = "YOUR_ACCESS_TOKEN";
548-
549-
var paymentRequest = new PaymentCreateRequest
550-
{
551-
TransactionAmount = decimal.Parse(Request["transactionAmount"]),
552-
Token = Request["token"],
553-
Description = Request["description"],
554-
Installments = int.Parse(Request["installments"]),
555-
PaymentMethodId = Request["paymentMethodId"],
556-
Payer = new PaymentPayerRequest
557-
{
558-
Email = Request["email"],
559-
Identification = new IdentificationRequest
560-
{
561-
Type = Request["identificationType"],
562-
Number = Request["identificationNumber"],
563-
},
564-
},
565-
};
566-
567-
var client = new PaymentClient();
568-
Payment payment = await client.CreateAsync(paymentRequest);
569-
570-
Console.WriteLine(payment.Status);
571-
572-
```
573-
```python
574-
===
575-
Encontre o status do pagamento no campo _status_.
576-
===
577-
import mercadopago
578-
sdk = mercadopago.SDK("ACCESS_TOKEN")
579-
580-
payment_data = {
581-
"transaction_amount": float(request.POST.get("transaction_amount")),
582-
"token": request.POST.get("token"),
583-
"description": request.POST.get("description"),
584-
"installments": int(request.POST.get("installments")),
585-
"payment_method_id": request.POST.get("payment_method_id"),
586-
"payer": {
587-
"email": request.POST.get("email"),
588-
"identification": {
589-
"type": request.POST.get("type"),
590-
"number": request.POST.get("number")
591-
}
592-
}
593-
}
594-
595-
payment_response = sdk.payment().create(payment_data)
596-
payment = payment_response["response"]
597-
598-
print(payment)
599-
```
600-
```curl
601-
===
602-
Encontre o status do pagamento no campo _status_.
603-
===
604-
605-
curl -X POST \
606-
-H 'accept: application/json' \
607-
-H 'content-type: application/json' \
608-
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
609-
'https://api.mercadopago.com/v1/payments' \
610-
-d '{
611-
"transaction_amount": 100,
612-
"token": "ff8080814c11e237014c1ff593b57b4d",
613-
"description": "Blue shirt",
614-
"installments": 1,
615-
"payment_method_id": "visa",
616-
"issuer_id": 310,
617-
"payer": {
618-
"email": "[email protected]"
619-
}
620-
}'
621-
622-
```
623-
]]]
624-
625-
------------
626-
----[mlm]----
627-
[[[
628-
```php
629-
===
630483
Encontre o status do pagamento no campo _status_.
631484
===
632-
<?php
633-
require_once 'vendor/autoload.php';
634-
635-
MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");
636-
637-
$payment = new MercadoPago\Payment();
638-
$payment->transaction_amount = (float)$_POST['transactionAmount'];
639-
$payment->token = $_POST['token'];
640-
$payment->description = $_POST['description'];
641-
$payment->installments = (int)$_POST['installments'];
642-
$payment->payment_method_id = $_POST['paymentMethodId'];
643-
$payment->issuer_id = (int)$_POST['issuer'];
644-
645-
$payer = new MercadoPago\Payer();
646-
$payer->email = $_POST['email'];
647-
$payer->identification = array(
648-
"number" => $_POST['identificationNumber']
649-
);
650-
$payment->payer = $payer;
651485

652-
$payment->save();
486+
MercadoPago.SDK.setAccessToken("YOUR_ACCESS_TOKEN");
653487

654-
$response = array(
655-
'status' => $payment->status,
656-
'status_detail' => $payment->status_detail,
657-
'id' => $payment->id
658-
);
659-
echo json_encode($response);
488+
Payment payment = new Payment();
489+
payment.setTransactionAmount(Float.valueOf(request.getParameter("transactionAmount")))
490+
.setToken(request.getParameter("token"))
491+
.setDescription(request.getParameter("description"))
492+
.setInstallments(Integer.valueOf(request.getParameter("installments")))
493+
.setPaymentMethodId(request.getParameter("paymentMethodId"));
660494

661-
?>
662-
```
663-
```node
664-
===
665-
Encontre o status do pagamento no campo _status_.
666-
===
667-
668-
var mercadopago = require('mercadopago');
669-
mercadopago.configurations.setAccessToken("YOUR_ACCESS_TOKEN");
495+
Identification identification = new Identification();----[mla, mlb, mlu, mlc, mpe, mco]----
496+
identification.setType(request.getParameter("identificationType"))
497+
.setNumber(request.getParameter("identificationNumber"));------------ ----[mlm]----
498+
identification.setNumber(request.getParameter("identificationNumber"));------------
670499

671-
var payment_data = {
672-
transaction_amount: Number(req.body.transactionAmount),
673-
token: req.body.token,
674-
description: req.body.description,
675-
installments: Number(req.body.installments),
676-
payment_method_id: req.body.paymentMethodId,
677-
issuer_id: req.body.issuer,
678-
payer: {
679-
email: req.body.email,
680-
identification: {
681-
number: req.body.identificationNumber
682-
}
683-
}
684-
};
500+
Payer payer = new Payer();
501+
payer.setEmail(request.getParameter("email"))
502+
.setIdentification(identification);
503+
504+
payment.setPayer(payer);
685505

686-
mercadopago.payment.save(payment_data)
687-
.then(function(response) {
688-
res.status(response.status).json({
689-
status: response.body.status,
690-
status_detail: response.body.status_detail,
691-
id: response.body.id
692-
});
693-
})
694-
.catch(function(error) {
695-
console.error(error)
696-
});
697-
```
698-
```java
699-
===
700-
Encontre o estado do pagamento no campo _status_.
701-
===
506+
payment.save();
702507

703-
PaymentClient client = new PaymentClient();
704-
705-
PaymentCreateRequest paymentCreateRequest =
706-
PaymentCreateRequest.builder()
707-
.transactionAmount(request.getTransactionAmount())
708-
.token(request.getToken())
709-
.description(request.getDescription())
710-
.installments(request.getInstallments())
711-
.paymentMethodId(request.getPaymentMethodId())
712-
.payer(
713-
PaymentPayerRequest.builder()
714-
.email(request.getPayer().getEmail())
715-
.firstName(request.getPayer().getFirstName())
716-
.identification(
717-
IdentificationRequest.builder()
718-
.type(request.getPayer().getIdentification().getType())
719-
.number(request.getPayer().getIdentification().getNumber())
720-
.build())
721-
.build())
722-
.build();
723-
724-
client.create(paymentCreateRequest);
508+
System.out.println(payment.getStatus());
725509

726510
```
727511
```ruby
@@ -739,7 +523,8 @@ payment_data = {
739523
payment_method_id: params[:paymentMethodId],
740524
payer: {
741525
email: params[:email],
742-
identification: {
526+
identification: {----[mla, mlb, mlu, mlc, mpe, mco]----
527+
type: params[:identificationType],------------
743528
number: params[:identificationNumber]
744529
}
745530
}
@@ -774,7 +559,8 @@ var paymentRequest = new PaymentCreateRequest
774559
{
775560
Email = Request["email"],
776561
Identification = new IdentificationRequest
777-
{
562+
{----[mla, mlb, mlu, mlc, mpe, mco]----
563+
Type = Request["identificationType"],------------
778564
Number = Request["identificationNumber"],
779565
},
780566
},
@@ -801,7 +587,8 @@ payment_data = {
801587
"payment_method_id": request.POST.get("payment_method_id"),
802588
"payer": {
803589
"email": request.POST.get("email"),
804-
"identification": {
590+
"identification": {----[mla, mlb, mlu, mlc, mpe, mco]----
591+
"type": request.POST.get("type"), ------------
805592
"number": request.POST.get("number")
806593
}
807594
}
@@ -837,7 +624,6 @@ curl -X POST \
837624
```
838625
]]]
839626

840-
------------
841627
> WARNING
842628
>
843629
> Importante

0 commit comments

Comments
 (0)