#lyubo_api
1 messages ยท Page 1 of 1 (latest)
๐ 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/1365308550053761044
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
this is the integration and this is the code:
const appearance = {
theme: 'stripe',
variables: {
borderRadius: '36px',
}
}
const expressCheckoutOptions = {
buttonHeight: 50,
buttonTheme: {
applePay: 'white-outline'
}
}
const elements = stripe1.elements({
mode: 'payment',
amount: 100,
currency: 'usd',
appearance,
})
const expressCheckoutElement = elements.create(
'expressCheckout',
expressCheckoutOptions
)
expressCheckoutElement.mount('#express-checkout-element')
I haven't created any server logic, however I assumed Apple pay has it's own server logic
yes
const stripe1 = Stripe('pk_test_51QCPzHJ14oeQYtXPyTPLTyVXQGRwR4TYl6w1zo4Qc9s0FX3WZ7JYddQR0973tQvD3ctTjIZISvqpuBWas42ZWJuZ008jCccZdC');
and I have used grok in order to get https for testing purposes
*ngrok
You can safely confirm the payment - your real card won't be charged.
It fails
Could you please share the PaymentIntent ID pi_xxx?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
this is all my code
I do not have a payment intent here, because I assumed I do not need one? At least in the documentation I didn't see any info about it
Hi ๐
You defintely need a payment intent to collect payment. Sometimes (via checkout or invoices/subscriptions) that might be managed for you, but there is always a payment intent.
If this is all of your code, you appear to be missing the second half of the integration
This will get an Express Checkout Element to appear, but you need to handle completing the payment
Your code goes to step 4 in this guide, roughly
Ok, whenever I create a payment intent, what do I need to put as options here? stripe1.createPaymentMethod({
type: 'card',
card: cardNumber // Ensure cardNumber is a valid Stripe element
}).then(function (result) { type: "card" is for my card and it works great, how about when I use paypal or google pay, or express in general?
oh yeah, this is the documentation I have been looking for
You need to keep going and:
- create the payment intent on your server
- set up a
confirmevent handler on ECE
expressCheckoutElement.on('confirm', async (event) => { ... } - call
stripe.confirmPayment()with the client secret from the payment intent to complete the payment
I assume I can confirm the payment on the backend?
Yes, but that's a little more complicated
You need to use createConfirmationToken like is shown here:
https://docs.stripe.com/elements/express-checkout-element/accept-a-payment?client=html#create-ct
but then you'll use that token on your server to confirm
daaamn I don't get paid enough for this lol
Thanks for your help
I will continue reading the docs
That sequence (create conforimation token, confirm on server with confirmation token) is shown here:
https://docs.stripe.com/payments/finalize-payments-on-the-server?platform=web&type=payment#create-ct
You need to call stripe.createConfirmationToken() using stripe.js, then get the confirmation token, pass that to your server and create/confirm the payment intent passing in that token:
const intent = await stripe.paymentIntents.create({
confirm: true,
// ...
confirmation_token: {{confirmationTokenId}}
});
No, we're not online here on the weekend but you can contact support any time: https://support.stripe.com/contact
// Step 3: Create the PaymentIntent for the cause
$chargeCause = $stripeCause->paymentIntents->create([
'amount' => $amount * 100, // Amount in cents
'currency' => 'bgn', // Bulgarian Lev
'customer' => $customer->id, // Attach the customer
'payment_method' => $paymentMethod, // Use the attached PaymentMethod
'off_session' => true, // Indicates the payment is processed without user interaction
'confirm' => true, // Confirm the payment intent immediately
'metadata' => [
'product_id' => 'prod_RThK3jNdS9Oprf', // Product ID for the cause
'name' => $names,
],
]);
I use php so I just create the payment intent and confirm it on the backend
// Step 1: Create or retrieve a customer in Stripe
$customer = $stripeCause->customers->create([
'email' => $email, // Associate the customer with the provided email
]);
// Step 2: Attach the PaymentMethod to the Customer
$stripeCause->paymentMethods->attach(
$paymentMethod, // Use the PaymentMethod ID sent from the frontend
['customer' => $customer->id]
);
nvm, I wil keep trying I got all I need
once again
thanks for your help ๐
btw, is there a way to debug this in the browser because how do I debug this on a phone?
You can debug your client code yes, for mobile devices that usually involves pairing with a desktop browser for dev tools
both chrome and safari support this, for example
Thanks for all the help ๐ That's all I needed
NP!