jamesmacaulay / shopify-clj

A Clojure library for interacting with the Shopify API
14 stars 7 forks source link

billing questions #2

Open podviaznikov opened 10 years ago

podviaznikov commented 10 years ago

Hi,

thanks for the great library. I think it is really well designed.

I'm having some trouble with billing API.

(shop/save! :recurring_application_charge
                     {:name "Super Duper Plan"
                      :price  10.0
                      :return_url "http://localhost:3000"} auth)

Do you think this code should work? Should it return something? I have proper auth object.

Another question: can I see some debug information? For me this method returns just nil.

jamesmacaulay commented 10 years ago

Thanks for the report. I've confirmed that it's a bug with extracting multi-word resource names (it was looking for the underscored_version, but the keywords had already been converted-to-dashes).

I've got a work-in-progress fix (#3) that you can try out right now. I'll try to get it into a patch release soon.

jamesmacaulay commented 10 years ago

Some more clarification:

podviaznikov commented 10 years ago

Thank you for looking into it!

podviaznikov commented 10 years ago

Hi, I can confirm that call for creating charge is working.

Can you please tell me how to activate charge?

I'm not quite sure with what parameters to call save! for such resource /admin/recurring_application_charges/455696195/activate.json.

jamesmacaulay commented 10 years ago

Good question. I don't think there's a very good way of doing this right now that is integrated into the documented API of this library. However, you can build up the request manually and send it like so:

(defn activate-recurring-charge!
  "Sends a request to activate the charge with the given id"
  [id auth]
  (-> auth
      (assoc
        :method :post
        :uri (str "/admin/recurring_application_charges/" id "/activate"))
      (shopify.resources/request)))

(shopify.resources/request is the function that actually performs the request)

podviaznikov commented 10 years ago

Thanks! That worked