Skip to content

Commit

Permalink
Update checkout method names
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Oct 8, 2020
1 parent db641b4 commit 179218c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
30 changes: 15 additions & 15 deletions src/Concerns/PerformsCharges.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,45 +60,45 @@ public function refund($paymentIntent, array $options = [])
}

/**
* Begin a new Checkout Session.
* Begin a new Checkout Session for an existing Price ID.
*
* @param int $amount
* @param string $name
* @param string $price
* @param int $quantity
* @param array $sessionOptions
* @param array $customerOptions
* @return \Laravel\Cashier\Checkout
*/
public function checkout($amount, $name, $quantity = 1, array $sessionOptions = [], array $customerOptions = [])
public function checkout($price, $quantity = 1, array $sessionOptions = [], array $customerOptions = [])
{
return Checkout::create($this, array_merge([
'line_items' => [[
'price_data' => [
'currency' => $this->preferredCurrency(),
'product_data' => [
'name' => $name,
],
'unit_amount' => $amount,
],
'price' => $price,
'quantity' => $quantity,
]],
], $sessionOptions), $customerOptions);
}

/**
* Begin a new Checkout Session.
* Begin a new Checkout Session for a "one-off" charge.
*
* @param string $price
* @param int $amount
* @param string $name
* @param int $quantity
* @param array $sessionOptions
* @param array $customerOptions
* @return \Laravel\Cashier\Checkout
*/
public function checkoutProduct($price, $quantity = 1, array $sessionOptions = [], array $customerOptions = [])
public function checkoutCharge($amount, $name, $quantity = 1, array $sessionOptions = [], array $customerOptions = [])
{
return Checkout::create($this, array_merge([
'line_items' => [[
'price' => $price,
'price_data' => [
'currency' => $this->preferredCurrency(),
'product_data' => [
'name' => $name,
],
'unit_amount' => $amount,
],
'quantity' => $quantity,
]],
], $sessionOptions), $customerOptions);
Expand Down
28 changes: 14 additions & 14 deletions tests/Feature/CheckoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@

class CheckoutTest extends FeatureTestCase
{
public function test_customers_can_start_a_checkout_session()
{
$user = $this->createCustomer('customers_can_start_a_checkout_session');

$checkout = $user->checkout(1200, 'T-shirt', 1, [
'success_url' => 'http://example.com',
'cancel_url' => 'http://example.com',
]);

$this->assertInstanceOf(Checkout::class, $checkout);
$this->assertInstanceOf(StripeCheckoutSession::class, $checkout->asStripeCheckoutSession());
}

public function test_customers_can_start_a_product_checkout_session()
{
$user = $this->createCustomer('customers_can_start_a_product_checkout_session');
Expand All @@ -33,7 +20,20 @@ public function test_customers_can_start_a_product_checkout_session()
'unit_amount' => 1500,
]);

$checkout = $user->checkoutProduct($price->id, 1, [
$checkout = $user->checkout($price->id, 1, [
'success_url' => 'http://example.com',
'cancel_url' => 'http://example.com',
]);

$this->assertInstanceOf(Checkout::class, $checkout);
$this->assertInstanceOf(StripeCheckoutSession::class, $checkout->asStripeCheckoutSession());
}

public function test_customers_can_start_a_one_off_charge_checkout_session()
{
$user = $this->createCustomer('customers_can_start_a_one_off_charge_checkout_session');

$checkout = $user->checkoutCharge(1200, 'T-shirt', 1, [
'success_url' => 'http://example.com',
'cancel_url' => 'http://example.com',
]);
Expand Down

0 comments on commit 179218c

Please sign in to comment.