Skip to content

Commit

Permalink
Merge pull request #539 from stripe/remi-add-checkout-sessions
Browse files Browse the repository at this point in the history
Add support for the Checkout Session resource
  • Loading branch information
remi-stripe authored Dec 21, 2018
2 parents dd64f37 + b9c31da commit 4e0da9c
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/resources/CheckoutSessions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = require('../StripeResource').extend({
path: 'checkout_sessions',
includeBasic: ['create'],
});

1 change: 1 addition & 0 deletions lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var resources = {
Balance: require('./resources/Balance'),
BitcoinReceivers: require('./resources/BitcoinReceivers'),
Charges: require('./resources/Charges'),
CheckoutSessions: require('./resources/CheckoutSessions'),
CountrySpecs: require('./resources/CountrySpecs'),
Coupons: require('./resources/Coupons'),
Customers: require('./resources/Customers'),
Expand Down
59 changes: 59 additions & 0 deletions test/resources/CheckoutSessions.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use strict';

var stripe = require('../../testUtils').getSpyableStripe();
var expect = require('chai').expect;

describe('CheckoutSessions Resource', function() {
describe('create', function() {
it('Sends the correct request', function() {
stripe.checkoutSessions.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',
});

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/checkout_sessions',
headers: {},
data: {
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',
},
});
});
});
});

0 comments on commit 4e0da9c

Please sign in to comment.