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

CheckoutPricing: Coupons #385

Merged
merged 45 commits into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
95a861e
Adds CheckoutPricing#coupon
chrissrogers Oct 26, 2017
e4c5f81
Adds CheckoutPricing discount calculations
chrissrogers Oct 26, 2017
f3be292
Updates recurly.coupon for new endpoint
chrissrogers Oct 27, 2017
e26485d
Removes component-type
chrissrogers Oct 27, 2017
53b622b
Updates coupon module structure
chrissrogers Oct 27, 2017
75af47d
Updates CheckoutPricing for new coupon getter
chrissrogers Oct 27, 2017
0f84178
Updates coupon specs for new endpoint
chrissrogers Oct 27, 2017
c513752
Adds recurly.pipedRequest
chrissrogers Oct 28, 2017
2e73e2a
Adds multiple plan code support to coupon getter
chrissrogers Oct 28, 2017
b8df59c
Fixes argument syntax
chrissrogers Nov 1, 2017
8503c99
Updates CheckoutPricing coupon handler for new types
chrissrogers Nov 2, 2017
b75213f
Improves recurly.pipedRequest response handling
chrissrogers Nov 2, 2017
19f22f9
Adds spec plans
chrissrogers Nov 2, 2017
adb4523
Updates SubscriptionPricing.coupon to receive objects
chrissrogers Nov 4, 2017
bd08d09
Fixes CheckoutPricing plan currency handling
chrissrogers Nov 4, 2017
712f670
Fixes CheckoutPricing/Calculations sub calculation safety
chrissrogers Nov 4, 2017
4430bb4
Adds EmbeddedSubscriptionPricing
chrissrogers Nov 4, 2017
2a96fa2
Fixes SubscriptionPricing reprice safety
chrissrogers Nov 4, 2017
06b62b8
Fixes CheckoutPricing/Calculations trial detection
chrissrogers Nov 4, 2017
73b6e63
Ensures subscription safety in CheckoutPricing/Calculations
chrissrogers Nov 4, 2017
0fab807
Applies Promise pattern to CheckoutPricing/Calculations
chrissrogers Nov 5, 2017
3860f7f
Fixes checkout pricing free trial coupon application
chrissrogers Nov 6, 2017
fcb7da7
Adds adjustment code uniqueness validator
chrissrogers Nov 6, 2017
c1b7e07
Adds reprice silence option
chrissrogers Nov 6, 2017
18eca38
Narrows scope of reprice event silencer
chrissrogers Nov 6, 2017
576644b
Fixes itemization collector for checkouts with sub discounts
chrissrogers Nov 6, 2017
a04476b
Documentation
chrissrogers Nov 6, 2017
59008b8
Cleans up unused variables
chrissrogers Nov 6, 2017
580312e
Fixes CheckoutPricing/Calculations plan-specific discount filter
chrissrogers Nov 6, 2017
b2181c8
Fixes coupon specs
chrissrogers Nov 6, 2017
2fff200
Fixes SubscriptionPricing.reprice
chrissrogers Nov 6, 2017
70b3b98
Adds coupon validity detection for new endpoint
chrissrogers Nov 6, 2017
31a01ed
Fixes coupon fixtures
chrissrogers Nov 6, 2017
fbb652c
Fixes coupon validity method safety
chrissrogers Nov 6, 2017
dc8ecdf
Fixes pipedRequest for empty sets
chrissrogers Nov 7, 2017
eb0f52f
Fixes CheckoutPricing.coupon set and calculations
chrissrogers Nov 7, 2017
2aaa800
Adds CheckoutPricing.coupon specs
chrissrogers Nov 7, 2017
2c5c70d
Fixes CheckoutPricing fixed amount discount overrun
chrissrogers Nov 8, 2017
8011207
Fixes CheckoutPricing subscription coupon and gift card removal
chrissrogers Nov 8, 2017
193bb94
Adds decimalize pass to CheckoutPricing
chrissrogers Nov 8, 2017
2a15d81
Adds CheckoutPricing fixed amount discount soecs
chrissrogers Nov 8, 2017
1b8eb55
Fixes CheckoutPricing free trial application reprice
chrissrogers Nov 8, 2017
2852800
Fixes SubscriptionPricing fixed amount discounting of setup fees
chrissrogers Nov 8, 2017
1bbabe0
Adds CheckoutPricing discount specs
chrissrogers Nov 8, 2017
2362f17
Adds recurly.pipedRequest defaults
chrissrogers Nov 9, 2017
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
Prev Previous commit
Next Next commit
Adds decimalize pass to CheckoutPricing
Signed-off-by: Christopher Rogers <chrissrogers@gmail.com>
  • Loading branch information
chrissrogers committed Nov 8, 2017
commit 193bb94d38801c4d9ac7cd1fa61d2ce87b8d9a1a
8 changes: 6 additions & 2 deletions lib/recurly/pricing/checkout/calculations.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ export default class Calculations {
.then(() => this.totals())
.then(() => this.giftCards())
.then(() => this.itemizedSets())
.catch(this.pricing.error)
.done(() => done(this.price))
.catch(err => this.pricing.error(err))
.done(() => {
each(this.price.now, decimalizeMember, this.price.now);
each(this.price.next, decimalizeMember, this.price.next);
done(this.price)
});
}

get validSubscriptions () {
Expand Down
2 changes: 1 addition & 1 deletion lib/recurly/pricing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class Pricing extends Emitter {
* @param {[String]} namespace - dot-delimited error namespace
* @private
*/
error (error, reject, namespace) {
error (error, reject = () => {}, namespace) {
if (namespace) {
namespace.split('.').reduce((memo, name) => this.emit(`${memo}.${name}`, error), 'error');
}
Expand Down
1 change: 1 addition & 0 deletions lib/util/decimalize-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
*/

export default function decimalizeMember (prop) {
if (typeof this[prop] !== 'number') return;
this[prop] = (Math.round(Math.max(this[prop], 0) * 100) / 100).toFixed(2);
}