UNPKG

mangopay4-nodejs-sdk

Version:

Mangopay Node.js SDK

104 lines (87 loc) • 3.47 kB
const Service = require('../service'); const ExtendedPreauthorization = require('../models/ExtendedPreauthorization'); const PayPalExtendedPreauthorization = require('../models/PayPalExtendedPreauthorization'); const ExtendedPreauthorizations = Service.extend({ /** * Create an Extended Preauthorization */ create: function(extendedPreauthorization, callback, options) { options = this._api._getOptions(callback, options, { data: extendedPreauthorization, dataClass: ExtendedPreauthorization }); return this._api.method('extended_preauthorizations_create', callback, options); }, /** * Create a PayPal Extended Preauthorization */ createPayPalPreauthorization: function(extendedPreauthorization, callback, options) { options = this._api._getOptions(callback, options, { data: extendedPreauthorization, dataClass: PayPalExtendedPreauthorization }); return this._api.method('extended_preauthorizations_paypal_create', callback, options); }, /** * Get an Extended Preauthorization */ get: function(extendedPreauthorizationId, callback, options) { options = this._api._getOptions(callback, options, { path: { extendedPreauthorizationId: extendedPreauthorizationId }, dataClass: ExtendedPreauthorization }); return this._api.method('extended_preauthorizations_get', callback, options); }, /** * Get all extended preauthorizations for a card */ getAllForCard: function(cardId, callback, options) { options = this._api._getOptions(callback, options, { path: { cardId: cardId } }); return this._api.method('extended_preauthorizations_get_all_for_card', callback, options); }, /** * Get all extended preauthorizations for a user */ getAllForUser: function(userId, callback, options) { options = this._api._getOptions(callback, options, { path: { userId: userId } }); return this._api.method('extended_preauthorizations_get_all_for_user', callback, options); }, /** * Update an Extended Preauthorization (set PaymentStatus to CANCELED) */ update: function(extendedPreauthorizationUpdate, callback, options) { if (!extendedPreauthorizationUpdate.Id) { this._api.errorHandler('Cannot update extended preauthorization, the Id is missing'); } options = this._api._getOptions(callback, options, { path: { extendedPreauthorizationId: extendedPreauthorizationUpdate.Id }, data: extendedPreauthorizationUpdate, dataClass: ExtendedPreauthorization }); return this._api.method('extended_preauthorizations_update', callback, options); }, /** * Get all transactions for an extended preauthorization */ getTransactions: function(extendedPreauthorizationId, callback, options) { options = this._api._getOptions(callback, options, { path: { extendedPreauthorizationId: extendedPreauthorizationId } }); return this._api.method('extended_preauthorizations_get_transactions', callback, options); }, }); module.exports = ExtendedPreauthorizations;