how to use External account inside charge method of laravel cashier

  laravel, laravel-cashier, php, stripe-payments

I am using laravel cashier for an application where the user can subscribe in 3 ways

  • Montly
  • Yearly
  • One time

I am using create for Monthly and Yearly subscriptions and charge for one time.

The problem is I am not able to pass External Accounts details to the charge method(the amount should credit to this account from the user account) but for the create method it works perfectly.

For create I have used the below code, here the debited amount from the user will credit to the $subscriptionOptions account

$subscription = $request->user()->newSubscription('default', 'price_premium')->withMetaData(['name' => $app->name])->create(null, [
    'email' => $request->user()->email,
    'name'  => $request->user()->name,
    ['metadata' => ['name' => $app->name]],
], $subscriptionOptions);

For charge I have used the below code, here the debited amount from the user will not credit to the $subscriptionOptions account

$subscription = $request->user()->charge(200, $request->paymentMethodId, [
    'metadata' => [
        'app' => $app->name,
    ]
],$subscriptionOptions);

Can anyone help me out? Thank you.

Source: Laravel

Leave a Reply