#fakhrul.islam
1 messages · Page 1 of 1 (latest)
Hi
But the problem is that the recurring billing doesn't work
Can you share more details about your integration and what is the problem exactly ?
Are you willing to use Stripe Checkout or Stripe Elements ?
Here is my code for last step of subscription
$subscription_product = \Stripe\Product::create(
[
'name' => 'New shop subscription for BUYNOIR',
'default_price_data' => [
'unit_amount' => ($cart['amount']*100),
'currency' => 'usd',
'recurring' => ['interval' => $cart['period_unit']],
],
'expand' => ['default_price'],
]
);
$subscription_price = \Stripe\Price::create([
'unit_amount' => ($cart['amount']*100),
'currency' => 'usd',
'recurring' => ['interval' => $cart['period_unit']],
'product' => $subscription_product->id,
]);
// Create a new customer object
$customerResponse = \Stripe\Customer::create([
'email' => Company::getCurrent()->email
]);
$result = \Stripe\Subscription::create([
'customer' => $customerId,
'items' => [[
'price' => $priceId,
]],
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
'description' => 'Your subscription to package has been successfully processed and confirmed!',
]);
Thanks for sharing this. You should be following this Guide:
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
According to your code, you should continue with Step 6 for now:
https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements#collect-payment
Thank you very much.
Np!