Fixed handling of null currency & used duration

no-issue

Currency is not always present on an offer so we need to handle it.
Duration was incorrectly not passed to Stripe when creating the coupon.
This commit is contained in:
Fabien O'Carroll 2021-10-07 18:13:17 +02:00
parent 13b870d0ef
commit c8933c9abd
2 changed files with 3 additions and 3 deletions

View File

@ -123,7 +123,7 @@ class OfferRepository {
interval: offer.cadence.value,
product_id: offer.tier.id,
duration: offer.duration.value,
currency: offer.currency.value
currency: offer.currency ? offer.currency.value : null
});
if (offer.codeChanged || offer.isNew) {
@ -139,7 +139,7 @@ class OfferRepository {
/** @type {import('stripe').Stripe.CouponCreateParams} */
const coupon = {
name: offer.name.value,
duration: 'once'
duration: offer.duration.value
};
if (offer.type.value === 'percent') {

View File

@ -22,7 +22,7 @@ const OfferCurrency = require('./OfferCurrency');
* @prop {OfferType} type
* @prop {OfferAmount} amount
* @prop {OfferDuration} duration
* @prop {OfferCurrency} currency
* @prop {OfferCurrency} [currency]
* @prop {string} [stripe_coupon_id]
* @prop {OfferTier} tier
*/