简体   繁体   English

如何将Coinbase回调与您网站上的客户联系起来?

[英]How to tie a coinbase callback back to the customer on your site?

Both MtGox and Coinbase offer these extremely easy to copy/paste JavaScript buttons to accept bitcoin payments. MtGox和Coinbase都提供了这些非常容易复制/粘贴的JavaScript按钮,以接受比特币付款。 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. 但是,这两种服务似乎都省略了有关如何将回调URL上已完成的订单“推”链接回站点上的客户的任何文档。 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. 推JSON数据具有事务ID,等等。但是我看不到任何方法可以在客户访问的网站上获取匹配数据。 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. 现在,如果暴露在按钮上的网站上运行的javascript创建了一些JavaScript变量,那么我可以进行查找以便在交易结束时找到交易ID,以便我可以将客户与从中获得的完整订单进行匹配Coinbase,那太好了。 But I see no documentation to that effect. 但我看不到有任何相关文档。

How do folks do this? 人们如何做到这一点?

There is a custom parameter you can pass in when creating the button. 创建按钮时可以传递一个custom参数。 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. 但是,如果你的事实,按钮属性可以在HTML覆盖结合本(如描述这里的“自定义嵌入HTML”部分),然后突然你的网站可以包括对每一位客户的唯一值将从订单传播回调消息的按钮。

Here is what Coinbase generates for you: 这是Coinbase为您生成的:

<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. 您可以对其稍加修改,以包含data-custom HTML属性。 This value will propagate through the order all the way to the callback JSON message. 该值将通过顺序一直传播到回调JSON消息。 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. 通过将其值设置为您的客户ID(或任何其他唯一值),当回调来自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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM