#tamim-ikbal_api

1 messages · Page 1 of 1 (latest)

violet merlinBOT
#

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

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

wise basalt
#

hello! looking at this now

fair gorge
#

Thank you sir.

#

I really need this. or either we can have system we charge on our account and transfer the amount o connected account .
But we charge stripe fees to connected accoutn as marketplace fee

#

Can we have a VC?

wise basalt
#

we don't do voice chat here! but this issue sounds pretty simple so i think we can handle it pretty easily over text

#

gimme just a moment to look

wise basalt
#

i don't use sir but you are welcome 🙂

fair gorge
#

One more point: we do seller onboarding as standard type.

wise basalt
fair gorge
#

Can I share you my code snippet>

violet merlinBOT
fair gorge
#

Onboarding:

     'type' => 'standard',
        'email'            => auth()->user()->email,
         'capabilities'     => [
               'card_payments' => ['requested' => true],
                 'transfers'     => ['requested' => true],
                ],
            'country'          => $businessProfile->store_country ?? null,
             'business_type'    => 'company',
             'company'          => [
                        'name'    => $businessProfile->name,
                        'address' => [
                            'city'        => $businessProfile->city ?? null,
                            'country'     => $businessProfile->store_country ?? null,
                            'state'       => $businessProfile->state ?? null,
                            'line1'       => $businessProfile->store_street_address ?? null,
                            'postal_code' => $businessProfile->zip_code ?? null,
                        ],
                    ],
                    'metadata'         => [
                        'seller_id' => auth()->user()->id,
                    ],
                    'business_profile' => [
                        'name'            => $businessProfile->store_name,
                        'url'             => config('app.website_domain'),
                        'support_address' => [
                            'city'        => $businessProfile->city ?? null,
                            'country'     => $businessProfile->store_country ?? null,
                            'state'       => $businessProfile->state ?? null,
                            'line1'       => $businessProfile->store_street_address ?? null,
                            'postal_code' => $businessProfile->zip_code ?? null,
                        ],
                        'support_phone'   => $businessProfile->business_phone ?? null,
                    ],
                ]);
#

