Class: PurchaseService

Defined in: src/service/purchase.coffee

Overview

Handles purchase of goods for users.

Instance Method Summary

Instance Method Details

- (Object) purchase(params)

Purchase a good for a user.

Parameters:

  • params (Object) — Arguments to the purchase.

Options Hash: (param):

  • good (String) — The label of a good to purchase
  • allGoods (Array<Object>) — All goods available, e.g. from Totem#goods
  • userGoods (Array<Object>) — Goods the user already owns, e.g. from AuthorizedUser#goods
  • user (AuthorizedUser) — A [AuthorizedUser AuthorizedUser] on behalf of whom to purchase the good
  • paymentService (Object) — An object with method purchase, taking parameters userId, goodId, callback(err, res), which will call back with either an [Error] or a response
  • confStrategy (Function) — A function accepting arguments user, goodId, paymentResponse, which will ensure that the purchase has been accepted by HAPI. The function should return a promise, resolving with any [Error] raised during the confirmation process.

Returns:

  • (Object) — A promise, resolving to an object error:<Error>, response: