Skip to content

Commit

Permalink
Move CheckoutSession to the Checkout namespace and rename to Session
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Jan 17, 2019
1 parent 61b931b commit 9a4eb15
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 67 deletions.
8 changes: 8 additions & 0 deletions lib/resources/Checkout/Sessions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var StripeResource = require('../../StripeResource');

module.exports = StripeResource.extend({
path: 'checkout/sessions',
includeBasic: ['create'],
})
7 changes: 0 additions & 7 deletions lib/resources/CheckoutSessions.js

This file was deleted.

4 changes: 3 additions & 1 deletion lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ 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 Expand Up @@ -83,6 +82,9 @@ var resources = {
TransferReversals: require('./resources/TransferReversals'),

// Namespaced resources
Checkout: resourceNamespace('checkout', {
Sessions: require('./resources/Checkout/Sessions'),
}),
Issuing: resourceNamespace('issuing', {
Authorizations: require('./resources/Issuing/Authorizations'),
Cardholders: require('./resources/Issuing/Cardholders'),
Expand Down
62 changes: 62 additions & 0 deletions test/resources/Checkout/Sessions.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';

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

var expect = require('chai').expect;

describe('Checkout', function () {
describe('Sessions 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: 'test@stripe.com',
},
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: 'test@stripe.com',
},
success_url: 'https://stripe.com/success',
},
});
});
});
});
});
59 changes: 0 additions & 59 deletions test/resources/CheckoutSessions.spec.js

This file was deleted.

0 comments on commit 9a4eb15

Please sign in to comment.