Skip to content

Commit

Permalink
Cast variant_id before saving (#81)
Browse files Browse the repository at this point in the history
* Fix type of variant_id

* wip

---------

Co-authored-by: Dries Vints <[email protected]>
  • Loading branch information
matthiasweiss and driesvints authored Mar 26, 2024
1 parent 487e9da commit 5ed2c1d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Http/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public function handleOrderCreated(array $payload): void
$order = $billable->orders()->create([
'lemon_squeezy_id' => $payload['data']['id'],
'customer_id' => $attributes['customer_id'],
'product_id' => $attributes['first_order_item']['product_id'],
'variant_id' => $attributes['first_order_item']['variant_id'],
'product_id' => (string) $attributes['first_order_item']['product_id'],
'variant_id' => (string) $attributes['first_order_item']['variant_id'],
'identifier' => $attributes['identifier'],
'order_number' => $attributes['order_number'],
'currency' => $attributes['currency'],
Expand Down Expand Up @@ -135,8 +135,8 @@ public function handleSubscriptionCreated(array $payload): void
'type' => $custom['subscription_type'] ?? Subscription::DEFAULT_TYPE,
'lemon_squeezy_id' => $payload['data']['id'],
'status' => $attributes['status'],
'product_id' => $attributes['product_id'],
'variant_id' => $attributes['variant_id'],
'product_id' => (string) $attributes['product_id'],
'variant_id' => (string) $attributes['variant_id'],
'card_brand' => $attributes['card_brand'] ?? null,
'card_last_four' => $attributes['card_last_four'] ?? null,
'trial_ends_at' => $attributes['trial_ends_at'] ? Carbon::make($attributes['trial_ends_at']) : null,
Expand Down
4 changes: 2 additions & 2 deletions src/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public function sync(array $attributes): self
{
$this->update([
'customer_id' => $attributes['customer_id'],
'product_id' => $attributes['first_order_item']['product_id'],
'variant_id' => $attributes['first_order_item']['variant_id'],
'product_id' => (string) $attributes['first_order_item']['product_id'],
'variant_id' => (string) $attributes['first_order_item']['variant_id'],
'identifier' => $attributes['identifier'],
'order_number' => $attributes['order_number'],
'currency' => $attributes['currency'],
Expand Down
4 changes: 2 additions & 2 deletions src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ public function sync(array $attributes): self
{
$this->update([
'status' => $attributes['status'],
'product_id' => $attributes['product_id'],
'variant_id' => $attributes['variant_id'],
'product_id' => (string) $attributes['product_id'],
'variant_id' => (string) $attributes['variant_id'],
'card_brand' => $attributes['card_brand'] ?? null,
'card_last_four' => $attributes['card_last_four'] ?? null,
'pause_mode' => $attributes['pause']['mode'] ?? null,
Expand Down

0 comments on commit 5ed2c1d

Please sign in to comment.