bchavez / Coinbase.Commerce

:moneybag: A .NET/C# implementation of the Coinbase Commerce API.
https://commerce.coinbase.com/docs/
Other
48 stars 9 forks source link

Question: Charge vs Checkout Charge #14

Closed Mike-E-angelo closed 3 years ago

Mike-E-angelo commented 3 years ago

First off, thank you so much for putting this library together! Especially the Webhook integration. It's going to save me a lot of work. 👍

I did have a question that perhaps you can help answer for me. In my Coinbase Commerce account, I have created a Checkout. Now, in the API, it says Checkouts can have many charges and each charge is automatically generated on a per customer basis.

However, when creating a charge, I do not see where to assign the checkout, neither in this API nor on Coinbase Commerce itself. So, I'm now officially confused. 😅

My understanding is you create a checkout and when you visit that checkout it creates a charge. You can also create a charge directly. However, it doesn't seem you can create a charge from a checkout (even though it seems this happens when you visit a created checkout from the Commerce settings).

I hope this makes sense. It would be really helpful to get this figured out.

Otherwise, great work out there. The documentation, too!

Mike-E-angelo commented 3 years ago

FWIW I am working around this ATM by requesting commerce.coinbase.com/checkout/{id} in an HTTP request and then parsing the resulting response redirect (commerce.coinbase.com/charges/{id}) for the charge id.  Hardly elegant but works.

Mike-E-angelo commented 3 years ago

Ok after spending the past day or so poking and prodding the API I believe I have enough understanding here to answer my own question.

It would seem that there are two ways of making charges:

  1. via Checkout that can be created through the Commerce UI and API (Checkout Charges)
  2. via API directly (Direct Charges)

Checkout Charges do not not have return/cancel URLs but do honor the branding color defined in account settings. Conversely, Direct Charges do have return/cancel URLs but do not honor the branding color defined in account settings.

So it would seem that the checkout property in the Charge object simply denotes that it was created by a Checkout object and if so, which one. It cannot be set via the API and the only way it is set is to visit the Checkout page directly via a web request, where Coinbase creates the charge automatically for you behind the scenes, and subsequently redirects you there.

Kind of misaligned to say the least, but that's what we're left to work with here. I should also end this by stating that I am a bit concerned that the API that we're dealing with here hasn't been updated since 2018, but I guess that's another issue altogether.

In any case, I feel my issue here has been answered.