-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.6] KTC-131 Subscriptions with Stripe #1973
Conversation
Apply fixes from StyleCI
app/GraphQL/Subscription/Mutations/SubscriptionItems/SubscriptionItemMutation.php
Outdated
Show resolved
Hide resolved
app/GraphQL/Subscription/Mutations/Subscriptions/SubscriptionMutation.php
Outdated
Show resolved
Hide resolved
app/GraphQL/Subscription/Mutations/Subscriptions/SubscriptionMutation.php
Outdated
Show resolved
Hide resolved
app/GraphQL/Subscription/Mutations/Subscriptions/SubscriptionMutation.php
Outdated
Show resolved
Hide resolved
src/Domains/Subscription/SubscriptionItems/DataTransferObject/SubscriptionItem.php
Outdated
Show resolved
Hide resolved
src/Domains/Subscription/Subscriptions/Observers/SubscriptionObserver.php
Outdated
Show resolved
Hide resolved
Apply fixes from StyleCI
Apply fixes from StyleCI
src/Domains/Subscription/Subscriptions/Actions/CreateSubscription.php
Outdated
Show resolved
Hide resolved
Refact subscription hdnel
public function create(array $req): PriceModel | ||
{ | ||
$app = app(Apps::class); | ||
$stripeProduct = StripeProduct::create([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if Stripe has validation for not create duplicate records?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each product or price has a different ID in Stripe even if it has the same name and detail. That's why en is linked by the Stripe price_id.
return new Plan(); | ||
} | ||
|
||
public static function getByIdWithApp(int $id, ?AppInterface $app = null): Model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this functionality in the base model Check this file
public static function getByIdWithApp(int $id, AppInterface $app): Price | ||
{ | ||
try { | ||
return self::getModel()::notDeleted() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do it different
$price = Kanvas\Subscription\Prices\Models\Price::getById($id, $app);
$plan = $price->plan;
In Laravel , when you use eloquent queries, all relationships are retrieved in the result, in this case plan, and you can access to it with maggic attribute plan
Also our models has default relationships
- user
- company
- app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using companies subscriptions to apps, you can have prices/plans without a relationship with a company and user, because plans/prices belong to apps, companies can subscribe to apps, so you can have plans/prices that companies are not using so not relationship
$prices = [ | ||
[ | ||
'apps_plans_id' => 1, | ||
'stripe_id' => 'price_1Q11XeBwyV21ueMMd6yZ4Tl5', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This id, I believe that is move to env, @kaioken can be add this id to the test env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, good job 😊😁
Ktc 131 update dev
General:
Management of plans, prices, subscriptions, and items using Stripe. The GraphQL mutations allow creating, updating, and deleting these resources both in Stripe and the database.
Tasks:
Requirements:
Considerations: