Skip to content
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

Add support for Checkout Sessions #571

Merged
merged 1 commit into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ php:

env:
global:
- STRIPE_MOCK_VERSION=0.39.0
- STRIPE_MOCK_VERSION=0.40.0
matrix:
- AUTOLOAD=1
- AUTOLOAD=0
Expand Down
1 change: 1 addition & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
require(dirname(__FILE__) . '/lib/BitcoinTransaction.php');
require(dirname(__FILE__) . '/lib/Card.php');
require(dirname(__FILE__) . '/lib/Charge.php');
require(dirname(__FILE__) . '/lib/CheckoutSession.php');
require(dirname(__FILE__) . '/lib/Collection.php');
require(dirname(__FILE__) . '/lib/CountrySpec.php');
require(dirname(__FILE__) . '/lib/Coupon.php');
Expand Down
20 changes: 20 additions & 0 deletions lib/CheckoutSession.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Stripe;

/**
* Class CheckoutSession
*
* @property string $id
* @property string $object
* @property bool $livemode
*
* @package Stripe
*/
class CheckoutSession extends ApiResource
{

const OBJECT_NAME = "checkout_session";

use ApiOperations\Create;
}
1 change: 1 addition & 0 deletions lib/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static function convertToStripeObject($resp, $opts)
\Stripe\BitcoinTransaction::OBJECT_NAME => 'Stripe\\BitcoinTransaction',
\Stripe\Card::OBJECT_NAME => 'Stripe\\Card',
\Stripe\Charge::OBJECT_NAME => 'Stripe\\Charge',
\Stripe\CheckoutSession::OBJECT_NAME => 'Stripe\\CheckoutSession',
\Stripe\CountrySpec::OBJECT_NAME => 'Stripe\\CountrySpec',
\Stripe\Coupon::OBJECT_NAME => 'Stripe\\Coupon',
\Stripe\Customer::OBJECT_NAME => 'Stripe\\Customer',
Expand Down
36 changes: 36 additions & 0 deletions tests/Stripe/CheckoutSessionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Stripe;

class CheckoutSessionTest extends TestCase
{
public function testIsCreatable()
{
$this->expectsRequest(
'post',
'/v1/checkout_sessions'
);
$resource = CheckoutSession::create([
'allowed_source_types' => ['card'],
'cancel_url' => 'https://stripe.com/cancel',
'client_reference_id' => '1234',
'line_items' => [
[
'amount' => 123,
'currency' => 'usd',
'description' => 'item 1',
'images' => [
'https://stripe.com/img1',
],
'name' => 'name',
'quantity' => 2,
],
],
'payment_intent_data' => [
'receipt_email' => 'test@stripe.com',
],
'success_url' => 'https://stripe.com/success'
]);
$this->assertInstanceOf('Stripe\\CheckoutSession', $resource);
}
}
1 change: 0 additions & 1 deletion tests/Stripe/CustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public function testCanDeleteSource()
'/v1/customers/' . self::TEST_RESOURCE_ID . '/sources/' . self::TEST_SOURCE_ID
);
$resource = Customer::deleteSource(self::TEST_RESOURCE_ID, self::TEST_SOURCE_ID);
$this->assertInstanceOf("Stripe\\AlipayAccount", $resource);
}

public function testCanListSources()
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

define("MOCK_MINIMUM_VERSION", "0.39.0");
define("MOCK_MINIMUM_VERSION", "0.40.0");
define("MOCK_PORT", getenv("STRIPE_MOCK_PORT") ?: 12111);

// Send a request to stripe-mock
Expand Down