#gasper_best-practices

1 messages · Page 1 of 1 (latest)

amber badgeBOT
#

👋 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/1284080241878499409

📝 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.

blazing sedge
#

Hi @austere skiff I think we already talked yesterday

#

So in our staging environment where we use sandbox stripe account we enabled paypal as a new payment method

#

Using payment sheet api new payment method is already listed when adding new payment method as a customer and all works fine

#

Question we have now is how we can test charges when using paypal payment method, how can we simulate errors which can happen when doing extra charges....

austere skiff
#

Hey!

blazing sedge
#

but these are testing cards where we can only test card payment method errors not paypal

austere skiff
blazing sedge
#

when adding paypal on staging env we can not login with any testing paypal account

#

this is what we get when adding new payment method paypal

blazing sedge
#

where can I pass this email

amber badgeBOT
turbid parcel
#

in the email input inside the Stripe Checkout page

blazing sedge
#

but we are not using stripe checkout page, we are just adding payment method paypal and later on this payment method is used in checkout process when creating payment intent

turbid parcel
#

I don't know what that means sorry, can you share the code of how exactly you do this?

blazing sedge
#

sure

#

this in how we add new payment method in mobile app

turbid parcel
#

well I'd suggest not setting billingDetailsCollectionConfiguration:{email:never} , so that the PaymentSheet can show an email input, which is where you can enter the test email

#

alternatively you can pass those test emails into billingDetails when you call confirmSetup (which is not shown in that code, you must have it somewhere else)

blazing sedge
#

will try with your suggestion

#

please do not archive our conversation 🙂

blazing sedge
#

we tried you above suggestion

#

paypal payment method was created but it seems it is still connected to fake_payer ... account

turbid parcel
#

what is the Payment/SetupIntent ID from the video?

amber badgeBOT
blazing sedge
#

here is setupintent id

#

it is from above video

lime stratus
#

Can you please paste the ID here

blazing sedge
#

seti_1PyWsuJA7Or4kmRACDcKXEVO

lime stratus
#

Can you help my understand the issue? What does 'connected to fake_payer account' mean?

blazing sedge
#

so as I mentioned above we would like to test paypal in our staging environment. We would like to test how charges/refunds works with paypal payment method

lime stratus
#

But you're not processing any payments, you're using a Setup Intent to save the PayPal PM for later usage

#

I suspect those email credentials don't work in that scenario

blazing sedge
#

yes I know, in above flow we are just setting paypal as PM. We can also create a payment intent with payment method. It all works. What we would like to test now is different errors which can be triggered when using paypal when placing new order or doing extra charges

#

like having expired card in paypal or having insufficient funds on card connected with Paypal

lime stratus
#

Yeah but you're using the email address to trigger declines with a Setup Intent. It doesn't work like that, you need to create and confirm a Payment Intent with those email addresses

blazing sedge
#

so my stripe customer email needs to be payee_account_restricted@smth.com to be able to test declines when using paypal as PM?

lime stratus
#

No, you need to create a Payment Intent and pass the email address listed in the documentation

blazing sedge
#

sorry I don't understand where I need to pass the email

lime stratus
#

Then you can use the email addresses listed here to test the scenarios. Right now you're trying to use them with a Setup Intent (not a payment) and they mustn't work

Learn how to accept PayPal payment, a digital wallet popular with businesses in Europe.

blazing sedge
#

is there an option to pass an email

lime stratus
#

Yes, as per the documentation you use payment_method_data[billing_details][email] when you create/confirm the intent

Learn how to accept PayPal payment, a digital wallet popular with businesses in Europe.

blazing sedge
#

ok, let us test now

amber badgeBOT
blazing sedge
#

please do not archive conversation yet, our mobile dev just jump out for few minutes

tawny mural
#

hi! I'm taking over this thread. if we close this thread due to inactivity, feel free to reopen a new one on #help

blazing sedge
#

yes I know but we will lose the thread

tawny mural
#

threads are not deleted, so you can always access it.

blazing sedge
#

I tried above suggestion

#

so when creating payment intent I added payment_method_data

#

if @payment_method.type == 'paypal'
charge_payload.merge!(
payment_method_data: {
type: 'paypal',
billing_details: {
email: 'payee_account_restricted@smth.com'
}
},
mandate_data: {
customer_acceptance: {
type: 'offline'
}
},
return_url: ENV['STRIPE_PAYPAL_RETURN_URL']
)
end

#

but I get Received both payment_method and payment_method_data parameters. Please pass in only one

#

@lime stratus

tawny mural
blazing sedge
#

req_V2JF84WqRSrfBP

tawny mural
#

yes the error makes sense. if you already have a payment_method, you cannot use payment_method_data. instead you could just update the existing PaymentMethod

blazing sedge
#

yes with setup intent we aready created payment method

#

and when creating payment intent we are passing this payment method

#

question I have is how to test paypal payment method in staging environment

#

this was shared with me but I can not make it working

tawny mural
#

the doc you linked if for Checkout Session. are you using Checkout Session?

