I am following the doc: https://stripe.com/docs/payments/accept-a-payment#android
On server side:
- Created
PaymentIntentCreateParams, I set the currency and amount on this object - Created the
PaymentIntentusingPaymentIntentCreateParams - the
clientSecretKeyis sent to the client (android)
On client side:
- Getting the
PaymentMethodCreateParamsfrom theCardMultilineWidget - Create a
ConfirmPaymentIntentParamsusing thePaymentMethodCreateParamsandclientSecretKey - Using the
stripeobject toconfirmPayment
Here is the payment associated with this transaction:
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) {
}
});
}
