Question

Both MtGox and Coinbase offer these extremely easy to copy/paste JavaScript buttons to accept bitcoin payments. And they both offer callback mechanisms where they 'push' completed orders back to your site.

But both services seem to omit any documentation about how I can link a completed order 'push' on my callback URL back to the customer who is at my site. The push JSON data has a transaction ID, etc. But I don't see any way to get matching data on the site that my customer visited. Now, if the javascript running on my web site that exposed the button created some JavaScript variable I could look-up in order to find a transaction ID at the conclusion of the transaction so that I could match the customer with the completed order I get from Coinbase, that would be great. But I see no documentation to that effect.

How do folks do this?

Was it helpful?

Solution

There is a custom parameter you can pass in when creating the button. At first this doesn't seem useful because if it's hard-coded into the button it's the same for every user. But if you combine this with the fact that button attributes can be overridden in the HTML (as described here in the "Customizing the Embed HTML" section), then suddenly your site can include a unique value for every customer that will propagate from the order button to the callback message.

Here is what Coinbase generates for you:

<a class="coinbase-button"
   data-code="coinbase-generated-code"
   href="https://coinbase.com/checkouts/coinbase-generated-code">Pay With Bitcoin</a>
<script src="https://coinbase.com/assets/button.js" type="text/javascript"></script>

You can modify it slightly to include a data-custom HTML attribute. This value will propagate through the order all the way to the callback JSON message. By setting its value to your customer ID (or any other unique value), you'll be able to associate the callback with your customer when it comes in from Coinbase.

<a class="coinbase-button"
   data-code="coinbase-generated-code"
   data-custom="YOUR-CUSTOMER-ID-HERE" 
   href="https://coinbase.com/checkouts/coinbase-generated-code">Pay With Bitcoin</a>
<script src="https://coinbase.com/assets/button.js" type="text/javascript"></script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top