-
Notifications
You must be signed in to change notification settings - Fork 756
Migration guide for v7
Version 7 of stripe's Node.js library contains some backwards incompatible changes. This guide will help you update your Stripe integration so that it keeps working as expected after you upgrade to v7.
The library no longer supports Node 4, 5, 7 or 9, all of which have reached end-of-life (EOL) and no longer receive security updates.
Currently supported versions are: 6.0 or higher, 8.1 or higher, and 10.0 or higher. While we continue to support Node 6 due to its broad usage, note that it has also reached EOL and we encourage upgrading as soon as possible.
We recommend using Node v10.13.0 (LTS) or higher.
The following table contains the list of deprecated methods which have been removed, as well as their replacement.
Removed method | Replacement | Documentation |
---|---|---|
applicationFees.refund(feeId, params) |
applicationFees.createRefund(feeId, params) |
Link |
balance.listTransactions() |
balanceTransactions.list() |
Link |
balance.retrieveTransaction() |
balanceTransactions.retrieve() |
Link |
chargeRefunds.create() |
refunds.create() |
Link |
chargeRefunds.retrieve() |
refunds.retrieve() |
Link |
chargeRefunds.update() |
refunds.update() |
Link |
chargeRefunds.list() |
refunds.list() |
Link |
charges.refund(chargeId) |
refunds.create({charge: chargeId}) |
Link |
charges.createRefund(chargeId) |
refunds.create({charge: chargeId}) |
Link |
charges.retrieveRefund(chargeId, refundId) |
refunds.retrieve(refundId) |
Link |
charges.updateRefund(chargeId, refundId, params) |
refunds.update(refundId, params) |
Link |
charges.listRefunds(chargeId) |
refunds.list({charge: chargeId}) |
Link |
charges.updateDispute(chargeId, params) |
disputes.update(disputeId, params) |
Link |
charges.closeDispute(chargeId) |
disputes.close(disputeId) |
Link |
charges.markAsSafe(id) |
charge.update(id, {fraud_details: {user_report: 'safe'}}) |
Link |
charges.markAsFraudulent(id) |
charge.update(id, {fraud_details: {user_report: 'fraudulent'}}) |
Link |
customerCards.create() |
customers.createSource() |
Link |
customerCards.del() |
customers.deleteSource() |
Link |
customerCards.list() |
customers.listSources() |
Link |
customerCards.retrieve() |
customers.retrieveSource() |
Link |
customerCards.update() |
customers.updateSource() |
Link |
customers.createCard() |
customers.createSource() |
Link |
customers.retrieveCard() |
customers.retrieveSource() |
Link |
customers.updateCard() |
customers.updateSource() |
Link |
customers.deleteCard() |
customers.deleteSource() |
Link |
customers.listCards() |
customers.listSources({object: 'card'}) |
Link |
customers.createSubscription() |
subscriptions.create() |
Link |
customers.retrieveSubscription() |
subscriptions.retrieve() |
Link |
customers.updateSubscription() |
subscriptions.update() |
Link |
customers.deleteSubscriptionDiscount() |
subscriptions.deleteDiscount() |
Link |
customers.listSubscriptions() |
subscriptions.list() |
Link |
customers.cancelSubscription() |
subscriptions.del() |
Link |
customerSubscriptions.create() |
subscriptions.create() |
Link |
customerSubscriptions.retrieve() |
subscriptions.retrieve() |
Link |
customerSubscriptions.update() |
subscriptions.update() |
Link |
customerSubscriptions.cancel() |
subscriptions.del() |
Link |
customerSubscriptions.list() |
subscriptions.list() |
Link |
fileUploads.create() |
files.create() |
Link |
fileUploads.retrieve() |
files.retrieve() |
Link |
fileUploads.list() |
files.list() |
Link |
invoices.retrieveLines() |
invoices.listLineItems() |
Link |
payouts.listTransactions(payoutId) |
balanceTransactions.list({payout: payoutId}) |
Link |
recipientCards.create() |
None, use Connect instead | Link |
recipientCards.retrieve() |
None, use Connect instead | Link |
recipientCards.update() |
None, use Connect instead | Link |
recipientCards.del() |
None, use Connect instead | Link |
recipientCards.list() |
None, use Connect instead | Link |
recipients.createCard() |
None, use Connect instead | Link |
recipients.retrieveCard() |
None, use Connect instead | Link |
recipients.updateCard() |
None, use Connect instead | Link |
recipients.deleteCard() |
None, use Connect instead | Link |
recipients.listCards() |
None, use Connect instead | Link |
transfers.cancel(transferId) |
payouts.cancel(payoutId) |
Link |
transfers.listTransactions(transferId) |
balanceTransactions.list({payout: payoutId}) |
Link |
transfers.reverse() |
transfers.createReversal() |
Link |
The getMetadata()
and setMetadata()
methods have been removed on all resources.
Metadata can be retrieved using the standard retrieve()
and list()
methods, and set using the standard create()
and update()
methods.
// Before:
stripe.charges.setMetadata(charge.id, {foo: 'bar'});
// After:
stripe.charges.update(charge.id, {metadata: {foo: 'bar'}});
// Before:
stripe.charges.getMetadata(charge.id).then((metadata) => {
console.log(metadata.foo);
});
// After:
stripe.charges.retrieve(charge.id).then((charge) => {
console.log(charge.metadata.foo);
})
Previously, it was possible to access "nested" resources using this form:
const transferReversals = new resources.TransferReversal(stripe, {transferId: 'tr_123'});
transferReversals.update('trr_123', params);
This is no longer possible. Nested resources must now be accessed via methods on their parent resources:
stripe.transfers.updateReversal('tr_123', 'trr_123', params);
-
The
invoices.retrieveUpcoming()
method now accepts a single argument, an object with all the request parameters. Previously the customer ID and subscription ID could be passed as strings before the rest of the parameters.// Before: invoices.retrieveUpcoming('sub_123', params); // After: invoices.retrieveUpcoming({subscription: 'sub_123', ...params}); // Before: invoices.retrieveUpcoming('cus_123', params); // After: invoices.retrieveUpcoming({customer: 'cus_123', ...params});