Stripe Java : Creating a Customer Programmatically in Stripe Java Failed

21 Views Asked by At

With Java, I'm trying to create a customer in Stripe (Version 2022-11-15). I get this error:

com.stripe.exception.InvalidRequestException Invalid Object....

How can I solve this problem?

Here's the code:

String idempotencyKey = UUID.randomUUID().toString();
RequestOptions requestOptions = RequestOptions.builder().setApiKey(Constantes.STRIPE_KEY_TEST).build();
// CUSTOMER
CustomerCreateParams paramsCustomer = CustomerCreateParams.builder()
    .setEmail("[email protected]")
    .setName("John Doe")
    .putExtraParam("address", "123 avenidad da Saudade CopaCabana RJ")
    .setPaymentMethod("pm_card_br")
    .build();

Customer customer = null;
try {
    customer = Customer.create(paramsCustomer);
    System.out.println("Customer ID: " + customer.getId());
} catch (StripeException e) {
    e.printStackTrace();
}
0

There are 0 best solutions below