#tamim-ikbal_api
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/1410695961855922300
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
hello! looking at this now
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?
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
Great to hear that. Thanks sir
i don't use sir but you are welcome 🙂
One more point: we do seller onboarding as standard type.
when you're calling loadStripe are you including the stripeAccount option? you can see how to do this here:
https://docs.stripe.com/connect/direct-charges?platform=web&ui=elements#configure-elements-provider
Can I share you my code snippet>
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;```
Hello 👋
I"m stepping in for my colleauge. Give me a minute to catch up
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;
Sure, Thanks for your help.
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?
I prefer Destination charge if we can handle the stripe fees on connected account.
If not the direct charge
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.
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:)
Sorry that doesn't make sense to me.
Can you share an example payment intent ID that demonstrates the current situation ?
Here it is:
pi_3S1AOoH0kLam8yX50SqejZJd
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
yes, Thanks we are on same floor
How do we calculate the transfer_data.amount ?
More simple: I want to set transfer amount (amount - stripefees)
How do I calculate stripe fees correctly.
because stripe charge different amount when the convert currency.
You cannot calculate stripe fees ahead of time because they also change based on the payment method used
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;
}
Cool, then How can I solve this situation🙂
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
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?
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
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.
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
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?
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.
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.❤️
Happy to shed what 💡 I can 🙂
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.
Hello, what data are you looking to expose here?
Payment Intent client_secret
Marketplace public_key
And Connected Account Id.
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?
$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;
Marketplace public_key
With direct charges, when initializing Stripe.js, you will want to use your platform's public key and theacct_123account ID of the connected account you are making the direct charge with
We are marketplace and our seller connect thier account and we are going to use direct charge
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
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
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?
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?
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
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Thanks a lot
I really appreciate your help❤️
No, more query for now.