@@ -220,6 +220,8 @@ Incluindo o elemento do tipo `select` com o id: `form-checkout__identificationTy
220
220
```
221
221
]]]
222
222
223
+ ------------
224
+
223
225
## Obter métodos de pagamento do cartão
224
226
225
227
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
403
405
>
404
406
> 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 ) .
405
407
406
- ----[ mla, mlb, mlu, mlc, mpe, mco] ----
407
408
[[[
408
409
``` php
409
410
===
@@ -424,8 +425,8 @@ Encontre o status do pagamento no campo _status_.
424
425
425
426
$payer = new MercadoPago\Payer();
426
427
$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'],------------
429
430
"number" => $_POST['identificationNumber']
430
431
);
431
432
$payment->payer = $payer;
@@ -458,8 +459,8 @@ var payment_data = {
458
459
issuer_id: req .body .issuer ,
459
460
payer: {
460
461
email: req .body .email ,
461
- identification: {
462
- type: req .body .identificationType ,
462
+ identification: {---- [mla, mlb, mlu, mlc, mpe, mco] ----
463
+ type: req .body .identificationType ,------------
463
464
number: req .body .identificationNumber
464
465
}
465
466
}
@@ -479,249 +480,32 @@ mercadopago.payment.save(payment_data)
479
480
```
480
481
``` java
481
482
===
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
-
619
- }
620
- }'
621
-
622
- ```
623
- ]]]
624
-
625
- ------------
626
- ----[ mlm] ----
627
- [[[
628
- ``` php
629
- ===
630
483
Encontre o status do pagamento no campo _status_.
631
484
===
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;
651
485
652
- $payment->save( );
486
+ MercadoPago . SDK . setAccessToken( " YOUR_ACCESS_TOKEN " );
653
487
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 " ) );
660
494
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" ));------------
670
499
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);
685
505
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();
702
507
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());
725
509
726
510
```
727
511
``` ruby
@@ -739,7 +523,8 @@ payment_data = {
739
523
payment_method_id: params[:paymentMethodId ],
740
524
payer: {
741
525
email: params[:email ],
742
- identification: {
526
+ identification: {---- [mla, mlb, mlu, mlc, mpe, mco]----
527
+ type: params[:identificationType ],------------
743
528
number: params[:identificationNumber ]
744
529
}
745
530
}
@@ -774,7 +559,8 @@ var paymentRequest = new PaymentCreateRequest
774
559
{
775
560
Email = Request [" email" ],
776
561
Identification = new IdentificationRequest
777
- {
562
+ {---- [mla , mlb , mlu , mlc , mpe , mco ]----
563
+ Type = Request [" identificationType" ],------------
778
564
Number = Request [" identificationNumber" ],
779
565
},
780
566
},
@@ -801,7 +587,8 @@ payment_data = {
801
587
" payment_method_id" : request.POST .get(" payment_method_id" ),
802
588
" payer" : {
803
589
" email" : request.POST .get(" email" ),
804
- " identification" : {
590
+ " identification" : {---- [mla, mlb, mlu, mlc, mpe, mco]----
591
+ " type" : request.POST .get(" type" ), ------------
805
592
" number" : request.POST .get(" number" )
806
593
}
807
594
}
@@ -837,7 +624,6 @@ curl -X POST \
837
624
```
838
625
]]]
839
626
840
- ------------
841
627
> WARNING
842
628
>
843
629
> Importante
0 commit comments