#lamikam

1 messages · Page 1 of 1 (latest)

limber ibexBOT
vapid star
#

Hello

wintry stratus
#

hey

vapid star
#

If you are trying to just share a code snippet then you can put it between three backticks like this

wintry stratus
#

I have a ZIP fie

#

file

vapid star
#

Not sure you can share a ZIP on discord

wintry stratus
#

ok

#

thanks

vapid star
#

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?

wintry stratus
#

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.

vapid star
#

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

wintry stratus
#

how do I do that?

vapid star
#

You use Webhooks

wintry stratus
#

but this is .setOffSession(true) I am expecting a direct charge

vapid star
#

They take multiple days to move to succeeded as they are async

limber ibexBOT
wintry stratus
#

setConfirm(true)
.setOffSession(true) are supposed to ret urn immediate result, no>