edalzell / statamic-charge

One-time or subscription billing
13 stars 3 forks source link

Error when changing user roles #37

Closed jeremydouglas closed 4 years ago

jeremydouglas commented 4 years ago

I'm getting this error when a user subscribes and user roles are set:

[2020-01-05 21:16:59] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST) in /Users/jeremyhoover/Sites/deboss-garage-api/public/site/addons/Charge/Actions/UpdateUserRolesAction.php:9

If it helps, this is what I'm using as a charge config file:

currency: usd
active: Active
canceling: Canceling
past_due: 'Past Due'
canceled: Canceled
plans_and_roles:
  -
    plan: plan_GCmdg3U0GEib2B
    role:
      - 93b31b39-47af-4bd2-83ca-100b39eca84f
canceled_email_template: email/cancel_subscription
payment_failed_email_template: email/payment_failed
upcoming_payment_email_template: email/payment_upcoming
charge_formset: subscribe
edalzell commented 4 years ago

@jeremydouglas what version of PHP are you on?

jeremydouglas commented 4 years ago

7.3.11

jeremydouglas commented 4 years ago

@edalzell,

I now have roles adding properly, but when changing from one plan/role to another, the old one isn't removed. Can you confirm?

jeremydouglas commented 4 years ago

@edalzell,

These are the scripts that the {{ charge:js }} tag is loading to the page:

<script type="text/javascript">var Charge = {"plan":null,"freePlan":null};</script>
<script src="/_resources/addons/Charge/js/charge-new.js"></script>

The src on the second tag looks like it's not pointing to the js file in the add-on. Is that a big deal?

edalzell commented 4 years ago

@edalzell,

I now have roles adding properly, but when changing from one plan/role to another, the old one isn't removed. Can you confirm?

@jeremydouglas how are you changing them?

jeremydouglas commented 4 years ago

I have several plans in my charge config with roles attached to each plan.

When a user subscribes to a plan, the role is being applied. When they subscribe to a different plan, the role associated with the plan the were formerly on isn't removed.

I'm still learning how Stripe works with subscription plans. I'm guessing changing plans might not remove users from the previous plan they were on?

edalzell commented 4 years ago

should work, it's a bug. Will test later this week.

Sorry for the delays, I typically only work on charge in the evenings and been spending more time w/ family.

jeremydouglas commented 4 years ago

Thanks Erin, I know how it is.

I'm hoping to take a site using Charge to a soft-launch and demo in the next week. I think I should be able to work around the bugs for now. At this point, I think that's easier than me upgrading to Statamic 3 Beta and using Laravel Cashier. Like, by far! And, then there's bugs there too :(