#k1ng

1 messages ยท Page 1 of 1 (latest)

crystal wrenBOT
candid whale
#

๐Ÿ‘‹ Could you share what is the issue you're facing? Is there any error message?

pseudo dirge
#

"Pay now" shows up, client secret stuff is good

#

not sure how to fix

candid whale
#

Can you share your development website, so that I can take a look?

pseudo dirge
#

@candid whale lots of code, so its a bit of pain to send. There are three files dealing with this, and they look exactly like the preview on this
https://stripe.com/docs/payments/quickstart?client=next

Learn how to embed a custom Stripe payment form in your website or application. Build a checkout form with Elements to complete a payment using various payment methods.

#

index has a useffect that hits the endpoin and gets clientsecret. that works

pseudo dirge
candid whale
#

From the code itself, I can't tell which line has an issue. It'll be helpful to share your development website, so that I can check the console log, networks and javascript execution to determine the issue

pseudo dirge
#

@candid whale u mean a link to it?

#

click BUY CREDITS to trigger it

candid whale
#

From the error message:

{
  "error": {
    "message": "Invalid API Key provided: undefined",
    "type": "invalid_request_error"
  }
}
#

Can you double check if you set the public key correctly?

pseudo dirge
#

this part right? const stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY);

candid whale
#

Yes!

#

The stripePromise will then be set in the <Elements/> like this

<Elements stripe={stripePromise} options={options}>
  <CheckoutForm />
</Elements>
pseudo dirge
#

okay so it worked when i copy pasted it manually

#

let me check again one minute

#

@candid whale ok so it work when I enter it as a string but doesn't work with process.env
const stripePromise = loadStripe(${process.env.OPEN_PUBLISHABLE_KEY});

#

do you maybe know why? i don't want to use it as string on client side

candid whale
pseudo dirge
#

got it thank you @candid whale

#

i have one more question

#

I didn't pass in the customer cid anywhere, how am i supposed to check which customer bought the product?

#

stripe.retrievePaymentIntent(clientSecret).then(({ paymentIntent }) => {
switch (paymentIntent.status) {
case "succeeded":
setMessage("Payment succeeded!");
break;
case "processing":
setMessage("Your payment is processing.");
break;
case "requires_payment_method":
setMessage("Your payment was not successful, please try again.");
break;
default:
setMessage("Something went wrong.");
break;
}
});

#

this thing?

candid whale
pseudo dirge
#

got it

#

can i do this for subscriptions? @candid whale

#

instead of routing to a subscription link, keep it like this

candid whale
#

Do you mean you wish to use Payment Element to collect payments instead of using Checkout Session (Stripe hosted payment page)?

pseudo dirge
#

correct

#

but for subscriptions

candid whale
pseudo dirge
#

got it

#

Lastly, is there a way to save payment info?

#

one click checkout

#

@candid whale

candid whale