#vng-trn_code

1 messages ยท Page 1 of 1 (latest)

jagged irisBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

frosty flumeBOT
eternal turtle
#

Hi @vital frigate

#

need your help about Stripe Apps

#

Are you available so I can provide more information.

vital frigate
#

Hi, these Test behaviors should mirror on what you see in Live mode.

Can you add more clarity on what you mean with 'will the user's account be added to the connected accounts list of the owner account'?

eternal turtle
#

Okay

#

Let's talk about the test mode first.

#

Let me describe what I want.

#

I built a Stripe app, to support marketing for users.

#

When users install our application, we will receive the objects of the payments they received, based on the "payment_intent.succeeded" event.

#

But we don't have permission to add webhooks on the user's account, so we can only add webhooks to the app owner's account.

vital frigate
#

What does 'user's account' mean in this case?

eternal turtle
#

and I uploaded an app with the following permissions.
charge_read, customer_read, event_read, payment_intent_read, payment_intent_write, checkout_session_read.
also stripe_api_access_type: platform and distribution_type is public

eternal turtle
#

i'm build a Stripe app and upload this to Marketplace

#

and you install my app, so you called is users account

#

understand?

vital frigate
#

So the user is the customer who is making the purchase from the app, right?

eternal turtle
#

Don't buy anything from the app

#

The application is to support marketing for customers (user installed app)

vital frigate
#

Can you share the full flow of the app so we are on the same page?

From the initial question, I think you're looking to listent to events from the Connected Accounts: https://docs.stripe.com/connect/webhooks

However, I'm not fully sure that is what you're asking so I need a clearer explanation of the flow.

eternal turtle
#

I explain simply:

A => Build a Stripe app, and upload this to marketplace.
B => Installed this app
C send a payment to B, A will be get the object of this payment by webhook.

vital frigate
eternal turtle
#

but

#

My understanding is that, when account B is in account A's list of connected accounts, A will now be able to listen to B's events

#

right?

#

but the application is still in test mode. and B installs A's app, account B is not listed in the connected accounts.

eternal turtle
vital frigate
#

Ok, so you're not using Connect? If you're not using Connected, what you're looking for is not possible. You can't listen to events on accounts that are not connected to your Platform.

eternal turtle
#

and if in live mode, when B installed the App, will account B automatically connect to account A?

#

here is A webhook settings

vital frigate
#

I'm really sorry for the confusion I created.

eternal turtle
#

[code]{
"id": "com.n-frames.n-frames-review",
"version": "0.0.1",
"name": "N Frames Review",
"icon": "",
"permissions": [
{
"permission": "charge_read",
"purpose": "sample text"
},
{
"permission": "customer_read",
"purpose": "sample text"
},
{
"permission": "event_read",
"purpose": "Allows reading event data from users who have installed the app"
},
{
"permission": "payment_intent_read",
"purpose": "sample text"
},
{
"permission": "payment_intent_write",
"purpose": "sample text"
},
{
"permission": "checkout_session_read",
"purpose": "sample text"
}
],
"ui_extension": {
"views": [
{
"viewport": "stripe.dashboard.drawer.default",
"component": "App"
}
],
"content_security_policy": {
"connect-src": [
"https://reviews.stage.n-framescorp.com/index.php",
"https://reviews.stage.n-framescorp.com/listen.php"
],
"image-src": null,
"purpose": "Send data to our backend"
}
},
"stripe_api_access_type": "platform",
"distribution_type": "public"
}[/code]

#

here is my stripe-app.json

eternal turtle
vital frigate
#

That seems correct, you should be able to test this in test mode and it would work the same way.

eternal turtle
#

Yeah, i'm testing

#

@vital frigate i get the event on webhook.

vital frigate
#

Glad to hear!

eternal turtle
#

Everything now works just like I wanted it to.

#

I spent a lot of time on this problem.

jagged irisBOT
eternal turtle
#

My old app configured stripe_api_access_type is restricted_api_key

#

and it couldn't work, but now it seems to be fine

vital frigate
#

Happy to hear!

eternal turtle
#

thank so much for support

#

Wish you a happy working day.

vital frigate
#

Thank you, happy to help!

eternal turtle
#

Hi @vital frigate

#

i have more question

#

i got the object of payment on webhook, but i don't see the customer information.

surreal creek
#

Hello! I'm taking over and catching up...

eternal turtle
#

