Skip to content

Commit 2ff020c

Browse files
[2.x] Protect against duplication of customer (#234)
* Protect against duplication of customer * wip * Update ManagesCustomer.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent ce4f40f commit 2ff020c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Concerns/ManagesCustomer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public function createAsCustomer(array $options = [])
4545
$response = Cashier::api('POST', 'customers', $options)['data'];
4646
}
4747

48+
if (Cashier::$customerModel::where('paddle_id', $response['id'])->exists()) {
49+
throw new LogicException("The Paddle customer [{$response['id']}] already exists in the database.");
50+
}
51+
4852
$customer = $this->customer()->make();
4953
$customer->paddle_id = $response['id'];
5054
$customer->name = $response['name'];

src/Concerns/PerformsCharges.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public function checkout($prices, int $quantity = 1)
3030
*/
3131
public function subscribe($prices, string $type = Subscription::DEFAULT_TYPE)
3232
{
33-
return $this->checkout($prices, 1)->customData(['subscription_type' => $type]);
33+
return $this->checkout($prices)->customData(['subscription_type' => $type]);
3434
}
3535
}

0 commit comments

Comments
 (0)