#videovillain_api

1 messages · Page 1 of 1 (latest)

still berryBOT
#

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

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

supple ridge
#

What type of connected account do you use? Standard, Express, Custom or using controller config?

pure mirage
#

I believe we made Standard, how do I find out for sure though?

#

yes, they are standard in the test data, except for the first one which was Express

supple ridge
#

Could you share a connected account ID (acct_xxx), so that I can take a look?

pure mirage
#

acct_1QMPGBQrBbr8JOkl

supple ridge
#

This will allows product / prices to be created on the connected account

pure mirage
#

hmmm, i believe we are doing that.. jsut a sec

supple ridge
#

If you believe that, can you share the example request ID (req_xxx) which you created relevant objects on the connected account?

pure mirage
#

yes, just a sec, sorry

#

just to be clear, this is the part you are talkinga bout right? ['stripe_account' => '{{CONNECTED_ACCOUNT_ID}}']

#

req_KvpABTZdG7Ex9K

#

that is one I think was made intended for a stripe connected account

#

this is the PHP:

public function createPaymentIntentCourse(Request $request) {
        $sub = "";
        try {
            //I need to add the Coach Stripe Account ID?
            $unit_amount = $request->unit_amount;
            $currency = $request->currency;
            $session_unique_key = $request->session_unique_key;
            $payment_intent_id = $request->payment_intent_id;
            $player_id = $request->player_id;
            $player = Player::findOrFail($player_id);
            $customer = $player->createOrGetStripeCustomer();
            $customerid = $customer->id;
            $stripe = $this->initializeStripeClient();
            if (isset($payment_intent_id)) {
                $sub = $stripe->paymentIntents->retrieve($payment_intent_id);
                if ($sub->status !== 'succeeded') {
                    // Proceed with confirmation
                    $sub->confirm();
                }
            } else {
                // Create the Payment Intent using the amount and currency from the price
                $sub =  $stripe->paymentIntents->create([
                    'amount' => $unit_amount, // Use the amount from the price object
                    'currency' => $currency,  // Use the currency from the price object
                    'customer' => $customerid, // 顧客IDを追加
                    "setup_future_usage" => "on_session",
                    'automatic_payment_methods' => [
                        'enabled' => true,
                    ],
                    'metadata' => [
                        'course_unique_key' => $session_unique_key,
                    ],
                ]);
            }

            return $sub;
        } catch (Exception $e) {
            return $this->error_send($e, "A-005", 500);
        }

        return $sub;
    }
supple ridge
#

just to be clear, this is the part you are talkinga bout right? ['stripe_account' => '{{CONNECTED_ACCOUNT_ID}}']
Yes

pure mirage
#

so in there we need to add

['stripe_account' => '{{CONNECTED_ACCOUNT_ID}}'] to the create() right?

supple ridge
still berryBOT
supple ridge
#

['stripe_account' => '{{CONNECTED_ACCOUNT_ID}}'] to the create() right?
Yes

pure mirage
#

Okay, and that is the only difference?

supple ridge
#

Yup! This will allow the products / payment intents to be created on the connected account

pure mirage
#

Also, how do we check if that account is restricted or not if it is ready to make/accept payments or not?

upbeat tapir
#

Hi @pure mirage I'm taking over this thread

pure mirage
#

thanks!

upbeat tapir
#

You can tell by looking at the account's charges_enabled property

pure mirage
#

okay

#

is that a simple check that the front can do during loading of the page, I assume we need a backend api built for it right?

#

or if we pull the stripe account it will come along with it all?

upbeat tapir
#

Yes you need to use your API key to retrieve the account object from your backend

pure mirage
#

Okay, now how do we make sure that the connected accounts and their payments and such are handled by stripe liability is on stripe and the connected accounts and not us?

#

I want to make sure I chose the right pattern

upbeat tapir
pure mirage
#

isn't there a path we could have taken that wouldn't allow us to set that?

#

so in that case it would default to stripe right?

#

is there an easy way to check it from the dashboard?

upbeat tapir
pure mirage
#

Okay thanks!

and also, regarding the charges_enabled

#

is that on Stripe Customer Accounts or on Stripe Connected Accounts? or both?

upbeat tapir
pure mirage
#

and are we doing this correctly?

public function createPaymentIntentCourse(Request $request) {
        $sub = "";
        try {
            //I need to add the Coach Stripe Account ID?
            $unit_amount = $request->unit_amount;
            $currency = $request->currency;
            $session_unique_key = $request->session_unique_key;
            $payment_intent_id = $request->payment_intent_id;
            $player_id = $request->player_id;
            $player = Player::findOrFail($player_id);
            $customer = $player->createOrGetStripeCustomer();
            $customerid = $customer->id;
            $stripe = $this->initializeStripeClient();
            if (isset($payment_intent_id)) {
                $sub = $stripe->paymentIntents->retrieve($payment_intent_id);
                if ($sub->status !== 'succeeded') {
                    // Proceed with confirmation
                    $sub->confirm();
                }
            } else {
                // Create the Payment Intent using the amount and currency from the price
                $sub =  $stripe->paymentIntents->create([
                    'amount' => $unit_amount, 
                    'currency' => $currency, 
                    'customer' => $customerid, // <-- do we also need this so it knows which customer is paying, is this the right location?
                    "setup_future_usage" => "on_session",
                    'automatic_payment_methods' => [
                        'enabled' => true,
                    ],
                    'metadata' => [
                        'course_unique_key' => $session_unique_key,
                    ],
                    ['stripe_account' => '{{CONNECTED_ACCOUNT_ID}}'],  // <-- add this line and it will work?
                );
            }

            return $sub;
        } catch (Exception $e) {
            return $this->error_send($e, "A-005", 500);
        }

        return $sub;
    }
#

i have two comments with < --

#

You still there?

upbeat tapir
#

Yes, you can specify a customer to assocaite a payment to it

pure mirage
#

okay, and just a last thing

#

the setup_future_usage, would I only use that if this product were to be a subscription or is that good to have in case the customer wants to buy it again?

upbeat tapir
#

Setting setup_future_usage tells Stripe that you want to save the payment method for future usage. You can use the saved payment method for another one-off payment, or recurring payments like subscriptions

pure mirage
#

right, okay

#

so then, actually, i have another question

#

i was looking at adding payment methods

#

and we found a way to change default method based on already existing methods

#

but for a Stripe Customer Account, how do we simply prompt them to add a new method for their account without any payment intent?

upbeat tapir
#

I don't quite understand your last question. What you mean by "Stripe Customer Account" ? is it a customer or connected account?

pure mirage
#

the customer account

#

the regular one everyone needs

#

for example, users on our site all get a stripe customer account and become free users on our app

#

they can subscribe, and i want to let them add othe methods there

upbeat tapir
pure mirage
#

they can also buy from connected accounts and i want them to have their options available there.

#

yes

upbeat tapir
pure mirage
#

they can also Become connected account users and offer things to others, and i want to migrate their payment info when/if possible

#

okay, so setup intent is just for adding payment methods?

upbeat tapir
#

Yes you are right.

pure mirage
#

okay great, thanks a bunch!

#

I think that is all for now, thanks for the help, both you and river