Skip to content

Conversation

@GianniTie
Copy link
Contributor

Detail

This PR add support for the nodes nodes required to create a CBP Payment and Preferece and add the types to read the attrs of the response body.

Preference

Create preference

...
List<PreferenceItemRequest> items = new ArrayList<>();
items.add(PreferenceItemRequest.builder()
        .title("CBP PRUEBA SDK")
        .description("CBP PRUEBA SDK")
        .quantity(1)
        .unitPrice(new BigDecimal("190"))
        .build());

PreferenceCounterCurrencyRequest counterCurrencyPreference = PreferenceCounterCurrencyRequest.builder()
        .currencyId("USD")
        .build();

PreferenceAmountsRequest preferenceAmounts = PreferenceAmountsRequest.builder()
        .payer(PreferenceUserAmountRequest.builder()
                .currencyId("MXN")
                .transaction(new BigDecimal("190"))
                .build())
        .collector(PreferenceUserAmountRequest.builder()
                .currencyId("USD")
                .transaction(new BigDecimal("10"))
                .build())
        .build();

PreferenceRequest preferenceCreateRequest = PreferenceRequest.builder()
        .items(items)
        .amounts(preferenceAmounts)
        .counterCurrency(counterCurrencyPreference)
        .build();
...

Read preference

{
    ...
    "counter_currency": {
        "currency_id": "USD"
    },
    "amounts": {
        "payer": {
            "currency_id": "MXN",
            "transaction": 190
        },
        "collector": {
            "currency_id": "USD",
            "transaction": 10
        }
    }
    ...
}

Payment

Create payment

...
PaymentPayerRequest payer = PaymentPayerRequest.builder()
        .email("asdasdasdasdfasd@testuser.com")
        .build();

PaymentAmountsRequest amounts = PaymentAmountsRequest.builder()
        .payer(PaymentUserAmountRequest.builder()
                .currencyId("MXN")
                .transaction(new BigDecimal("190.45"))
                .build())
        .collector(PaymentUserAmountRequest.builder()
                .currencyId("USD")
                .transaction(new BigDecimal("10"))
                .build())
        .build();

PaymentCounterCurrencyRequest counterCurrency = PaymentCounterCurrencyRequest.builder()
        .currencyId("USD")
        .build();

PaymentCreateRequest createRequest = PaymentCreateRequest.builder()
        .description("CBP PRUEBA SDK")
        .token("808ba2bd99ce420e8d8acc11960dbff3")
        .installments(1)
        .paymentMethodId("visa")
        .statementDescriptor("Store 123")
        .payer(payer)
        .amounts(amounts)
        .counterCurrency(counterCurrency)
        .build();
...

Read payment

{
    ...
    "counter_currency": {
        "currency_id": "USD"
    },
    "amounts": {
        "payer": {
            "currency_id": "MXN",
            "transaction": 190
        },
        "collector": {
            "currency_id": "USD",
            "transaction": 10
        }
    }
    ...
}

@GianniTie GianniTie marked this pull request as ready for review August 8, 2025 17:44
@aqudsilva aqudsilva merged commit fa7a34a into mercadopago:master Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants