Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating trial_ends_at results in "The provided XML was invalid." #365

Closed
darkostanimirovic opened this issue Aug 30, 2018 · 3 comments
Closed
Labels
V2 V2 Client

Comments

@darkostanimirovic
Copy link

Here's my code:

foreach (Recurly_SubscriptionList::getTrials() as $trial) {
    $trial->plan_code = '3monthtrial';
    $trial->trial_ends_at = (new DateTime)->modify('+3 month');
    $trial->updateImmediately();
}

This results in "The provided XML was invalid."

The actual XML is this:

<?xml version="1.0"?>
<subscription><plan_code>3monthtrial</plan_code><trial_ends_at>2018-11-30T10:26:08+00:00</trial_ends_at><timeframe>now</timeframe><subscription_add_ons></subscription_add_ons></subscription>

If I omit the ->trial_ends_at update, it works.

Thanks

@drewish
Copy link

drewish commented Aug 30, 2018

Great question! We don't allow the trial_ends_at value to be set as part of a subscription update. There's a separate postpone endpoint/method for that: https://dev.recurly.com/docs/postpone-subscription. What I'm not clear on is if you're also trying to change plans. If that's the case you might need to make two separate calls.

@darkostanimirovic
Copy link
Author

Ok that explains it.

In that case, shouldn't this prop be removed from subscription's getWriteableAttributes() list? I checked there first, to make sure it's writable and I assumed it was.

protected function getWriteableAttributes() {
    return array(
      'account', 'plan_code', 'coupon_code', 'coupon_codes',
      'unit_amount_in_cents', 'quantity', 'currency', 'starts_at',
      'trial_ends_at', 'total_billing_cycles', 'first_renewal_date',
      'timeframe', 'subscription_add_ons', 'net_terms', 'po_number',
      'collection_method', 'cost_in_cents', 'remaining_billing_cycles', 'bulk',
      'terms_and_conditions', 'customer_notes', 'vat_reverse_charge_notes',
      'bank_account_authorized_at', 'revenue_schedule_type', 'gift_card',
      'shipping_address', 'shipping_address_id', 'imported_trial',
      'remaining_pause_cycles', 'custom_fields', 'auto_renew',
      'renewal_billing_cycles'
    );
  }

Thanks for helping! Yes, looks like I'll need to make two calls. Not a big deal though, it's not a huge list.

@drewish
Copy link

drewish commented Aug 30, 2018

I believe it's there for creation. Sort of confusing having them mixed up into one list though.

@drewish drewish closed this as completed Aug 30, 2018
@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

No branches or pull requests

3 participants