Skip to content

Commit

Permalink
Add support for Checkout Sessions in beta
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Dec 19, 2018
1 parent ba85ad7 commit cee0680
Show file tree
Hide file tree
Showing 8 changed files with 54,994 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ php:
env:
global:
- STRIPE_MOCK_VERSION=0.39.0
- STRIPE_MOCK_PORT=12111
matrix:
- AUTOLOAD=1
- AUTOLOAD=0
Expand All @@ -37,9 +38,14 @@ before_install:
tar -zxf "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz" -C "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/"
fi
- |
stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/stripe-mock > /dev/null &
stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/stripe-mock \
-http-port ${STRIPE_MOCK_PORT} \
-spec tests/openapi/spec3.json \
-fixtures tests/openapi/fixtures3.json \
> /dev/null &
STRIPE_MOCK_PID=$!
script: ./build.php ${AUTOLOAD}

after_script: ./vendor/bin/coveralls -v

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' => '[email protected]',
],
'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
Loading

0 comments on commit cee0680

Please sign in to comment.