Open cgsmith opened 1 year ago
@cgsmith Pushed some latest changes - https://github.com/CGSmith-LLC/shipwise-api/compare/master...feature/stripe-billing-and-invoicing Docs are updated. // FYI
I'm going to finish the webhooks implementation and the {payment/subscription management} via the customer portal.
I added logic for working with Stripe webhooks, but, since we already have similar logic for Shopify, it would be great to combine some parts. I've created https://github.com/CGSmith-LLC/shipwise-api/issues/177 for this. Once, these two branches are merged, I will implement this.
SubscriptionService
subscription history
StripeCheckoutSessionCompletedJob
Working on:
/subscription
page based on the changes for subscription history
(active subscription is stored here)@cgsmith
/subscription
page (screenshot below)Working on:
Thanks @bohdan-vorona let me review what you currently have. I think you might be adding more of a direct integration instead of leveraging their customer portal.
No problem if you did!
Check - Stripe (webhooks + Dashboard):
Check - website:
@cgsmith In general, I've finished the main part of Stripe integration. Implemented the following webhooks: _customer.deleted, checkout.session.completed, customer.subscription.created, customer.subscription.trial_willend, customer.subscription.deleted, customer.subscription.updated.
I'm working on usage-based measurement.
Some moments I need help with:
$customer = Customer::findOne(1); // I find the first customer
$subscriptionService = new SubscriptionService($customer);
How shall I determine the current customer? As I see, in the User
model we have such code:
public function getCustomerId()
{
return $this->customer_id;
}
But also, as I see, one user can have several customers:
public function getCustomerIds()
{
return ArrayHelper::getColumn(
$this->hasMany('frontend\models\UserCustomer', ['user_id' => 'id'])
->select('customer_id')
->asArray()
->all(),
'customer_id');
}
So, shall I use the field customer_id
from the user
table or ...?
if (!Yii::$app->session->has($module->switchIdentitySessionKey) &&
!Yii::$app->user->identity->isAdmin &&
Yii::$app->user->identity->isDirectCustomer()) {
// code...
}
I left all these checks for my logic too. Is it correct? It means that I will check the current active subscription only if it's not an admin and is a direct customer and it's not switching between users.
I can propose not showing our header and footer when the user sees the pricing widget. Just add a neat button Back + Logo or something like that.
Menu:
Subscription page:
Active trial:
Active subscription:
Thx for subscribing:
Redirect if no active subscription:
Stripe qty usage:
Is your feature request related to a problem? Please describe. Billing right now is partly done through Stripe and manually done through Quickbooks. I want to use Stripe for everything billing out of Shipwise. The current integration is fairly broken and just adds credit cards. It also handles the invoicing but doesn't enroll them in the subscription.
Describe the solution you'd like No migrations are necessary as I will be informing the customers of the new subscriptions and terms. They will then choose a plan and be subscribed.
I created a subscription for testing in Stripe under the test mode. Test subscription
Additional context Useful documentation:
Stripe Subscription Documentation Stripe Customer Portals
Loom explanation for @bohdan-vorona Video