Stripe android, created PaymentIntent on server and confirm it on Android, but created requires_payment_method error

Viewed 929

I am following the doc: https://stripe.com/docs/payments/accept-a-payment#android

On server side:

  1. Created PaymentIntentCreateParams, I set the currency and amount on this object
  2. Created the PaymentIntent using PaymentIntentCreateParams
  3. the clientSecretKey is sent to the client (android)

On client side:

  1. Getting the PaymentMethodCreateParams from the CardMultilineWidget
  2. Create a ConfirmPaymentIntentParams using the PaymentMethodCreateParams and clientSecretKey
  3. Using the stripe object to confirmPayment

Here is the payment associated with this transaction:

enter image description here

Obviously, the payment didn't go through and I don't understand why and how I am getting this status, my payment method is what is on the CardMultilineWidget isn't?

How do I set the payment method on the PaymentIntent?

Server

 @PostMapping("/api/payment")
    @ResponseBody
    public String startPay(@RequestHeader Map<String, String> headers,
                           @RequestParam(name = "currency") String currency,
                           @RequestParam(name = "name") String name) throws Exception{

        PaymentBody paymentBody = new PaymentBody(currency, name);

        PaymentIntentCreateParams createParams = new PaymentIntentCreateParams.Builder()
                .setCurrency(paymentBody.getCurrency())
                .setAmount(100000L)
                .addPaymentMethodType("card")
                .build();

        PaymentIntent intent = PaymentIntent.create(createParams);

        Gson gson = new Gson().newBuilder().setPrettyPrinting().create();

        System.out.println(gson.toJson(intent));

        PaymentResponse paymentResponse = new PaymentResponse(ApiKey.PUBLISHABLE_KEY,
                intent.getClientSecret(),
                intent.getId(),
                intent.getStatus());

        return gson.toJson(paymentResponse);
    }

Client:

 @Override
    public void onPayClicked() {

        mStripeApi.requestPaymentIntent("USD", "Name").enqueue(new Callback<PaymentResponse>() {
            @Override
            public void onResponse(Call<PaymentResponse> call, Response<PaymentResponse> response) {

                PaymentMethodCreateParams paymentMethodCreateParams = mViewMvc.getCardDetails();

                if(paymentMethodCreateParams == null) {
                    return;
                }

                mViewMvc.setResponse(response.body().getResponse());

                ConfirmPaymentIntentParams confirmPaymentIntentParams = ConfirmPaymentIntentParams.
                        createWithPaymentMethodCreateParams(paymentMethodCreateParams, response.body().getClientSecret());

                mStripe.confirmPayment(mFragmentActivity, confirmPaymentIntentParams);

            }

            @Override
            public void onFailure(Call<PaymentResponse> call, Throwable t) {

            }
        });

    }
0 Answers
Related