{"id":"evt_3Oz5DjIyTqf0e7cM2DuN20Bo","object":"event","account":"acct_1OyClyIyTqf0e7cM","api_version":"2023-10-16","created":1711579524,"data":{"object":{"id":"pi_3Oz5DjIyTqf0e7cM2wLY9lqd","object":"payment_intent","amount":300000,"amount_capturable":0,"amount_details":{"tip":[]},"amount_received":300000,"application":null,"application_fee_amount":null,"automatic_payment_methods":null,"canceled_at":null,"cancellation_reason":null,"capture_method":"automatic","client_secret":null,"confirmation_method":"automatic","created":1711579523,"currency":"usd","customer":null,"description":null,"invoice":null,"last_payment_error":null,"latest_charge":"ch_3Oz5DjIyTqf0e7cM2wsnKBJu","livemode":false,"metadata":[],"next_action":null,"on_behalf_of":null,"payment_method":"pm_1Oz5DiIyTqf0e7cMMt36jWLh","payment_method_configuration_details":null,"payment_method_options":{"card":{"installments":null,"mandate_options":null,"network":null,"request_three_d_secure":"automatic"}},"payment_method_types":["card"],"processing":null,"receipt_email":null,"review":null,"setup_future_usage":null,"shipping":null,"source":null,"statement_descriptor":null,"statement_descriptor_suffix":null,"status":"succeeded","transfer_data":null,"transfer_group":null}},"livemode":false,"pending_webhooks":1,"request":{"id":"req_bPy8d4ddsGW7pS","idempotency_key":"d2c385f3-289b-4fa7-821d-b03b14eb6cf0"},"type":"payment_intent.succeeded"}

#

the data i get from the webhook

surreal creek
#

That's a payment_intent.succeeded Event, which contains a Payment Intent object. Payment Intents don't contain customer information. Usually that kind of information is stored in an associated Customer object (although this Payment Intent does not have an associated Customer) or on the associated Payment Method.

eternal turtle
#

the permissions i'm request on the app.

eternal turtle
surreal creek
#

You can't. You need to retrieve it from the API.

#

There's no Event that contains the information you want.

eternal turtle
eternal turtle
surreal creek
#

Yep. that information is on the associated Payment Method, and you can retrieve that via the API.

eternal turtle
surreal creek
eternal turtle
surreal creek
#

Yep!

eternal turtle
#

For example, I want to get customer information whose id: cus_PogkFewKnKJ2G7 from account: acct_1OyClyIyTqf0e7cM

#

So how should I write the code?

surreal creek
#

You would adjust that to use the technique I shared above.

eternal turtle
#

$stripe->customers->retrieve('cus_PogkFewKnKJ2G7', ['stripe_account' => 'acct_1OyClyIyTqf0e7cM']);

#

this is correct?

surreal creek
#

Run it and see if it works!

#

I can't run or validate your code for you. ๐Ÿ™‚

#

That's what test mode is for.

eternal turtle
#

Okay

surreal creek
#

What happened when you tried it?

#

Oh, try passing an empty array in for the second argument. I believe the connected account needs to be specified in the array you pass in as the third argument.

eternal turtle
#

Warning: Options found in $params: stripe_account. Options should be passed in their own array after $params. (HINT: pass an empty array to $params if you do not have any.) in /home/reviewsstagenfra/public_html/vendor/stripe/stripe-php/lib/ApiRequestor.php on line 395

Fatal error: Uncaught Error sending request to Stripe: (Status 400) (Request req_Z5LKJAznZAt0pn) Received unknown parameter: stripe_account Stripe\Exception\InvalidRequestException: Received unknown parameter: stripe_account in /home/reviewsstagenfra/public_html/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php:38 Stack trace: #0 /home/reviewsstagenfra/public_html/vendor/stripe/stripe-php/lib/Exception/InvalidRequestException.php(35): Stripe\Exception\ApiErrorException::factory('Received unknow...', 400, '{\n "error": {\n...', Array, Object(Stripe\Util\CaseInsensitiveArray), 'parameter_unkno...') #1 /home/reviewsstagenfra/public_html/vendor/stripe/stripe-php/lib/ApiRequestor.php(218): Stripe\Exception\InvalidRequestException::factory('Received unknow...', 400, '{\n "error": {\n...', Array, Object(Stripe\Util\CaseInsensitiveArray), 'parameter_unkno...', 'stripe_account') #2 /home/reviewsstagenfra/public_html/vendor/stripe/stripe-php/lib/ApiRequestor.php(180): Stripe\ApiRequestor::_specificAPIError('{\n "error in /home/reviewsstagenfra/public_html/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38