#vng-trn_code
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/1222657944756424714
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi @vital frigate
need your help about Stripe Apps
Are you available so I can provide more information.
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'?
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.
What does 'user's account' mean in this case?
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
i explain
i'm build a Stripe app and upload this to Marketplace
and you install my app, so you called is users account
understand?
So the user is the customer who is making the purchase from the app, right?
no
Don't buy anything from the app
The application is to support marketing for customers (user installed app)
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.
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.
Ah, yeah you'd want to setup a connect webhook: https://docs.stripe.com/connect/webhooks
yeah
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.
if my this is correct, then how can account B be connect and be in account A's list of connected accounts
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.
yes, when B install the app in test mode, the account is not connected. so how does it connect?
and if in live mode, when B installed the App, will account B automatically connect to account A?
here is A webhook settings
Ok, I was totally off here, sorry. I checked with a teammate and confirmed that you can do what you're trying to do. You can scratch the connect relationship that I shared above.
You'd use the Platform Key, https://docs.stripe.com/stripe-apps/api-authentication and add the events permission, https://docs.stripe.com/stripe-apps/reference/permissions#event to listen to the webhook events.
I'm really sorry for the confusion I created.
[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
Is this configuration absolutely correct?
That seems correct, you should be able to test this in test mode and it would work the same way.
Glad to hear!
Everything now works just like I wanted it to.
I spent a lot of time on this problem.
My old app configured stripe_api_access_type is restricted_api_key
and it couldn't work, but now it seems to be fine
Happy to hear!
Thank you, happy to help!
Hi @vital frigate
i have more question
i got the object of payment on webhook, but i don't see the customer information.
Hello! I'm taking over and catching up...
can you check help me if i'm missing permission?
{"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
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.
the permissions i'm request on the app.
what the Event can i get the customer information?
You can't. You need to retrieve it from the API.
There's no Event that contains the information you want.
this payment i made with guest information, and enter some basic information including name and email
so on platform account, can i retrieve it on user account?
Yep. that information is on the associated Payment Method, and you can retrieve that via the API.
using platform api key?
You would use this approach: https://docs.stripe.com/connect/authentication
so the api is similar to the usual, but here i need to add the id of the connected account
Yep!
For example, I want to get customer information whose id: cus_PogkFewKnKJ2G7 from account: acct_1OyClyIyTqf0e7cM
So how should I write the code?
There's an example snippet here: https://docs.stripe.com/api/customers/retrieve
You would adjust that to use the technique I shared above.
$stripe->customers->retrieve('cus_PogkFewKnKJ2G7', ['stripe_account' => 'acct_1OyClyIyTqf0e7cM']);
this is correct?
Run it and see if it works!
I can't run or validate your code for you. ๐
That's what test mode is for.
Okay
this is not correct
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.
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
ahaha, you are true