ayyanar pms
ayyanar pms

Reputation: 169

Stripe charge destination account in latest stripe API

I am using php stripe API, in my old stripe version i used below code to charge from customer and send amount to another stripe account

My logic: Let's say i'm a marketplace for example, i allow John to sell lamps online. Then, Alice comes and wants to buy a lamp from John on his website. i use the code mentioned below to charge Alice and send the funds to John's account directly.

FYI: i have shop owner John's stripe checkout card details like card token id, cardid

My old stripe version code:

 $charge = \Stripe\Charge::create(array(
            "amount" => 100,
            "currency" => "gbp",
            "source" => $token,
            "destination" => [
                "amount" => 20,
                "account" => 'xxxxx',
            ],
        ));

How to achieve above logic in new stripe version because above code not working.

Can anyone provide equivalent php code example please i'm struck here..

Code Updated:

 $account = \Stripe\Account::create(array(
                    "type" => "custom",
                    "country" => "GB",
                    "email" => $email,
                    'capabilities' => [
                        'card_payments' => ['requested' => true],
                        'transfers' => ['requested' => true],
                    ]
                   
        ));

i got following errors:

  1. Card payments, payouts and transfers are disabled for this account until a business type is added.

  2. Add a bank account or debit card to enable payouts.

How to resolve these errors using php stripe

Upvotes: 0

Views: 523

Answers (1)

Alexander
Alexander

Reputation: 1336

Does Jonh have a stripe account that is connected to yours?

Seems like in the new API you have to find the id of his account and do this:

$payment_intent = \Stripe\PaymentIntent::create([
  'payment_method_types' => ['card'],
  'amount' => 1000,
  'currency' => 'usd',
  'transfer_data' => [
    'destination' => '{{CONNECTED_STRIPE_ACCOUNT_ID}}',
  ],
]);

See the full documentation here: https://stripe.com/docs/connect/destination-charges

Upvotes: 1

Related Questions