blazing sedge
#

no

tawny mural
blazing sedge
#

the link was shared with me in this thread

#

so for testing I need to skip passing my already created paypal payment method (created with setup intent) and pass payment_method_data[billing_details][email]

tawny mural
#

correct. or you could try updating the email of the existing payment method, but I haven't tested this so not sure.

blazing sedge
#

req_5LvguH3kZxlXIm

#

initial charge was succesfully made. Shouldn't be declined? I used transaction_refused email

#

ah sorry I set name insted of email

#

testing again

tawny mural
#

no worries!

amber badgeBOT
blazing sedge
#

when I use these testing emails I always need to confirm payment intent

#

one more question, if customer adds paypal as a PM with setup intent and we set this payment method for off session charges will user ever need to confirm payment intent again?

dull pecan
blazing sedge
#

in our case users add payment methods upfront, then they go through checkout process and at the end we create payment intent. When creating payment intent with off_session: false (customer is online in checkout process) we always get a response from stripe requires_action in payment intent when using paypal payment method

dull pecan
#

If customer is on session, then don't do off_session=true

#

Where confirmation is client side

blazing sedge
#

we would like to skip this extra step required_action

dull pecan
#

Can you share the payment intent id where this happened?

blazing sedge
#

if we add off_session: true than payment intent status is succeeded

#

ok one moment

#

pi_3PyZWnJA7Or4kmRA0i245lE6

#

{ "amount": "2000", "capture_method": "automatic", "confirm": "true", "confirmation_method": "manual", "currency": "GBP", "customer": "cus_Qea47DneT5NsjW", "description": "CHARGE 3516663", "mandate_data": { "customer_acceptance": { "type": "offline" } }, "metadata": { "service_country": "GB" }, "payment_method": "pm_1PvlDZJA7Or4kmRAl2CzcDHf", "payment_method_types": { "0": "card", "1": "paypal" }, "return_url": "https://lh-dev.eu.ngrok.io/paypal", "setup_future_usage": "off_session", "statement_descriptor": "LAUNDRYHEAP 3516663" }

#

this was our request

dull pecan
#

Oh yeah if customer is onsession they're supposed to complete payment through paypal

blazing sedge
#

and response

#

{ "id": "pi_3PyZWnJA7Or4kmRA0i245lE6", "object": "payment_intent", "amount": 2000, "amount_capturable": 0, "amount_details": { "tip": { } }, "amount_received": 0, "application": null, "application_fee_amount": null, "automatic_payment_methods": null, "canceled_at": null, "cancellation_reason": null, "capture_method": "automatic", "client_secret": "pi_3P**********************_******_*********************N4vg", "confirmation_method": "manual", "created": 1726234033, "currency": "gbp", "customer": "cus_Qea47DneT5NsjW", "description": "CHARGE 3516663", "invoice": null, "last_payment_error": null, "latest_charge": null, "livemode": false, "metadata": { "service_country": "GB" }, "next_action": { "redirect_to_url": { "return_url": "https://lh-dev.eu.ngrok.io/paypal", "url": "https://pm-redirects.stripe.com/authorize/acct_14bXGSJA7Or4kmRA/pa_nonce_QqG2nVriwaXUgkPsHJbpKD5mlDpdOoz?useWebAuthSession=true&followRedirectsInSDK=true" }, "type": "redirect_to_url" }, "on_behalf_of": null, "payment_method": "pm_1PvlDZJA7Or4kmRAl2CzcDHf", "payment_method_configuration_details": null, "payment_method_options": { "card": { "installments": null, "mandate_options": null, "network": null, "request_three_d_secure": "automatic" }, "paypal": { "preferred_locale": null, "reference": null } }, "payment_method_types": [ "card", "paypal" ], "processing": null, "receipt_email": null, "review": null, "setup_future_usage": "off_session", "shipping": null, "source": null, "statement_descriptor": "LAUNDRYHEAP 3516663", "statement_descriptor_suffix": null, "status": "requires_action", "transfer_data": null, "transfer_group": null }

#

but if we set off_session: false for paypal then payment_intent.status is succeeded

dull pecan
#

Yeah I think this is expected

#

When customer is on session it's expected for them to complete payment in paypal

#

That's why the next action is redirect

blazing sedge
#

req_XvCKYduGJX3RUh

#

in request I shared with you you can see this is not needed

dull pecan
#

Not sure what you're referring to now

#

That's a retrieve customer request

#

What's your question exactly?

blazing sedge
#

in req_XvCKYduGJX3RUh you can see that I set off_session:true and payment_intent succeeded without any extra action

dull pecan
#

Yeah because it's off session

#

Customer isn't in the checkout flow

#

So they can't be redirected

blazing sedge
#

no I am in a checkout

dull pecan
#

You set off session to true

#

That tells us that customer is NOT in checkout flow

blazing sedge
#

yes that is my question if we can set off_session:true when creating payment intent to avoid this extra step for the customer

dull pecan
#

Technically, yeah if it's been set up properly for off session usage