I have successfully created a subscription using Laravel Cashier however I have a problem regarding the payouts.
My use case is that I collect the amount from the user in a form of a subscription and then after specific action of the user, a certain amount is transferred further to the vendor. I am using Manual Transfers for payouts and it seems it has everything I need (https://stripe.com/docs/connect/charges-transfers).
However in order to create a transfer from one Stripe account to another I have to assign a field "transfer_group" to my charge. Since I'm not using Charge for my subscriptions but Cashiers methods I don't have this option.
Looking into the implementation of "newSubscription" method or "create" method inside Billable class I couldn't find anything where I could pass this. Can this be achieved or I have to reimplement my subscription using plain Stripe SDK?
Here's how my subscription code looks like:
$response = $customer->newSubscription($plan->name, $plan->plan_id)->create($request->token, [
'email' => $user['profile']['email'],
'description' => $user['profile']['biography'],
'metadata' => [
'name' => $user['profile']['name'],
'uuid' => $request->uuid
]
]);
All these options passed here are related to a Customer object and not Charge. According to Stripe docs I need something like:
$charge = \Stripe\Charge::create(array(
"amount" => 10000,
"currency" => "eur",
"source" => "tok_visa",
"transfer_group" => "{ORDER10}",
));
Since you don't control the charge creation here, you won't be able to pass transfer_group
. What you should do instead is pass source_transaction: "ch_XXXX"
when you create the transfer via the API. This will ensure that the Transfer is associated with the charge associated with the subscription and suit Stripe's requirements.
This is documented directly in Stripe docs here.