#vibha-sharma_api

1 messages ¡ Page 1 of 1 (latest)

hidden jasperBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1288441595099746318

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

dreamy nexus
#

Hi, let me help you with this.

#

What have you tried already?

lethal stump
#

In this doc we can achieve this using session
can you please guide me alternate way ?

#

I would like to do with custom form

dreamy nexus
#

You can select the type of integration you're looking for here:

lethal stump
#

with this method how can we link payment intent with bank account details?
It will create a payment method for this automatically ?

dreamy nexus
#

What do you mean by "link payment intent with bank account details"?

lethal stump
#

I have created payment intent using api and frontend developer have ha client secret key in the response of that api

#

after that a form will open for taking account number and other details ryt?

dreamy nexus
#

Yes, are you seeing a different behavior?

lethal stump
dreamy nexus
#

Please try to implement this following the guide and let me know if you run into any issues.

lethal stump
#

I have created payment indent like that

$paymentIntent = $this->stripe->paymentIntents->create([
'customer' => $customer->id,
'amount' => $request['amount'] * 100, // Amount in the smallest currency unit
'currency' => $request['currency_code'],
'payment_method_types' => ['customer_balance'],
'payment_method_options' => [
'customer_balance' => [
'funding_type' => 'bank_transfer',
'bank_transfer' => [
'type' => 'gb_bank_transfer',
],
],
],
'description' => 'Payment for Order #1234', // Optional description

            ]);

$paymentIntent = $this->stripe->paymentIntents->retrieve($paymentIntent->id);
$confirmedPaymentIntent = $paymentIntent->confirm();
and returning $confirmedPaymentIntent

#

Is it the correct way??

#

for bacs payment for UK

dreamy nexus
#

You have to enable BACS debit in your Dashboard and remove payment_method_types and payment_method_options. This way you will control the available payment method types via Dashboard.

lethal stump
#

$paymentIntent = $this->stripe->paymentIntents->create([
'customer' => $customer->id,
'amount' => $request['amount'] * 100, // Amount in the smallest currency unit
'currency' => $request['currency_code'],
'description' => 'Payment for Order #1234', // Optional description

            ]);

$paymentIntent = $this->stripe->paymentIntents->retrieve($paymentIntent->id);
$confirmedPaymentIntent = $paymentIntent->confirm();

now Its fine?

dreamy nexus
#

Does it work?

hidden jasperBOT
lethal stump
#

const handleSubmit = async (e) => {
e.preventDefault();

if (!stripe || !elements) {
  return; // Stripe.js has not yet loaded.
}

setIsLoading(true);

try {
  const { error, paymentIntent } = await stripe.confirmPayment({
    elements,
    confirmParams: {
      return_url: `${window.location.origin}/new-order-stripe`,
    },
  });

  console.log("PAYMENTINTENT", paymentIntent, error);

  if (error) {
    setMessage(error.message || "An unexpected error occurred.");
  } else if (paymentIntent) {
    switch (paymentIntent.status) {
      case "succeeded":
        setMessage("Payment successful! Thank you!");
        break;
      case "requires_action":
      case "requires_confirmation":
        setMessage("Payment requires additional confirmation.");
        break;
      case "processing":
        setMessage("Payment is processing. Please wait.");
        break;
      case "requires_payment_method":
        setMessage(
          "Payment failed. Please try a different payment method."
        );
        break;
      default:
        setMessage("Payment status unknown. Please contact support.");
    }
  }
} catch (err) {
  console.error("Unexpected error:", err);
  setMessage("An unexpected error occurred.");
} finally {
  setIsLoading(false);
}

};

ConfirmPayment api is showing that failed to load response: connection is closed, cant dispatch pending call to network.getResponseBody
Using paymentElement

chilly yacht
#

That error seems totally unrelated to Bacs payment method really. What is happening when that error is thrown?

lethal stump
#

When the api confirmPayment is called, it is not showing any response

#

and directly it is redirecting to returnUrl without any confirmation

chilly yacht
#

What's the pi_xxx ID?

lethal stump
#

Payment intent id

chilly yacht
#

Yes

lethal stump
#

pi_3Q2sQ9IE5Vvk0efG14iq3z10

chilly yacht
#

Sounds like whatever error you're seeing is being triggered on your return URL page

lethal stump
#

Yes

chilly yacht
#

Hard to know what the issue could be without seeing the code from that page. But I suspect it's unrelated to Stripe

lethal stump
#

but i want to know that

useEffect(() => {
if (!stripePromise) return;

stripePromise.then(async (stripe) => {
  const url = new URL(window.location);
  const clientSecret = url.searchParams.get("payment_intent_client_secret");
  if (clientSecret) {
    const { error, paymentIntent } = await stripe.retrievePaymentIntent(
      clientSecret
    );
    if (paymentIntent) {
      placeOrder(paymentIntent);
    }
  }
});

}, [stripePromise]);

Without this code, will this confirmPayment api not work?

chilly yacht
#

Yes as at that point you're just retrieving the intent post-confirmation. They're completely unrelated really and not required

lethal stump
#

So now tell me then what is the issue, i have given you code

#

Or let me give you my whole code

chilly yacht
#

Seems like there is code on your return_url that is calling confirmPayment again?

lethal stump
#

No

#

as i submit my form then this api is called and i am redirected to this page