#lyubo_api

1 messages ยท Page 1 of 1 (latest)

lavish narwhalBOT
#

๐Ÿ‘‹ 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.

rich sedge
#

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

lilac timber
#

Hi, let me help you with this.

#

Are you using your Test mode API keys?

rich sedge
#

yes

#

const stripe1 = Stripe('pk_test_51QCPzHJ14oeQYtXPyTPLTyVXQGRwR4TYl6w1zo4Qc9s0FX3WZ7JYddQR0973tQvD3ctTjIZISvqpuBWas42ZWJuZ008jCccZdC');

#

and I have used grok in order to get https for testing purposes

#

*ngrok

lilac timber
#

You can safely confirm the payment - your real card won't be charged.

rich sedge
#

It fails

lilac timber
#

Could you please share the PaymentIntent ID pi_xxx?

rich sedge
#

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

lavish narwhalBOT
rich sedge
#

Hi ๐Ÿ™‚

soft cradle
soft cradle
#

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

rich sedge
#

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

soft cradle
#

You need to keep going and:

  • create the payment intent on your server
  • set up a confirm event handler on ECE
    expressCheckoutElement.on('confirm', async (event) => { ... }
  • call stripe.confirmPayment() with the client secret from the payment intent to complete the payment
rich sedge
#

I assume I can confirm the payment on the backend?

soft cradle
#

Yes, but that's a little more complicated

rich sedge
#

daaamn I don't get paid enough for this lol

#

Thanks for your help

#

I will continue reading the docs

soft cradle
rich sedge
#

Oook, thanks ๐Ÿ™‚

#

You don't work on weekends btw?

soft cradle
#

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}}
    });
rich sedge
#

// 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?

soft cradle
#

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

rich sedge
#

Thanks for all the help ๐Ÿ™‚ That's all I needed

soft cradle
#

NP!

rich sedge
#

Sorry to bother you again

#

can I ask another question

#

actually, nevermind