如何将Stripe付款与Google Apps脚本集成

编程入门 行业动态 更新时间:2024-10-28 03:24:13
本文介绍了如何将Stripe付款与Google Apps脚本集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

根据此答案,Gmail不公开用于发送和接收付款的API.因此,我正在尝试使用Stripe 来实现这一目标.

According to this answer, Gmail does not expose an API for sending and receiving payments. Therefore, I am trying to use Stripe to accomplish that.

// Set your secret key: remember to change this to your live secret key in production // See your keys here: dashboard.stripe/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); (async () => { const product = await stripe.products.create({ name: 'My SaaS Platform', type: 'service', }); })();

但是,GAS目前不直接支持async和require.有没有可能的解决方法,这样我就可以使用Stripe在我的GAS应用程序中发送和接收付款?

However, GAS does not directly support async and require at this time. Is there any possible workaround so I can use Stripe to send and receive payments in my GAS app?

如果那不可能,我应该从这里往哪个方向走?

If that's not possible, what direction should I go from here?

推荐答案

这个答案怎么样?请认为这只是几个答案之一.

How about this answer? Please think of this as just one of several answers.

不幸的是,Node.js的模块不能直接用于Google Apps脚本.因此,需要为Google Apps脚本准备脚本.幸运的是,在您提出的问题的链接的官方文档中,有几个示例.使用此方法,如何转换为Google Apps脚本的脚本?

Unfortunately, the module of Node.js cannot be directly used for Google Apps Script. So it is required to prepare the script for Google Apps Script. Fortunately, at the official document of the link in your question, there are several samples. Using this, how about converting to the script of Google Apps Script?

将您问题中的脚本转换为Google Apps脚本后,它就会如下所示.

When your script in your question is converted to Google Apps Script, it becomes as follows.

// Set your secret key: remember to change this to your live secret key in production // See your keys here: dashboard.stripe/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); (async () => { const product = await stripe.products.create({ name: 'My SaaS Platform', type: 'service', }); })();

To

function myFunction() { var url = "api.stripe/v1/products"; var params = { method: "post", headers: {Authorization: "Basic " + Utilities.base64Encode("sk_test_4eC39HqLyjWDarjtT1zdp7dc:")}, payload: {name: "My SaaS Platform", type: "service"} }; var res = UrlFetchApp.fetch(url, params); Logger.log(res.getContentText()) }

  • 在这种情况下,Node.js和Google Apps脚本的请求都是相同的.
    • 在Node.js的示例脚本中,sk_test_4eC39HqLyjWDarjtT1zdp7dc被用作密钥.但是在这种情况下,由于使用了基本授权,因此请添加:来使用sk_test_4eC39HqLyjWDarjtT1zdp7dc:.
    • At the sample script of Node.js, sk_test_4eC39HqLyjWDarjtT1zdp7dc is used for the key. But in this case, because the basic authorization is used, please use sk_test_4eC39HqLyjWDarjtT1zdp7dc: by adding :.
    • 结算快速入门
    • UrlFetchApp类
    • Billing Quickstart
    • Class UrlFetchApp

    如果我误解了你的问题,而这不是你想要的方向,我深表歉意.

    If I misunderstood your question and this was not the direction you want, I apologize.

更多推荐

如何将Stripe付款与Google Apps脚本集成

本文发布于:2023-11-24 08:22:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624459.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   脚本   Google   Stripe   Apps

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!