Skip to content

Commit

Permalink
Merge pull request #2359 from mercadopago/fix/bugs-1605-2
Browse files Browse the repository at this point in the history
fix/bugs-1605-2
  • Loading branch information
hgaldino authored May 16, 2024
2 parents 1300086 + cfef894 commit ba820b5
Showing 1 changed file with 30 additions and 244 deletions.
274 changes: 30 additions & 244 deletions guides/checkout-api-v2/integration-via-core-methods.pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ Incluindo o elemento do tipo `select` com o id: `form-checkout__identificationTy
```
]]]

------------

## Obter métodos de pagamento do cartão

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.
Expand Down Expand Up @@ -403,7 +405,6 @@ Com todas as informações coletadas no backend, envie um POST com os atributos
>
> 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).
----[mla, mlb, mlu, mlc, mpe, mco]----
[[[
```php
===
Expand All @@ -424,8 +425,8 @@ Encontre o status do pagamento no campo _status_.

$payer = new MercadoPago\Payer();
$payer->email = $_POST['email'];
$payer->identification = array(
"type" => $_POST['identificationType'],
$payer->identification = array(----[mla, mlb, mlu, mlc, mpe, mco]----
"type" => $_POST['identificationType'],------------
"number" => $_POST['identificationNumber']
);
$payment->payer = $payer;
Expand Down Expand Up @@ -458,8 +459,8 @@ var payment_data = {
issuer_id: req.body.issuer,
payer: {
email: req.body.email,
identification: {
type: req.body.identificationType,
identification: {----[mla, mlb, mlu, mlc, mpe, mco]----
type: req.body.identificationType,------------
number: req.body.identificationNumber
}
}
Expand All @@ -479,249 +480,32 @@ mercadopago.payment.save(payment_data)
```
```java
===
Encontre o estado do pagamento no campo _status_.
===

PaymentClient client = new PaymentClient();

PaymentCreateRequest paymentCreateRequest =
PaymentCreateRequest.builder()
.transactionAmount(request.getTransactionAmount())
.token(request.getToken())
.description(request.getDescription())
.installments(request.getInstallments())
.paymentMethodId(request.getPaymentMethodId())
.payer(
PaymentPayerRequest.builder()
.email(request.getPayer().getEmail())
.firstName(request.getPayer().getFirstName())
.identification(
IdentificationRequest.builder()
.type(request.getPayer().getIdentification().getType())
.number(request.getPayer().getIdentification().getNumber())
.build())
.build())
.build();

client.create(paymentCreateRequest);

```
```ruby
===
Encontre o status do pagamento no campo _status_.
===
require 'mercadopago'
sdk = Mercadopago::SDK.new('YOUR_ACCESS_TOKEN')

payment_data = {
transaction_amount: params[:transactionAmount].to_f,
token: params[:token],
description: params[:description],
installments: params[:installments].to_i,
payment_method_id: params[:paymentMethodId],
payer: {
email: params[:email],
identification: {
type: params[:identificationType],
number: params[:identificationNumber]
}
}
}

payment_response = sdk.payment.create(payment_data)
payment = payment_response[:response]

puts payment

```
```csharp
===
Encontre o status do pagamento no campo _status_.
===
using System;
using MercadoPago.Client.Common;
using MercadoPago.Client.Payment;
using MercadoPago.Config;
using MercadoPago.Resource.Payment;

MercadoPagoConfig.AccessToken = "YOUR_ACCESS_TOKEN";

var paymentRequest = new PaymentCreateRequest
{
TransactionAmount = decimal.Parse(Request["transactionAmount"]),
Token = Request["token"],
Description = Request["description"],
Installments = int.Parse(Request["installments"]),
PaymentMethodId = Request["paymentMethodId"],
Payer = new PaymentPayerRequest
{
Email = Request["email"],
Identification = new IdentificationRequest
{
Type = Request["identificationType"],
Number = Request["identificationNumber"],
},
},
};

var client = new PaymentClient();
Payment payment = await client.CreateAsync(paymentRequest);

Console.WriteLine(payment.Status);

```
```python
===
Encontre o status do pagamento no campo _status_.
===
import mercadopago
sdk = mercadopago.SDK("ACCESS_TOKEN")

payment_data = {
"transaction_amount": float(request.POST.get("transaction_amount")),
"token": request.POST.get("token"),
"description": request.POST.get("description"),
"installments": int(request.POST.get("installments")),
"payment_method_id": request.POST.get("payment_method_id"),
"payer": {
"email": request.POST.get("email"),
"identification": {
"type": request.POST.get("type"),
"number": request.POST.get("number")
}
}
}

payment_response = sdk.payment().create(payment_data)
payment = payment_response["response"]

print(payment)
```
```curl
===
Encontre o status do pagamento no campo _status_.
===
curl -X POST \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
'https://api.mercadopago.com/v1/payments' \
-d '{
"transaction_amount": 100,
"token": "ff8080814c11e237014c1ff593b57b4d",
"description": "Blue shirt",
"installments": 1,
"payment_method_id": "visa",
"issuer_id": 310,
"payer": {
"email": "[email protected]"
}
}'
```
]]]

