Skip to content

SubscriptionService.prototype.unpause actually pauses a subscription #32

@paytree

Description

@paytree

I'm currently trying to implement behavior that pauses/unpauses a subscription based on what internal plan the user chose. This is my code:

const pm = paymill.getContext(paymillPrivateKey);
if (plan.paymillOfferId) {
  // update old subscription
   const updatedSubscription = 
     await pm.subscriptions.changeOfferChangeCaptureDateAndRefund(
     subscriptionId,
     plan.paymillOfferId,
   );
   if (updatedSubscription.status === 'inactive') {
     await pm.subscriptions.unpause(updatedSubscription.id);
   }
} else {
  // Allow for free plans to be purchased
  await pm.subscriptions.pause(subscriptionId);
}

While that code can pause the subscription just fine, calling pm.subscriptions.unpause() never managed to set the status to 'active' again. I dug through the source code and found this piece here at line 3950:

SubscriptionService.prototype.unpause = function(obj, cb) {
    var map = { "pause" : true };
    return this._updateWithMap(obj, map, cb);
};

I guess it really should be

SubscriptionService.prototype.unpause = function(obj, cb) {
    var map = { "pause" : false };
    return this._updateWithMap(obj, map, cb);
};

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions