简体   繁体   中英

How to connect to managed account in stripe and make a payment?

First of all, I'm Sorry for my english.

I want to create a charge in Stripe from account A to account B. The account A is a mananaged account. The account B can be any of multiple accounts. But when I try to create the charge with the destination parameter the API resturn an error. Says:

"error": {
    "type": "invalid_request_error",
    "message": "The destination param must be a connected account.",
    "param": "destination"
  }

How I could connect the destination account (Account B) to get this??. I'm using the php api stripe to this. Next this is the example code that I using. Thanks in advance:

\Stripe\Stripe::setApiKey('sk_test_ACCOUNT_A_KEY');

// Charge the order:
$charge = \Stripe\Charge::create(array(
    // 'source'    => $token,
    'customer'  => 'cus_ID_CUSTOMER_TO_GET_PAYMENT',
    "amount" => 100000,
    "currency" => "usd",
    "description" => "from account A to account B",
    'destination' => 'acct_ID_DESTINATION_ACCOUNT'
    )
);

echo "<pre>";
print_r($charge);
echo "</pre>";

If you have gone through stripe documentations you clearly will have seen there are three types of charges in Stripe connect.

  • Direct Charges
  • Destination Charges
  • Seperate Charges

In your case, you will have to use destination charges. You could use

$charge = \Stripe\Charge::create(array(
                  "amount" => 1000,
                  "currency" => "usd",
                  "source" => "cus_ID_CUSTOMER_TO_GET_PAYMENT",
                  "destination" => array(
                    "account" => "{CONNECTED_STRIPE_ACCOUNT_ID}",
                  ),
            ));

to charge a customer on behalf of your connected account .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM