#gasper_best-practices
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/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.
- gasper_api, 22 hours ago, 39 messages
- gasper_api, 2 days ago, 20 messages
- gasper_paypal-future-charges, 3 days ago, 19 messages
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....
Hey!
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....
You can use this PaymentMethod and simulate a payment failure:
https://docs.stripe.com/testing#international-cards:~:text=The cards in the previous table can’t be attached to a Customer object. To simulate a declined payment with a successfully attached card%2C use the next one.
but these are testing cards where we can only test card payment method errors not paypal
For Paypal, you can use these emails to simulate different payment scenarios:
https://docs.stripe.com/payments/paypal/accept-a-payment?web-or-mobile=web&payments-ui-type=stripe-hosted#test-integration
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
No you don't need to login to your paypal account for stating env
you just need to pass the email with one of the values listed there
where can I pass this email
in the email input inside the Stripe Checkout page
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
I don't know what that means sorry, can you share the code of how exactly you do this?
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)
we tried you above suggestion
paypal payment method was created but it seems it is still connected to fake_payer ... account
what is the Payment/SetupIntent ID from the video?
Can you please paste the ID here
seti_1PyWsuJA7Or4kmRACDcKXEVO
Can you help my understand the issue? What does 'connected to fake_payer account' mean?
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
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
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
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
so my stripe customer email needs to be payee_account_restricted@smth.com to be able to test declines when using paypal as PM?
No, you need to create a Payment Intent and pass the email address listed in the documentation
sorry I don't understand where I need to pass the email
In the Payment Element when you initialise it for the Payment Intent. You basically need to follow this guide: https://docs.stripe.com/payments/paypal/accept-a-payment?web-or-mobile=web&payments-ui-type=direct-api
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
Yes, as per the documentation you use payment_method_data[billing_details][email] when you create/confirm the intent
ok, let us test now
please do not archive conversation yet, our mobile dev just jump out for few minutes
hi! I'm taking over this thread. if we close this thread due to inactivity, feel free to reopen a new one on #help
yes I know but we will lose the thread
threads are not deleted, so you can always access it.
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
can you share the request ID (req_xxx)? you can find it here https://dashboard.stripe.com/test/logs
req_V2JF84WqRSrfBP
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
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
the doc you linked if for Checkout Session. are you using Checkout Session?
then why did you link to that page?
anyway, this is the correct link: https://docs.stripe.com/payments/paypal/accept-a-payment?web-or-mobile=web&payments-ui-type=direct-api#test-mode
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]
correct. or you could try updating the email of the existing payment method, but I haven't tested this so not sure.
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
no worries!
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?
What do you mean by confirm payment intent? If it's an off-session charge the user wouldn't be present in the flow to confirm payment intent. That would be done on your server: https://docs.stripe.com/payments/paypal/set-up-future-payments?web-or-mobile=web&payments-ui-type=direct-api#web-create-off-session-payment-intent
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
If customer is on session, then don't do off_session=true
Where confirmation is client side
we would like to skip this extra step required_action
Can you share the payment intent id where this happened?
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
Oh yeah if customer is onsession they're supposed to complete payment through paypal
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
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
Not sure what you're referring to now
That's a retrieve customer request
What's your question exactly?
in req_XvCKYduGJX3RUh you can see that I set off_session:true and payment_intent succeeded without any extra action
Yeah because it's off session
Customer isn't in the checkout flow
So they can't be redirected
no I am in a checkout
yes that is my question if we can set off_session:true when creating payment intent to avoid this extra step for the customer
Technically, yeah if it's been set up properly for off session usage