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 cancel support for topups #485

Merged
merged 1 commit into from
Aug 3, 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
7 changes: 7 additions & 0 deletions lib/resources/Topups.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
'use strict';

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

module.exports = StripeResource.extend({
path: 'topups',
includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'],

cancel: stripeMethod({
method: 'POST',
path: '{topupId}/cancel',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test seem to confirm it works but other files have a leading / in the path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we seem to be a little inconsistent on this right now — looking through other examples in the library, it seems that both work.

urlParams: ['topupId'],
}),
});
12 changes: 12 additions & 0 deletions test/resources/Topups.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ describe('Topup Resource', function() {
});
});

describe('cancel', function() {
it('Sends the correct request', function() {
stripe.topups.cancel('tu_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/topups/tu_123/cancel',
headers: {},
data: {},
});
});
});

describe('update', function() {
it('Sends the correct request', function() {
stripe.topups.update('tu_123', {metadata: {'key': 'value'}});
Expand Down