-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[15.x] Create stripe customer if not exists or update/sync (#1661)
* create stripe customer or if exists then update/sync * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
4235d5e
commit 70b581c
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,24 @@ public function test_customers_in_stripe_can_be_updated() | |
$this->assertEquals('Mohamed Said', $customer->description); | ||
} | ||
|
||
public function test_customers_in_stripe_can_be_created_or_updated() | ||
{ | ||
$user = $this->createCustomer('customers_in_stripe_can_be_created_or_updated'); | ||
|
||
$customer = $user->updateOrCreateStripeCustomer(['description' => 'Hello World']); | ||
|
||
// Created | ||
$this->assertEquals('Main Str. 1', $customer->address->line1); | ||
$this->assertEquals('Little Rock', $customer->address->city); | ||
$this->assertEquals('72201', $customer->address->postal_code); | ||
$this->assertEquals('Hello World', $customer->description); | ||
|
||
$customer = $user->updateOrCreateStripeCustomer(['description' => 'Random details']); | ||
|
||
// Updated | ||
$this->assertEquals('Random details', $customer->description); | ||
} | ||
|
||
public function test_customer_details_can_be_synced_with_stripe() | ||
{ | ||
$user = $this->createCustomer('customer_details_can_be_synced_with_stripe'); | ||
|
@@ -43,6 +61,33 @@ public function test_customer_details_can_be_synced_with_stripe() | |
$this->assertEquals('72201', $customer->address->postal_code); | ||
} | ||
|
||
public function test_customer_details_can_be_synced_or_created_with_stripe() | ||
{ | ||
$user = $this->createCustomer('customer_details_can_be_synced_or_created_with_stripe'); | ||
|
||
$customer = $user->syncOrCreateStripeCustomer(['description' => 'Hello World']); | ||
|
||
// Created | ||
$this->assertEquals('Main Str. 1', $customer->address->line1); | ||
$this->assertEquals('Little Rock', $customer->address->city); | ||
$this->assertEquals('72201', $customer->address->postal_code); | ||
$this->assertEquals('Hello World', $customer->description); | ||
|
||
$user->name = 'John Doe'; | ||
$user->email = '[email protected]'; | ||
$user->phone = '+32 499 00 00 00'; | ||
|
||
$customer = $user->syncOrCreateStripeCustomer(); | ||
|
||
// Synced | ||
$this->assertEquals('John Doe', $customer->name); | ||
$this->assertEquals('[email protected]', $customer->email); | ||
$this->assertEquals('+32 499 00 00 00', $customer->phone); | ||
$this->assertEquals('Main Str. 1', $customer->address->line1); | ||
$this->assertEquals('Little Rock', $customer->address->city); | ||
$this->assertEquals('72201', $customer->address->postal_code); | ||
} | ||
|
||
public function test_customers_can_generate_a_billing_portal_url() | ||
{ | ||
$user = $this->createCustomer('customers_can_generate_a_billing_portal_url'); | ||
|