Android Studio: Transparent Checkout Paid Market

Asked

Viewed 598 times

2

I’m trying to integrate for the first time the transparent checkout for Android Mercadopago.

I already downloaded and put to work in Emulator the latest version of the application https://github.com/mercadopago/px-android.

On the Github page above, it is explained how to integrate the transparent checkout of Mercadopago with only one line of code.

new MercadoPagoCheckout.Builder("public_key", "checkout_preference_id")
    .build()
    .startPayment(activityOrContext, requestCode);

Where public_key we got on the Mercadopago credentials page. But the String checkout_preference_id I don’t know how to create, even though almost at the end of the Github page has a template for how to create it.

Create your preference id

curl -X POST \
     'https://api.mercadopago.com/checkout/preferences?access_token=ACCESS_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{
           "items": [
               {
               "title": "Dummy Item",
               "description": "Multicolor Item",
               "quantity": 1,
               "currency_id": "ARS",
               "unit_price": 10.0
               }
           ],
           "payer": {
               "email": "[email protected]"
           }
     }'

I tried to put a String any in checkout_preference_id, but it didn’t work. It just worked String provided in the Github application example itself:

private static final String DUMMY_PREFERENCE_ID = "243962506-0bb62e22-5c7b-425e-a0a6-c22d0f4758a9";

All other ways to implement presented in the example application require a fake payment confirmation reply.

Due to my little experience with application development, I have no idea how to create and pass this variable.

I appreciate if someone can help create and pass the variable checkout_preference_id.

EDITED

I would also be very grateful if someone could solve the problem of confirmation of fake payment, exemplifying with code.

I think checkout_preference_id can be accessed via Marketplace on a website or maybe when creating a curl using Android webservice. So this part is still a mystery to me.

Regarding the alternative way to create a payment with Mercadopago, we have other arguments to pass:

new MercadoPagoCheckout.Builder("public_key", checkoutPreference, paymentConfiguration)
                .build()
                .startPayment(activityOrContext, requestCode);

Where checkoutPreference allows us to create a custom item to sell.

final Item item = new Item.Builder("Product Title", 1, new BigDecimal(12.3)).setDescription("Product Description").build();
CheckoutPreference checkoutPreference = new CheckoutPreference.Builder(Sites.BRASIL, "[email protected]", Collections.singletonList(item)).setDefaultInstallments(1).build();

paymentConfiguration is where the confirmation of false payment is implemented.

PaymentConfiguration paymentConfiguration = new PaymentConfiguration.Builder(new MyPaymentProcessor()).build();

Where the class MyPaymentProcessor() and other classes on which it depends can be found in the Github example.

  • I have the same problem. It has already solved?

  • Not yet! So far I’ve only been able to implement one fake payment answer, what is already exemplified in the application offered on Github. I already scoured the Internet, emailed Mercadopago support and sent questions to community of Mercadopago and so far nothing.

  • It seems to me that the secret is the first step, creating a server to communicate with the Mercado Pago server to get the preference_id. What seems strange to me.

  • I did a little test. I made a payment POST request, as has https://github.com/mercadopago/px-android and with the answer has an "id" tag, put in the checkout_preference_id and it worked.

  • If possible, could you post a code example of how to perform this task? What method did you use to make the request, Volley?

  • If the problem is with API support, you should consult the API provider directly. If it is something on site scope, It is important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. To better enjoy the site, understand and avoid closures and negativations worth understanding What is the Stack Overflow and read the Stack Overflow Survival Guide (summarized) in Portuguese.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.