------------
----[mlm]----
[[[
```php
===
Encontre o status do pagamento no campo _status_.
===
<?php
require_once 'vendor/autoload.php';

MercadoPago\SDK::setAccessToken("YOUR_ACCESS_TOKEN");

$payment = new MercadoPago\Payment();
$payment->transaction_amount = (float)$_POST['transactionAmount'];
$payment->token = $_POST['token'];
$payment->description = $_POST['description'];
$payment->installments = (int)$_POST['installments'];
$payment->payment_method_id = $_POST['paymentMethodId'];
$payment->issuer_id = (int)$_POST['issuer'];

$payer = new MercadoPago\Payer();
$payer->email = $_POST['email'];
$payer->identification = array(
"number" => $_POST['identificationNumber']
);
$payment->payer = $payer;

$payment->save();
MercadoPago.SDK.setAccessToken("YOUR_ACCESS_TOKEN");

$response = array(
'status' => $payment->status,
'status_detail' => $payment->status_detail,
'id' => $payment->id
);
echo json_encode($response);
Payment payment = new Payment();
payment.setTransactionAmount(Float.valueOf(request.getParameter("transactionAmount")))
.setToken(request.getParameter("token"))
.setDescription(request.getParameter("description"))
.setInstallments(Integer.valueOf(request.getParameter("installments")))
.setPaymentMethodId(request.getParameter("paymentMethodId"));

?>
```
```node
===
Encontre o status do pagamento no campo _status_.
===

var mercadopago = require('mercadopago');
mercadopago.configurations.setAccessToken("YOUR_ACCESS_TOKEN");
Identification identification = new Identification();----[mla, mlb, mlu, mlc, mpe, mco]----
identification.setType(request.getParameter("identificationType"))
.setNumber(request.getParameter("identificationNumber"));------------ ----[mlm]----
identification.setNumber(request.getParameter("identificationNumber"));------------

var payment_data = {
transaction_amount: Number(req.body.transactionAmount),
token: req.body.token,
description: req.body.description,
installments: Number(req.body.installments),
payment_method_id: req.body.paymentMethodId,
issuer_id: req.body.issuer,
payer: {
email: req.body.email,
identification: {
number: req.body.identificationNumber
}
}
};
Payer payer = new Payer();
payer.setEmail(request.getParameter("email"))
.setIdentification(identification);

payment.setPayer(payer);

mercadopago.payment.save(payment_data)
.then(function(response) {
res.status(response.status).json({
status: response.body.status,
status_detail: response.body.status_detail,
id: response.body.id
});
})
.catch(function(error) {
console.error(error)
});
```
```java
===
Encontre o estado do pagamento no campo _status_.
===
payment.save();

PaymentClient client = new PaymentClient();

PaymentCreateRequest paymentCreateRequest =
PaymentCreateRequest.builder()
.transactionAmount(request.getTransactionAmount())
.token(request.getToken())
.description(request.getDescription())
.installments(request.getInstallments())
.paymentMethodId(request.getPaymentMethodId())
.payer(
PaymentPayerRequest.builder()
.email(request.getPayer().getEmail())
.firstName(request.getPayer().getFirstName())
.identification(
IdentificationRequest.builder()
.type(request.getPayer().getIdentification().getType())
.number(request.getPayer().getIdentification().getNumber())
.build())
.build())
.build();

client.create(paymentCreateRequest);
System.out.println(payment.getStatus());

```
```ruby
Expand All @@ -739,7 +523,8 @@ payment_data = {
payment_method_id: params[:paymentMethodId],
payer: {
email: params[:email],
identification: {
identification: {----[mla, mlb, mlu, mlc, mpe, mco]----
type: params[:identificationType],------------
number: params[:identificationNumber]
}
}
Expand Down Expand Up @@ -774,7 +559,8 @@ var paymentRequest = new PaymentCreateRequest
{
Email = Request["email"],
Identification = new IdentificationRequest
{
{----[mla, mlb, mlu, mlc, mpe, mco]----
Type = Request["identificationType"],------------
Number = Request["identificationNumber"],
},
},
Expand All @@ -801,7 +587,8 @@ payment_data = {
"payment_method_id": request.POST.get("payment_method_id"),
"payer": {
"email": request.POST.get("email"),
"identification": {
"identification": {----[mla, mlb, mlu, mlc, mpe, mco]----
"type": request.POST.get("type"), ------------
"number": request.POST.get("number")
}
}
Expand Down Expand Up @@ -837,7 +624,6 @@ curl -X POST \
```
]]]

------------
> WARNING
>
> Importante
Expand Down

0 comments on commit ba820b5

Please sign in to comment.