Stripe Payment gateway - php

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

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.

Payment Intent issues Stripe Connect

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']
);

Transfer amount into customer's bank account using Stripe Payout API

I am working on an implementation of REST API for a mobile application which encapsulates feature of redemption of earned points in form of money equivalent to points using Stripe as a payment gateway .
To accomplish it I have used Stripe payout API to transfer amount directly into destination bank account.
Following is code snippet of call to payout API of Stripe
$payout=\Stripe\Payout::create(array(
"amount" => 400,
"currency" => "usd",
"destination"=>$ID,/* ID of customer bank account ba_1CIZEOCHXaXPEwZByNehIJrY */
"source_type"=>'bank_account'
));
Upon execution of above code snippet I receive error message as response to call of payout API
The bank account ba_1CIZEOCHXaXPEwZByNehIJrY is not attached to this
Stripe account. External accounts can only be attached to Standard
accounts via the dashboard.
According to above error message it seems that same bank account needs to be attached to both customer and connected stripe account but I am unable to find appropriate solution to attach customer's bank account to merchant as an external account.
Please suggest me an appropriate solution to it.
Actually you can use the Stripe payout API to initiate a payout to either a bank account or debit card of a connected Stripe account.However you can create a transfer , To send funds from your Stripe account to a connected account.
https://stripe.com/docs/api/transfers/create
Below is the php code :
\Stripe\Stripe::setApiKey("sk_test_AjtBCFvy8Ah0x5vLmd5Ntemi");
\Stripe\Transfer::create([
"amount" => 400,
"currency" => "usd",
"destination" => "acct_1CPuerJ18us5u9z6",
"transfer_group" => "ORDER_95"
]);
I have also searched stripe documentation , to directly transfer the payment in the third party card / bank account, but did not find anything.
With Stripe Connect, you can make API requests on behalf of connected accounts using the Stripe-Account header as documented here. This applies to any API requests from creating a Charge or a Payout to listing all Refunds.
This obviously assumes that you use Stripe Connect and that the person receiving funds from you has their own connected accounts. You also have to use Custom or Express accounts if you want to be able to control their Payouts. This is not allowed with Standard accounts.
The code would look like this:
$payout=\Stripe\Payout::create(array(
"amount" => 400,
"currency" => "usd",
"destination"=> "ba_XXXX" // bank account id
),
array(
"stripe_account" => "acct_XXXX" // id of the connected account
));
This obviously assumes that you are familiar with Stripe Connect and are actively using it. It would be the only way to handle this and you can read more about this feature here.

Stripe send payment to connected accounts within platform

The scenario is there are 3 users in our website, Admin, Sender and Receiver.
Sender send payments to Receiver, but in our website Sender not directly send the payment to Receiver, the amount holds on Admin Stripe account and after the confirmation Receiver receive the payment from Admin Stripe account. For this process I create a platform from Admin Stripe Account , now Sender and Receiver both are connected to that platform.
Below are the codes we are using:
Sender Send Payment To Admin Strip Account
\Stripe\Stripe::setApiKey("sk_test_ADMIN_KEY");
\Stripe\Charge::create(array(
"amount" => 400,
"currency" => "usd",
"source" => "tok_18uL5yIXv4Heg2KDdPHJFo8A", // obtained with Stripe.js
"description" => "Charge for abigail.white#example.com"
));
Receiver Receive Payment From Admin Stripe Account
\Stripe\Stripe::setApiKey("sk_test_ADMIN_KEY.....");
\Stripe\Charge::create(array(
'amount' => 400,
'currency' => 'usd',
'source' => $token,
'destination' => 'acct_...' //
));
and more all of three users have their stripe accounts, and on test mode all of three have $0 Available Balance. and Amount is not added to Receiver Stripe Account after using the above code.
When accepting payments on behalf of third-parties, you cannot hold funds on the platform's account ("Admin"). For compliance reasons, you must set the destination account when you create the charge.
\Stripe\Stripe::setApiKey("sk_test_..."); // platform's API key
\Stripe\Charge::create(array(
'amount' => 400,
'currency' => 'usd',
'source' => $token,
'destination' => 'acct_...' // connected account's ID
));
This will charge the customer (via the payment method in $token) and add the funds to the connected account's balance. Once the funds become available, they can be transferred account to the connected account's associated bank account.
Note that because this charge is created "through the platform" (i.e. with the destination parameter), the platform will pay Stripe's fees and be responsible for chargebacks and refunds (cf. here). Because there is no application_fee parameter, the platform will effectively lose money on this transaction, as it will pay for Stripe's fees but not receive anything.
If you're using managed accounts, then you (as the platform) are also in control of transfers to the associated bank account. You can read more about this here.
With standalone accounts, the platform does not have control over bank transfers -- instead, each standalone account's owner does, via their own account settings.

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