繁体   English   中英

使用 Google Apps 脚本进行条纹支付

[英]Stripe payment using Google Apps Script

尝试使用示例代码在 Google Apps 脚本中创建 Stripe 结帐和收费。

HTML.html

 <!DOCTYPE html> <!-- modification of https://stripe.com/docs/checkout#integration-custom --> <button id="customButton">Purchase</button> <script src="https://checkout.stripe.com/checkout.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script> var handler = StripeCheckout.configure( { key: 'pk_test_UUbDY16wDCECOujIs0vQ2vTi', image: 'https://i.imgur.com/M0ku9HH.png', token: function(token) { // Use the token to create the charge with a server-side script. // You can access the token ID with `token.id` google.script.run.withSuccessHandler(chargeSuccess) google.script.run.withFailureHandler(chargeFailure) google.script.run.processCharge(token); } } ); $('#customButton').on('click', function(e) { // Open Checkout with further options handler.open( { name: 'ASD Anastasiya Ballet S.', description: 'Pagamento online' }); e.preventDefault(); }); function chargeSuccess(result) { // handle response code client side } function chargeFailure(error) { // client error handling } </script>

GS.gs
google.script.run.processCharge(token);

表单工作正常但不收费,因为似乎没有创建令牌。 根本不是 JS 专家,我不确定该功能是否

token: function(token)

那叫

google.script.run.processCharge(token);

被正确执行。

您的代码失败了,因为您已注释掉 custId - 必须提供此信息。 留下这个没有坏处,它只会创建一个测试客户。 否则,在 Stripe 控制面板中创建一个客户并将 ID 复制到 custId 中。

您可以随时查看“查看 > 执行记录”以获取有关脚本失败原因的线索。

暂无
暂无

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

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