Payment Intent issues Stripe Connect - php

I am developing a small online marketplace in WordPress for a client and I am using Stripe Connect. What I am trying to accomplish is:
User A is posting a project, User B bids for this project, gets accepted and delivers the work.
User A now has to pay the agreed amount for the deliverable
User A gets his card charges, Platform account gets the application fee, Stripe gets the Stripe fee, User B gets paid with the remaining amount
I have created the following function with payment intent, destination charge and application amount fee as described here: https://stripe.com/docs/connect/collect-then-transfer-guide
function destination_charge(){
// Set your secret key. Remember to switch to your live secret key in production!
\Stripe\Stripe::setApiKey('sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
$payment_intent = \Stripe\PaymentIntent::create([
'payment_method_types' => ['card'],
'amount' => 1000,
'currency' => 'usd',
'application_fee_amount' => 123,
'transfer_data' => [
'destination' => 'acct_UserB',
],
]);
}
So if I understand the docs and the concept correctly, when User A triggers the above function, User A gets charged $10 on his card, application takes $1.23 fee and User B gets the remaining amount. Stripe deducts its service fee from the application. Although I am not charging anything from a form, since User A is a verified connected account with card details already in Stripe Connect.
Unfortunately this is not the case though and even if I try separating charges from transfers, as described here: https://stripe.com/docs/connect/charges-transfers, it's not working either.
Stripe Connect is setup for US businesses, USD currency. I am using Express Accounts on a test environment.
Side note: I already tried using top-ups in order to add test funds and create balance, but the "add to balance" button is not available for some reason. https://stripe.com/docs/connect/top-ups
What am I missing here? Is destination charges the right choice for what I am trying to accomplish?
Any suggestion would be helpful.
Thanks.

You can try to use the stripe-account header. By using this, you are simply making the request on-behalf of the connected account. The payment will automatically be credited to the connected account.
$payment_intent = \Stripe\PaymentIntent::create([
'payment_method_types' => ['card'],
'amount' => 1000,
'currency' => 'usd',
'application_fee_amount' => 123,
], ['stripe-account' => 'acct_UserB']);
}
\Stripe\PaymentIntent::confirm(
$payment_intent->id,
['payment_method' => 'pm_card_visa']
);

Related

Stripe connect subscription split fees

Hi i'm using the stripe PHP API to build a platform for a client, the platform is selling monthly subscription to author content on a monthly basis I have a deal with my client to share 50% of the fees we taking on each subscriptions.
I used this snippet to make the subscription:
$stripe->subscriptions->create([
'customer' => '{{CUSTOMER}}',
'items' => [['price' => '{{PRICE}}']],
'expand' => ['latest_invoice.payment_intent'],
'application_fee_percent' => 10,
'transfer_data' => ['destination' => '{{CONNECTED_STRIPE_ACCOUNT_ID}}'],
]);
I was wondering if how i can transfer my half of the 10% automatactly and monthly to an other connected acconunt (mine)... Can someone help me with that?
Given the subscription is on the platform, you can transfer funds to multiple connected accounts after the charge.
Alternatively, you can keep the same code you shared here and then transfer the 5% from the application fee to the other connected account separately. You’d listen to invoice.paid Event and when creating the transfer, pass the source_transaction parameter which transfers funds from a charge. These funds will not become available until the original charge is settled.

Want to transfer amount from platform to connected account on stripe

I want to transfer the amount to the connected account from the platform.
I have tried Transfer Api But we have a limitation we can not send amounts outside of platform origin.
Now I want to transfer the amount with the help destination charges api but in this, we do not have any payment method because the customer is not involved in this process. In this API payment method is required to complete the transaction.
\Stripe\PaymentIntent::create([
'amount' => (int) $amount * 100,
'currency' => 'USD',
'transfer_data' => [
'destination' => {{connected_account_id}},
],
'on_behalf_of' => {{connected_account_id}},
]);
Is any other way to transfer the amount to the connected account ??

Stripe Payment gateway

I'm creating service like Airbnb using Laravel. So I'm using stripe payment gateway for my project. So I want to create escrow system using stripe. Let's say someone book properties of seller ABC for 3 days. On booking amount is debit from buyer's account and credit to the admin Account. Now on journey completion seller ABC get his money and Admin get his commission from booking. So we have to transfer money to seller account only when journey is complete.
So I'm using following method to achieve this following methods.
Payment Authorization
\Stripe\Stripe::setApiKey('sk_test_****');
\Stripe\PaymentIntent::create([
'amount' => 1099,
'currency' => 'inr',
'payment_method_types' => ['card'],
'capture_method' => 'manual',
]);
Payment Capture
\Stripe\Stripe::setApiKey('sk_test_*****');
$intent = \Stripe\PaymentIntent::retrieve('pi_****');
$intent->capture(['amount_to_capture' => 750]);
Transfer Payment
// Create a Transfer to a connected account (later):
$transfer = \Stripe\Transfer::create([
'amount' => 7000,
'currency' => 'inr',
'destination' => '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
'transfer_group' => '{ORDER10}',
]);
But it's not working properly because I'm getting following error.
Funds can't be sent to accounts located in IN because it's restricted outside of your platform's region;
Can someone please guide me to achieve my requirements.
It seems Stripe only accepts INR payouts within India.
Is your stripe account within India?
Stripe currently does not support the ability to receive INR payouts from Stripe accounts registered outside of India.
Stripe support documentation

Stripe Creating Direct Charges to connect account

I am trying to use stripe Direct Charges and it's working when user user new card (with token id).
Problem: When trying with save customer id and save card id. When i am trying to charge with custom-id and source=> save card id It's giving error customer not exist. But Both customer and card id exist.
$charge = \Stripe\Charge::create([
"customer" => $userdata->stripe_id,
"amount" => $amount,
"currency" => "usd",
"source" => $findcard['card_id'],
"application_fee" => $fee,
], ["stripe_account" => $talent_stripeid]);
Error: No such customer: cus_EOwmc6nVmU7oNu
I was getting the same error and when reached out to Stripe support got the following answer which helped me to solve the issue:
The error you are running into is happening because the customer
object is on the platform account, but when you add the
"Stripe-account" parameter to your charge request, you're moving the
command to the connected account, and so can't reach the customer
object.
To make the customer available, you'll need to share the customer to
the connected account. You'll basically create a token or source from
the customer object on your platform, and then share that with the
connected account, to process a payment, or to save locally, so the
connected account can use it directly.
https://stripe.com/docs/connect/shared-customers
Alternatively, you can keep the customer information on your platform
account and perform Destination charges, just sending to the connected
account "their share" of the proceeds:
https://stripe.com/docs/connect/destination-charges

stripe fund transfer not working properly

I am creating e-Com website. In which I am using stripe payment. The goal is we charge the user and then send amount to admin account and 80% of total charge transfer into vendor account.
The user payment working fine. In stripe admin account i can see the amount is increases per transaction. And vendor amount transfer is also working fine. In stripe admin account ,The Transfer link on left side showing all transfer history.
But when i login to vendor stripe account , I am getting $0 amount. Because transfer was not done.
Here is my transfer code:
$transfer = \Stripe\Transfer::create(array(
"currency" => "usd",
"recipient" => "rp_16lDd5AjH6fE1nozBz8hoQMY",
'amount' => $amount,
//'destination' => "ba_16lDe5AjH6fE1noz5V8oSTzU",
'destination' => "ba_16nn5nAjH6fE1nozX6xpp6JA",
"failure_message" => null,
"failure_code" => null,
)
);
It gives me success msg. After 2-7 days transfer amount not transferred into vendor stripe account. Please help me out.

Categories