Membership 2 recurring memberships issues

I'm using membership2 and there are times when we need to add members manually. We're using stripe plan for recurring subscriptions. When I add a member manually their payment gateway is set to "None (admin)". And the problem is that when their subscription expires they are never emailed or prompted to renew and pay.

  • locomo

    Hi Paul

    Manually added members will be assigned the default active gateway

    Question about this .. can this be set explicitly somewhere? I'm not seeing any settings that would let me set this.

    And I just want to make sure we're looking at the same users because for the 2 active memberships on my test site, the Payment Gateway was set to "None (Admin)". I added these users manually (as an admin user). They were sent an initial email but then after 1 week when the membership renewed they were not sent any emails. However an invoice was created for them and automatically set to "paid".

    What I want to happen is that when their membership is set to renew, they are prompted with an email to pay their invoice (marked as 'billed') thus setting up their stripeplan recurring payment.

    • Paul Kevin

      Hello locomo,

      Question about this .. can this be set explicitly somewhere? I'm not seeing any settings that would let me set this.

      Right now this is not defined as a setting anywhere, but I will add this in later versions to allow the admin to choose the default gateway for a member or membership.

      Regarding the email to send before payment, by default this is disabled in the Automatic Email Responses. You can view this under settings > "Automatic Email Responses" .

      Regarding the gateway being set to admin, at the moment this will only be set if there is one active gateway in the admin i.e. a user only has one option to pay from. In your setting I can see there is both Manual and Stripe. I will work on adding an option for "Default Gateway" in the settings in future releases.

      Warm Regards
      Paul Kevin

  • locomo

    ok thanks I'll try these new files

    2 other questions while I have you :slight_smile:

    1) I have another user on this test site who is currently expired (the yahoo account). For this user I signed up from the front end and entered one of Stripes test credit cards. Initial payment was successful and the subscription was setup in stripe. After 1 week the subscription was successfully processed again in Stripe but the payment was not reflected in membership. You can see invoice #3162-2 is marked as billed ... even though the payment was made successfully in Stripe. Any ideas?

    2) Do you have a solution if a large number of users need to be imported? My scenario is a group of users who have paid using a different membership system. We want to bring them into membership2, have them valid until a certain date, and then be prompted to pay via stripeplan when their "grandfathered" subscription expires.

    thanks!

  • locomo

    hey Paul

    I'm back to working on this .. I added the web hook to my stripe settings as you advised earlier in this thread

    now I'm getting a new issue .. when I create a new subscription from the front end a duplicate invoice is created and marked as paid

    from the M2 side of things it looks as if a 2nd time period was paid for (I tried 2 different subscriptions as tests, 1 recurs annually and 1 weekly)

    But in Stripe there is only record payment for the first invoice and in the M2 transaction logs there is something strange about the 2nd transaction for each user - the data is not complete and it indicates logged in as user Guest instead of the user who registered

    any thoughts?

  • locomo

    oh cool .. thanks ..

    I'm wondering if it would be possible to create some kind of 'bleeding edge' page for this plugin that lists bug fixes that are not yet in the current release

    that way we could install them at our own risk but not have to bug you guys as much or waste as much time hunting these issues down?

    for example with this duplicate invoice bug I spent an hour thinking it was something I was doing wrong .. it would have been great to be able to scan a lit of current issues (like in github or something) and then apply the fixes as desired

    btw is there a way to sync the current membership options over to Stripe>Plans via stripeplan gateway

  • locomo

    hey Paul .. so i'm having a bunch of different issues using stripeplan as the payment gateway - i did 4 different tests described below .. hoping you can help. A big issue is that no email seem to be going out (i think i've got all of the relevant emails activated - pay before, pay after, subscription renewed, subscription expired etc). Here are my notes:

    details about my test
    - a standard membership set to renew weekly
    - automated emails for payments, subscriptions etc are activated
    - payment gateway set to Stripe Subscriptions Gateway
    - email logging is on

    user 1 (user_id=128) ACTIVE
    - user signed up directly via front end of site
    - 3 payments (11/16, 11/23, 11,30) via stripeplan but only 2 invoices (11/16, 11/23)
    - no emails being sent out for subscription renewals
    - summary: subscription is being renewed but emails are not going out and invoice creation seems erratic

    user 2 (user_id=129) ACTIVE
    - set user subscription from backend and created invoice at same time, but user paid via front end
    - 3 payments (11/16, 11/23, 11,30) via stripeplan but only 2 invoices both dated 11/23
    - no emails being sent out for subscription renewals
    - summary: subscription is being renewed but emails are not going out and invoice creation seems erratic

    user 3 (user_id=131) EXPIRED
    - set user subscription from backend with no invoice initially > re-added membership + marked paid manually
    - 2nd invoice was created but never emailed to the user (invoice status == DRAFT) > user is now expired
    - summary: subsequent invoice created but set to Draft and never seen by user > RESULT: user expires (no email sent)

    user 4 (user_id=132) EXPIRED
    - set user subscription via custom import script with initial invoice marked as paid
    - 2nd invoice created but never emailed to user (invoice status == BILLED) > user is now expired
    - summary: subsequent invoice created but never emailed to user > RESULT: user expires (no email sent)

  • locomo

    There is some other weirdness going on with user 1 and user 2 (per my notes above). These users are getting renewed weekly and payments are being logged in Stripe .. but the payments are being applied against the same invoice each time. So for the initial payment an invoice is created. And then for the first auto-bill cycle a 2nd invoice is created and paid. But then for subsequent auto-bills, new invoices are NOT created and the payment seems to be applied to the old invoice again. I've attached a screen shot of my transaction logs and you can see payments being applied multiple times to the same invoice. Also the log details are weird (when you rollover the "i" to get more info) and it indicates that the logged in user is guest and that it could not determine the user

  • locomo

    hi Paul

    i installed membership2-pro-1.1.2-beta5 and some things are better but i'm still getting a lot of unexpected behavior

    - for users who sign up normally from the front end, i'm now getting a confirmation email when their payment is processed via stripeplan (great) .. but it is still applying the payment to the same invoice instead of creating a new invoice for each billing cycle

    - i tried manually adding users from the backend 2 different ways:
    1) added the membership and ticked 'create invoice' > user received the 'Subscription - Created with Payment' email but this is very misleading because their invoice is marked as Billed. Then I tried manually marking their invoice as paid thinking it would activate their membership - but they were still marked as expired. Finally I manually changed their membership to Active and they were sent 'Subscription - Renewed' email
    2) added the membership and did NOT tick 'create invoice' > user received the 'Subscription - Created with Payment' email. This is even more misleading because an invoice is auto generated but set to Draft and so the user cannot see the invoice and it is not indicated that they need to make a payment. The user appears as 'expired' in the list of members

  • Paul Kevin

    Hey there locomo ,

    Sorry for the late response on this .Regarding :

    1) added the membership and ticked 'create invoice' > user received the 'Subscription - Created with Payment' email but this is very misleading because their invoice is marked as Billed. Then I tried manually marking their invoice as paid thinking it would activate their membership - but they were still marked as expired. Finally I manually changed their membership to Active and they were sent 'Subscription - Renewed' email

    This is the expected output. To mark a user as active instantly, you need to mark the subscription as active, and the invoice will be marked as paid. Billed status means the user can see the invoice and needs to make payment. This was mainly added when an admin wants to manually bill the member of the site.

    2) added the membership and did NOT tick 'create invoice' > user received the 'Subscription - Created with Payment' email. This is even more misleading because an invoice is auto generated but set to Draft and so the user cannot see the invoice and it is not indicated that they need to make a payment. The user appears as 'expired' in the list of members

    This will not ark the invoice as billed. The admin will have to manually choose to mark the invoice as billed or automatically activate the users account. The checkbox mainly is to allow the admin to create a users subscription and bill them instantly (Billed status) or to give them direct access without billing them directly(Draft status) . So I think the issue here is the email content.

    Regarding the Stripe invoices, we noticed on first payment, it would create duplicate invoices since the webhook checks for paid invoices. Ive modified this to check the subscription date. Kindly replace the attached file in the directory "wp-content/plugins/membership/premium/gateway/stripeplan"
    Regarding the email issue, I will look into it.

    Warm Regards
    Paul Kevin

    • locomo

      Thanks Paul!

      I've updated the stripeplan file and I'll let you know how it goes.

      Re: adding subscriptions as an admin, I think these are the 2 scenarios we're trying to cover. I think I'm confused about the intended workflow. Could you maybe clarify the steps an admin should take to achieve each of the following:

      1) Admin adds a user subscription, bill them, keep them inactive until they pay. Once they pay they become active and are billed again on the next billing cycle.

      In this scenario the user should be emailed that they have a new subscription but that they must pay to activate it. Do we need a new type of automated email response to this (ie Subscription create but requires action)

      2) Admin adds a user subscription, activate them immediately. User is then billed (an invoice emailed to them) on the next billing cycle. This is kind of a "grandfathered" scenario where we're giving them credit for having paid via some other system but then we want them to conform to the current billing system going forward.

      In this scenario the user should be emailed that they have a new subscription that is now active. They will need to be emailed at the next billing cycle because they haven't setup payment yet.

      thanks!

        • locomo

          thanks Paul .. no need to apologize .. i really appreciate that you are actively responding to this thread ..

          i have one other strange email activity to report that is related to this (admin adding memberships) ..

          i did 2 more tests today and in both cases when a subscription was applied to a user they were immediately emailed "Confirmation of your membership" and when they were set to active they were emailed "Subscription renewed".

          BUT on the next cron job they were emailed "Subscription expired" (type_finished) .. which is very confusing and makes no sense .. and in fact these users are still active in the system and there is no record of their subscription expiring in their event logs etc

          so it seems like that email is getting queued up somehow incorrectly .. maybe because when their subscription is initially created it is not active?

          anyhow a " Subscription expired" should definitely not be going out in this case
          thanks very much

  • locomo

    hey Paul Kevin

    i just want to clarify one of the issues related to this thread

    i need a way to get members into the system initially marked as active (grandfathered in) but where at the next billing cycle they are emailed an invoice that they need to pay to renew their subscription

    what i'm finding is that for these users, even though they are ACTIVE, when the billing cycle renews the subsequent invoice that is created is always in Draft status (STATUS_NEW) - and so they are not emailed or visible to the user

    is this maybe because they are on stripeplan but do not have a gateway profile setup yet?

    This is what I thought would work (I've tried every permutation i can think of):
    I manually added the subscription with invoice checked and then manually set their status to Active - this set the 1st invoice to STATUS_PAID (but no payment was created). All good at this point. Then when the billing cycle renewed the next invoice was created as STATUS_NEW and never emailed. Not good - I have an active and essentially paid up member at this point who needs to be notified to renew their subscription.

    thanks!

  • locomo

    hi Paul Kevin

    is there any way we can have a live chat or phone call? i've got several hundred subscriptions set to renew very soon and i'm feeling very unconfident in the system right now

    i'd like to try and figure out either a good fallback plan and also try hear what can be reasonably expected from wpmu on the development front in the next week or 2

    as it stands now stripeplan gateway is just really not working ... i'm getting loads of duplicate emails, payments shown as processed in stripe but not in membership2, emails being sent out that do not accurately reflect the state of the subscription, etc etc

    please let me know if there is a way we could talk more directly

    thanks!

    • Paul Kevin

      Hey there locomo ,

      Hope you are well today. Stripe subscriptions works if the webhook is set up well, you can verify this on the transaction logs in the dashboard. The invoices created as draft are by the background webhook, once payment reaches Stripe, a webhook is triggered and this marks the invoice as paid.
      If this does not happen, the invoice will be marked as expired. I updated the stripe class which you can find attached.
      Regarding setting the members status to active at first, you can first create a free membership for a defined number of days where all the members are assigned to, then after expire they move into a paid plan. The reason why its not working well is the members you are adding have a pre-defined payment gateway, and membership will always check for this and send out payment emails. Regarding direct communication, I cannot do that at the moment but you can reach out to our support staff via live chat or email and they will make sure I get a full view of the issue.

      Warm Regards
      Paul Kevin

  • locomo

    thanks Paul Kevin

    I tried what you suggested and unfortunately it didn't work. Here is what I did and what the results were.

    Created a free standard membership (called "FreeTest") with these settings:
    access structure: finite
    Granted access for: 1 day
    after membership ends: Change to "Test2Day"

    "Test2Day" is a standard membership with these settings
    allowed payment gateways: stripeplan
    recurring every 2 days for $23

    - on 12/13 I manually added a "FreeTest" subscription to a user
    - on 12/14 user received email type_registration: Test2Day is activated (even though they have not setup payment with Stripe)
    - on 12/14 an invoice was created for this user with due date 12/16 (but no email was sent to notify the user)
    - on 12/14 one hour later user received email type_finished: Your Test2Day membership has ended on 2017-12-16 .. this obviously makes no sense at all as it is not even 12/16 yet and the user was never given a chance to setup payment

    In addition the "Test2Day" subscription was completely removed from the user by the system (they are now visitor).. so they are not even in expired status or cancelled

    in summary i think there are 2 main issues:
    1) we discussed earlier .. i think there needs to be a new type of email that goes out for subscriptions that require a user to setup payment. Instead of email "type_registration" maybe it should be "type_pending" or something. The user would be informed that their subscription has been created but they must log in and make payment to activate it.

    2) when the Free membership turns into the Paid membership it seems like the expiration dates are not being set properly or something like that. In my case the user was almost immediately expired on the date the subscription was created 12/14. And when the user was expired the subscription was removed instead of putting the user into an expired state.

    thanks

  • locomo

    hey Paul Kevin

    sorry to keep bugging you .. but at this point i feel like i don't have a solution .. i've been trying every possible way i can think of to manually add users and then let them pay via stripeplan .. i've tried all of the things you have suggested .. but the system is just not working .. I really don't think my use case is terribly unusual.

    On our live site I currently have about 500 users who are setup with different subscription plans that are set to renew at the end of the year. All I want to happen is that when the subscription renews is that an invoice is created, set to billed and that the user is emailed that they should log in and pay. We want them to pay via stripeplan.

    I need to be able to add these users manually because we have migrated them from another system and they have paid thru the year.

    I'm pretty much out of time here and I'm worried that I will quickly have to find another membership system that can handle this.

    Would it be possible for you to double check and test the solution you have suggested to confirm that it works? Maybe I'm messing something up?

    I know you said we can't be in direct contact but I'm wondering if something is getting lost in our communication? I could set up access on my site for you if that would help. Or maybe M2 just can't handle this situation? Any help you can provide would be most helpful. I'm really under the gun here.

    thanks
    morgan

    • Paul Kevin

      Hey there locomo ,

      Hope you are well today. If I understand, you want to manually add users to a stripe subscription which is not possible since each subscription must be linked to the users Stripe account for the transactions to occur. The filter I provided only sets the default gateway to Stripe, but does not handle any payments until each user links up their Stripe accounts.
      Since there are different systems, each user will have to set up the new Stripe plan to their account as Membership doesnt have a way to allow users to migrate from a specific plan especially if its from a different platform.
      When a subscription is not paid, its set to expired state depending on how long the subscription period is. Normally the user will be checked for after 30 days again to see if the invoice has been paid. But in most cases, the user will be set to inactive and will have to sign up again for that subscription plan. Right now the plugin has afew limitations, but more features can and will be added after the next release.

      Warm Regards
      Paul Kevin

      • locomo

        thanks Paul Kevin

        so i totally understand that the user will need to login and setup their stripe account .. i want to manually add them but i don't need to manually setup their stripeplan

        what i was hoping is that I could put people into their appropriate plan so that they could simply pay their invoice (with stripe) when the plan renews .. we're wanting them to "renew" their subscription rather than having to pick one from scratch

        so maybe to put it another way.. rather than have the user "join" we want to do that step for them but then prompt them to pay their first invoice ... by doing this step they would setup their stripe account and then from then on they should be all set for future renewals

        to clarify.. are you saying its not possible to do what i've outlined above?

        thanks

        • Paul Kevin

          Hello locomo ,

          Hope you are well today. Its possible when the invoice is created on subscription by the admin (by clicking the checkbox), the user should get a notification and be prompted to pay for their invoice. At this step they will sign into their account in Membership and the membership status should be "pending", which after clicking that link of "renew" they will be taken to a page where they can connect stripe.

          Not sure if this is the process flow you are looking for, but by default if the user takes sometime to pay for the invoice, it will go into deactivated. Maybe there can be a trial period of a day or two allowing the user ample time to pay

          Warm Regards
          Paul Kevin

          • locomo

            thanks Paul Kevin

            i'm trying to make this work .. some of the confusion are the emails that get automatically sent out when adding a subscription by admin .. have you had any luck on the "Subscription expired" email (several posts up in this thread)

            when i add the subscription to the user by the admin they are emailed 'type_registration' but then they are also emailed 'type_finished' ("Subscription - Expired Message") ... maybe because they have been added but still need to pay in order to activate their subscription?

            but this isn't really accurate .. they need to be told that their subscription is Pending until Payment .. not that their subscription is expired

            thanks

  • locomo

    hi Paul Kevin

    i just retested another issue that i had reported earlier on Dec 7 .. this is separate from "Subscription expired" issue i wrote about in my previous post

    i did a test with a user subscribing from the front end: they select a membership and successfully pay via stripeplan and there is a "payment successful' transaction log for invoice 10792

    at the 2nd billing cycle a new invoice is created and paid for successfully via stripeplan. There is a transaction log for invoice 10798 but it is greyed at and says "Could not determine a logged in user". In the database this transaction log has post author = 0 instead the user id of the member. Very strangely the "type_invoice" email that went out to the user refers to invoice #10792 instead of #10798

    at the 3rd billing cycle NO new invoice is created. But a payment is successfully made via stripeplan and the subscription is renewed. There is a transaction log but it is AGAIN for invoice 10798. It is greyed at and says "Could not determine a logged in user". Another "type_invoice" email was sent out to the user and it AGAIN refers to invoice #10792 instead of #10798

    So i think my webhook is setup correctly.. the payments are being processed and the subscription is getting renewed. But after the 2nd billing cycle, new invoices are NOT being created. And something is messed up with the current invoice number because the email receipts keep referring to the very first invoice number (#10792) and the transaction logs keep referring to the 2nd invoice (#10798)

  • locomo

    i'm not seeing anything in the error log .. does M2 write to the system error log or to its own log somewhere else?

    in lib3.log i'm seeing this:

    2017-12-19	15:19:54	[M2]Sent email [type_registration] to <myemail@gmail.com>: OK
    2017-12-19	15:20:25	[M2][error: Communication email failed] comm_type=type_finished, subscription_id=0, user_id=0
    2017-12-19	15:20:26	[M2]Sent email [type_finished] to < myemail@gmail.com>: OK
  • locomo

    hey Paul Kevin

    i know this thread has gotten pretty unwieldy .. let me know if it would be better to open up new threads to track separate issues - this is what i'm currently tracking on my end:

    Issue: 'expired' event created for manually added users
    Issue: 'type_finished' email not removed from queue when user is activated

    - i add a subscription to a member from the backend with invoice ticked
    - member is initially 'pending' but an 'expired' event is created and 'type_finished' email added to the queue
    - i change the members status to active and a 'renewed' event is created and 'renewed' email is sent .. 'type_finished' email is NOT removed from queue
    - at next cron the 'type_finished' email is sent even though the user is active.

    Issue: stripeplan payments not being applied to correct invoice (user subscription added by admin)
    - i add a subscription to a member from the backend with invoice ticked
    - i manually set subscription status to 'active', initial invoice (#1) is automatically marked as paid
    - at next billing cycle a new 'billed' invoice (#2) is generated and user logs in via front end and clicks pay on their invoice. They enter credit card info and payment goes thru successfully via stripeplan
    - BUT payment is applied to invoice #1 and invoice #2 is still set to 'billed'

    Issue: stripeplan payments not being applied to correct invoice after 2nd billing cycle (user subscribed from front end)
    - user subscribed from the front end: they select a membership and successfully pay via stripeplan and there is a "payment successful' transaction log for invoice #1
    - at the 2nd billing cycle a new invoice #2 is created and automatically paid for successfully via stripeplan BUT "type_invoice" email refers to invoice #1
    - at the 3rd billing cycle NO new invoice is created. But a payment is successfully made via stripeplan and the subscription is renewed. Transaction log for the payment refers to invoice #2 and "type_invoice" email refers to invoice #1
    - subsequent billing cycles follow this pattern, ie no new invoice created, payment successfully made via stripeplan against invoice #2, email receipts sent refers to invoice #1

  • Paul Kevin

    Hey locomo ,

    For the renewal emails, I see it was only set if a subscription was previously expired, cancelled or was on trial. The reason being there will be too many renewal emails that will be sent out for each payment done especially if the payment duration is minimal. A solution would be to set and enable/disable option for the payment gateway renewals. I'll have this setup and send you the changes

    Warm Regards
    Paul Kevin

  • locomo

    Thanks Paul Kevin

    I've installed the file and tried rerunning some of my tests. Unfortunately the stripe payment is still not being applied to the correct invoice.

    - i add a subscription to a member from the backend with invoice checked
    - i manually set subscription status to 'active', initial invoice (#1) is automatically marked as paid
    - user is sent a 'renewed' email AND a 'type_finished' email - an 'expired' event is still being created immediately for manually added users .. can we please disable this?
    - after the next membership status cron job a new 'billed' invoice (#2) is generated and user logs in via front end and clicks pay on their invoice. They enter credit card info and payment goes thru successfully via stripeplan
    - BUT payment is applied to invoice #1 and invoice #2 is still set to 'billed'

  • locomo

    hey Paul Kevin

    This is pretty confounding .. I'm really surprised that my issues can't be replicated.

    A few days ago I setup a brand new wordpress install with Membership2 and was able to recreate all of the issues i'm having on the other site.

    Would you please be willing to try the setup below and see if these same problems do or do not occur? Let me know if there are any other setup/config options you need me to provide. Or if you want direct access to my install let me know.

    SETUP

    I've got a standard membership with recurring payments every 2 days with only stripeplan activated as payment gateway. I've got the requested webhook setup in my stripe account

    these are the addons i've activated: "Additional Automated Messages" and "Pro-Rating"

    2 test users

    User 1
    - 2018-01-18 registers and pays via front end, receives receipt for invoice #139-1
    - 2018-01-18 invoice #164-2 is created with status 'new'
    - 2018-01-20 invoice #164-2 is paid automatically, receipt for invoice #139 is emailed AGAIN
    - 2018-01-22 invoice #164-2 is paid AGAIN, receipt for invoice #139 is emailed AGAIN

    issues
    - after 2nd invoice is created no subsequent invoices are created
    - transaction logs for payments keep being applied to 2nd invoice (#164) (except initial payment)
    - email receipts ALL reference 1st invoice number (#139)

    User 2
    - 2018-01-18 subscription add via backend with invoice option checked and then manually set to active

    issues
    - Membership expired event is automatically created for user and expired email is sent on next cron even though the subscription is active

    thanks
    morgan

  • locomo

    hey Paul Kevin

    i think i might open a new thread .. but just wanted to give you the heads up that after extensive testing i think there is an issue in M2 with how the 'current_invoice_number' in MS_Model_Relationship gets updated and used

    i think this is what is behind a number of the issues i've been seeing in terms of new invoices not being created and stripeplan applying payments to the same invoice over and over

    i made changes in the following files:
    app/core/class-ms-factory.php
    app/model/class-ms-model-invoice.php
    premium/gateway/stripeplan/class-ms-gateway-stripeplan.php

    and now i've got things working as expected!!

    i'm not sure if the changes i made will have implications in the rest of the plugin but i'm wondering if you'd like me to share my findings and solution? if so should i open a new thread or include it here?

    or if not helpful I can just keep this version of M2 that i've customized and be careful about upgrading in the future

  • locomo

    hey Paul Kevin

    so in general the issue is that 'current_invoice_number' is not being incremented and stored correctly. I made changes to 3 files. Again I've done a bunch of testing with no issues .. but i'm not sure if the changes i've made will have negative side effects on other functionality of the plugin that i'm not using

    ###
    class-ms-factory.php
    method: 'populate_model'

    line 471 'current_invoice_number' is "ignored" when the model is populated
    This has the effect of never loading the value for 'current_invoice_number'. Subsequently when the model is saved the value for 'current_invoice_number' is always reset to "1"

    my change was to comment the line out:
    //$ignore[] = 'current_invoice_number';

    ###
    app/model/class-ms-model-invoice.php
    method: 'changed'

    This is the change that I'm most unsure if it could have other side effects. But I think there is a flaw in the logic of how 'current_invoice_number' gets incremented.
    line 1193

    instead of this:

    // Update the current_invoice_number counter.
    $subscription->current_invoice_number = max(
    	$subscription->current_invoice_number,
    	$this->invoice_number + 1
    );

    i changed it to this this:

    // Update the current_invoice_number counter.
    $subscription->current_invoice_number = max(
    	$subscription->current_invoice_number,
    	$this->invoice_number
    );

    the reason is that earlier calls to $subscription->first_unpaid_invoice() take care of incrementing 'invoice_number' .. we don't need to add 1 to the value in this 'max' statement

    ###
    premium/gateway/stripeplan/class-ms-gateway-stripeplan.php
    method: 'process_purchase'

    for some of my users the invoice returned by '$subscription->get_current_invoice()' was already marked as paid .. i think its better to always use '$subscription->first_unpaid_invoice()'

    my change was from this:
    $invoice = $subscription->get_current_invoice();

    to this:

    $invoice_id = $subscription->first_unpaid_invoice();
    $invoice = MS_Factory::load( 'MS_Model_Invoice', $invoice_id );

    hope this makes sense .. let me know what you think !!

  • locomo

    hey Paul Kevin

    using 'get_current_invoice()' in the stripe class is also problematic as it assumes that no other invoices exist .. it can easily result in an invoice that has already been paid to be paid again

    it looks like MS_Model_Relationship::cancel_membership() calls MS_Model_Relationship::remove_unpaid_invoices() which should in theory clean up any unpaid invoices when a subscription is cancelled?

    or maybe there could be some kind of nightly cron job that performs some cleanup

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.