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:
parent
13b870d0ef
commit
c8933c9abd
@ -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') {
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user