#lamikam
1 messages · Page 1 of 1 (latest)
Hello
hey
If you are trying to just share a code snippet then you can put it between three backticks like this
Not sure you can share a ZIP on discord
You can drop it in a txt file
Also though if it is just a bunch of code that might not be very helpful
Really you should just share the relevant snippet for whatever you are trying to debug
Or we can start with discussing what is happening and what you are trying to do?
here's the code ``` public static void main(String[] args) {
port(4242);
Dotenv dotenv = Dotenv.load();
Stripe.apiKey = dotenv.get("STRIPE_SECRET_KEY");
staticFiles.externalLocation(
Paths.get(Paths.get("").toAbsolutePath().toString(), dotenv.get("STATIC_DIR")).normalize().toString());
post("/charge-card-off-session", (request, response) -> {
response.type("application/json");
CreatePaymentBody postBody = null;
PaymentIntent paymentIntent = null;
try {
postBody = gson.fromJson(request.body(), CreatePaymentBody.class);
String custID = "cus_MoU1z5D0AhfFLy";```
// PaymentMethodListParams listParams = new PaymentMethodListParams.Builder().setCustomer(customer.getId())
// .setType(PaymentMethodListParams.Type.CARD).build();
// PaymentMethodCollection paymentMethods = PaymentMethod.list(listParams);
PaymentIntentCreateParams createParams = new PaymentIntentCreateParams.Builder().setCurrency("usd")
.setAmount(999L)
.setPaymentMethod("pm_1M4rIHBBKIuAStQqVqulAiF0")
.setCustomer("cus_MoU1z5D0AhfFLy")
.setConfirm(true)
.setOffSession(true)
.addPaymentMethodType("us_bank_account")
.build();
paymentIntent = PaymentIntent.create(createParams);
PaymentIntent details = PaymentIntent.retrieve(paymentIntent.getId());
//extract the charge details. There will always be only one charge object
Charge charge = details.getLatestChargeObject();
System.out.println(charge.toJson());
Charge charge object is null when if should be populdates.
This is a bank debit
Which is an async payment method type
That means the charge isn't created immediately
You have to wait until the PaymentIntent moves to succeeded to retrieve the Charge
how do I do that?
but this is .setOffSession(true) I am expecting a direct charge
That's not how bank debits work. See: https://stripe.com/docs/payments/ach-debit
They take multiple days to move to succeeded as they are async
setConfirm(true)
.setOffSession(true) are supposed to ret urn immediate result, no>