PI create:

            'payment_method_types'   => ['card'],
            'amount'                 => $this->getAmount(),
            'currency'               => $this->currency,
            'metadata'               => [
                'object_id'   => $this->objectId,
                'object_type' => $this->objectType->value,
            ],
            'application_fee_amount' => $this->marketplaceCommission(),
        ];

        $options = [
            'stripe_account' => $this->accountId,
        ];

        $intent = $this->stripe->getClient()->paymentIntents->create($intentData,$options);

        if ( ! $intent->client_secret) {
            throw new ApiConnectionException('Failed to create payment intent');
        }

        return $intent->client_secret;```
ebon hill
#

Hello 👋

I"m stepping in for my colleauge. Give me a minute to catch up

fair gorge
#

I prefer this, Question it's charge processing fees on marketplace account, How do I charge stripe fees to conncected account?

        $intentData = [
            'payment_method_types'   => ['card'],
            'amount'                 => $this->getAmount(),
            'currency'               => $this->currency,
            'metadata'               => [
                'object_id'   => $this->objectId,
                'object_type' => $this->objectType->value,
            ],
            'application_fee_amount' => $this->marketplaceCommission(),
            'transfer_data'          => [
                'destination' => $this->accountId,
            ],
            'on_behalf_of'           => $this->accountId,
        ];

        $intent = $this->stripe->getClient()->paymentIntents->create($intentData);

        if ( ! $intent->client_secret) {
            throw new ApiConnectionException('Failed to create payment intent');
        }

        return $intent->client_secret;
fair gorge
ebon hill
#

Okay lets take a step back. How do you want to create these charges? Your last snippet looks like a Destination charge but the request you shared is for a Direct Charge

Which one do you want to use?

fair gorge
#

I prefer Destination charge if we can handle the stripe fees on connected account.

#

If not the direct charge

ebon hill
#

Please review the funds flows in the two different charge pages I linked. They will explain how stripe fees are collected for each charge type.

fair gorge
# fair gorge I prefer this, Question it's charge processing fees on marketplace account, How ...

Yes I got the flow:
Marketplace: $10 (Charge) - $0.59 (Stripe fee) - $10 (Transfer) + $1.23 (ApplicationFee) = $0.64
Connected: $10 (Charge) - $1.23 (ApplicationFee) = $8.77

But probelm is when I do this with payment intent

Marketplace: $10 (Charge) - $0.59 (Stripe fee) - $10 (Transfer) + $1.23 (ApplicationFee) = $0.64 this correct.

But connected accoutn get the full aamount.

I share you my snippet can you make it correct so we can include stripe fees into our application_fee_amount.

Thanks you:)

ebon hill
#

Sorry that doesn't make sense to me.

Can you share an example payment intent ID that demonstrates the current situation ?

fair gorge
#

Here it is:
pi_3S1AOoH0kLam8yX50SqejZJd

ebon hill
#

Okay so the problem here is you are not providing the transfer_data.amount parameter.

You specify here how much money from the initial charge you want to send to the Connected Account

fair gorge
#

yes, Thanks we are on same floor

fair gorge
ebon hill
#

You cannot calculate stripe fees ahead of time because they also change based on the payment method used

fair gorge
#

Last time I did this and stripe charge 15 CAD on marketplace as fees and 12 CAD on connected account as marketplace fees.
😂

public function stripeFee(): int
    {
        return (int) ceil($this->getAmount() * 0.029) + 30;
    }
fair gorge
ebon hill
#

If you use Destination Charges, the Platform pays the Stripe fee. If you use Direct Charges to collect an application fee, the Connected Account pays the Stripe fee

#

If you want the connected account to get all the funds except the Stripe fee, use Direct Charges

fair gorge
#

Let's talk about direct charge.
As I see we need connected account id to frontend for working with PI correctly, If I expose connected account Id with client_secret and pk is this safe?

ebon hill
#

Yes

#

A malicious actor cannot do anything with just the PK and account ID

#

And, to be clear, the PK will be for your platform

fair gorge
#

Yes, sir.

Can I have 20 or 30 min to implement this and check and get back to you.

We need very deep talk about direct charge, I wnat to knwo eveyrthign about stripe.

I love it so I have to be knowledgable on this.

Yes, Stripe has great doc but sometimes it's confusing.

#

Sorry, About destination charge.

ebon hill
#

We unblock developers on specific questions so it would be most helpful if you followed the guide for creating/confirming Direct Charges and then reference specific sections if you run into errors.

#

That way we are both on the same page about exactly what you are trying to do when you hit an error

fair gorge
#

Okay let me ask you a question about Destination charge please.🙂

#

I love the way destination charge work Everything on my just add marketplace add fees to connected account.

But, As I don't know about my stripe fees, How can I charge correct amount so it will be predicable and we will not run losses.

Is there any best practice for this?

ebon hill
#

Marketplaces that use Destination Charges are not trying to calculate the Stripe fees to pass them on. They are calculating a % of the total charge to pass to the Connected Account and accept that Stripe fees will come out of their Platform funds.

fair gorge
#

Hmm, Got you. just for asking like:
Maybe if I charge 5 or 7 %, I cna predict I will make money after the stripe charge too.
Thank you sir.

I am implementing the direct charge, will get back to you if any error occurs.

I really appreciate yor kind help.❤️

ebon hill
#

Happy to shed what 💡 I can 🙂

fair gorge
#

Sir, One question.
If I do direct charge and not taking fees the, there will not be any info of the payment buyer and selelr made on stripe to marketplace account?

I didn't collect fees for this and don't see any info about this payment: pi_3S1BcjQgOSS36hZ61WmWYsLY

I collect 10% and get teh only fees info but don't see any other information:
pi_3S1BelQgOSS36hZ61Vhp78ir

Is there any way to view this.

And I expose this and I am safe right sir.

'stripe'     => [
                'client_secret' => $this->createPaymentIntent(),
                'stripe_key'    => $this->stripe->getPublicKey(),
                'account_id'    => $this->accountId,
            ],
            'is_payable' => true,

Thanks a lot again.

violet merlinBOT
sick mulch
#

Hello, what data are you looking to expose here?

fair gorge
#

Payment Intent client_secret
Marketplace public_key
And Connected Account Id.

sick mulch
#

Out of those, the client_secret is the only one that is a part of the payment intent object. Can you show me what your code is doing in that createPaymentIntent to try to get to the client secret?

fair gorge
#
$intentData = [
            'payment_method_types'   => ['card'],
            'amount'                 => $this->getAmount(),
            'currency'               => $this->currency,
            'metadata'               => [
                'object_id'   => $this->objectId,
                'object_type' => $this->objectType->value,
            ],
            'application_fee_amount' => $this->marketplaceCommission(),
        ];

        $options = [
            'stripe_account' => $this->accountId,
        ];

        $intent = $this->stripe->getClient()->paymentIntents->create($intentData, $options);

        if ( ! $intent->client_secret) {
            throw new ApiConnectionException('Failed to create payment intent');
        }

        return $intent->client_secret;
sick mulch
#

Marketplace public_key
With direct charges, when initializing Stripe.js, you will want to use your platform's public key and the acct_123 account ID of the connected account you are making the direct charge with

fair gorge
#

We are marketplace and our seller connect thier account and we are going to use direct charge

sick mulch
#

Can you print out the full intent object right after you call paymentIntents->create? That client secret should be a part of the object, trying to think of why it may not be there, seeing an example may help

fair gorge
#
public function pay(): array
    {
        return [
            'stripe'     => [
                'client_secret' => $this->createPaymentIntent(),
                'stripe_key'    => $this->stripe->getPublicKey(),
                'account_id'    => $this->accountId,
            ],
            'is_payable' => true,
        ];
    }

    public function createPaymentIntent(): string
    {
        $intentData = [
            'payment_method_types'   => ['card'],
            'amount'                 => $this->getAmount(),
            'currency'               => $this->currency,
            'metadata'               => [
                'object_id'   => $this->objectId,
                'object_type' => $this->objectType->value,
            ],
            'application_fee_amount' => $this->marketplaceCommission(),
        ];

        $options = [
            'stripe_account' => $this->accountId,
        ];

        $intent = $this->stripe->getClient()->paymentIntents->create($intentData, $options);

        if ( ! $intent->client_secret) {
            throw new ApiConnectionException('Failed to create payment intent');
        }

        return $intent->client_secret;
    }
#
const stripePromise = useMemo(() => {
    if (accountId) {
      return loadStripe(publicKey, {
        stripeAccount: accountId,
      });
    }
    return loadStripe(publicKey);
  }, [publicKey, accountId]);

  const options: StripeElementsOptions = useMemo(
    () => ({
      clientSecret,
      appearance: {
        theme: "stripe",
        variables: {
          borderRadius: "12px",
        },
      },
    }),
    [clientSecret],
  );
#

We have laravel backend where we create the PI and Nextjs frontend where we collect the payment with stripe.js

sick mulch
#

And the client secret is null when you run that code? Or you running into some other issue when trying to get it to your frontend?

fair gorge
#

Let me clear the confusion:
Everything working fine.
Question 1: i don't see any payment information on marketplace dashboard except the fee marketplace charged. Is this how direct charge work? or I have to do some more configuration.
Question 2: I have to expose PI client_secret, marketplace PK and connect account ID to initialize Stripe.js and it is safe right?

sick mulch
#

Correct on #2, I am not that familiar with the dashboard and will double check what that typically looks like

#

For direct charges, you won't see the payment in your main transactions page on your dashboard, but if you go to the page for the connected account you can get a list of its payments there. The URL will look like this
https://dashboard.stripe.com/test/connect/accounts/acct_1234/payments
Where acct_1234 is the ID of a connected account

fair gorge
#

I really appreciate your help❤️

#

No, more query for now.