chargify/chargify_api_ares

Allow metafield update on a subscription via the API

Closed this issue · 16 comments

Looking here I'm seeing that metafields are valid api endpoints.

It would be great if this gem supported this.

Update

After clarification it appears these endpoints only allow get (list) and post (metafield create) endpoints. It's not yet possible to set/update the metafield of a new or existing subscription via the api. See thread and specificalyl this comment for clarity.

Thanks for the report @jonathansimmons I will take a look at adding it here shortly.

@jonathansimmons I have released a pre-release version of the gem found here:

https://rubygems.org/gems/chargify_api_ares/versions/1.1.0.pre
For more information on how to use metafields please look at this commit: ca27f0a

Note this does not include updating metadata for a given subscription / customer record, but that is to come.

Sweet, though I wished I clarified that updating was a key part of what I we were looking for. Any timeline on this being completed and released? (cc: @YesThatAllen)

@jonathansimmons I don't have an ETA. It is out of band work for me. I will try to get to it ASAP though. Can you explain how you want to use it so that we align on end result.

Do you want to do something like subscription.metadata(name: "something", value: "other") as it stands now I was implementing it to be a separate request.

subscription.metadata(name: "subdomain", value: "example") is exactly what we are looking for.
Essentially @YesThatAllen's desire is to be able to utilize a metafield for subdomain to create custom url 's in the chargify e-mails pointing our subscribers back to our internal billing pages vs the chargify hosted pages.

Forgive me though as I just re-read the docs and it's appears I was mistaken in thinking the API endpoints for updating a metafield already existed. That doesn't appear to be the case?

I think what you are looking for is metadata endpoints

Right, I'm confused as to how they don't exist. The metadata field is only useful for those using hosted pages?

We added them so that merchants can add data along side subscriptions / customers. So if you need to internally keep track of data with each subscription and don't want to build a mapping from Chargify subscription to your system you could.

Agreed, which is exactly what we want. We just don't use the hosted pages, everything is created via the Chargify API. So to me it appears without the use of hosted pages the metafields are essentially useless. For API users as least. Am I wrong?

This issue appears to have changed form "Support custom metafields" to "Allow metafield update on a subscription via the API".

For example since we use our subscriber's subdomain as a reference in chargify updating a metafield might look something like:

subscription = Chargify::Subscription.find_by_customer_reference([our_subscribers_subdomain])
subscription.metafields = {name: "subdomain", value: "[our_subscribers_subdomain]"}
subscription.save

I've updated the issue. If this is not the right place for this type of request, let me know where I can submit a proper one.

This is the right place for the request, thanks for the detail of how you want the interface to work.

Just as a status update, metadata is coming soon. I am just having some others double check the work. Please see #86 You'll want to have a look at the subscription metadata methods added.

Nice! Thanks for the quick work man!

No problem, thanks for putting it on our radar. It should have been added from the get go. If you could pull it down and take a look at it and tell me what you think that would be great.

v1.1.0 of the gem is out! please check out the examples here and enjoy!

https://github.com/chargify/chargify_api_ares/blob/master/examples/metadata.rb