Google Forms PayPal Express集成 [英] Google Forms PayPal Express Integration

查看:142
本文介绍了Google Forms PayPal Express集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为IT预算为0的非赢利性工作.他们需要允许用户在Google表单上输入信息,然后收取款项.我已经对该主题进行了大量研究,目前看来您只能在Google表单上添加超链接以链接到PayPal.但是,我想知道是否有某种方式链接PayPal Express Checkout javascript(解决方案

我最近为这个确切的问题苦苦挣扎,最终建立了此处并创建一个按钮.然后,您需要获取按钮的原始文本链接,贝宝将其称为电子邮件"链接.版本.您可以将其直接插入到表单中,并告诉用户访问它.一个问题是没有真正的方法来获取交易ID.您可以尝试将表单提交时间与付款时间相关联,或者将付款人电子邮件与表单提交电子邮件相关联.可能两者都不匹配,您必须手动进行.

快速结帐要求您通过调用PayPal API为每次付款动态创建一个新链接.这意味着您的链接需要打开一个页面,然后生成一个快速签出URL并将用户重定向到该页面.您可以使用 Google Apps脚本中的网络应用 >触发器,或者您可以使用任何语言在服务器上创建后端.

如果您可以在某个地方运行自己的服务器,我建议(很多PaaS服务都有免费层).当您不使用Apps Script时,测试和调试事情要容易得多.我使用了 PayPal节点SDK ,尽管无需维护,但效果很好. (Express Checkout已被PayPal弃用",但我敢打赌它不会很快消失).他们的榜样将带给您大部分帮助.当用户到达时,生成付款链接并重定向他们.完成后,他们将返回您的服务器,您可以显示任何内容.例如,您可以要求他们复制交易ID并将其粘贴到您的表单中.

最后,提交表单时,可以设置onSubmit()触发器.表单实际上有两种onSubmit()触发器-一个(表示表单本身),然后一秒钟用于链接到表单的电子表格.您可以注册触发器以进行额外的处理(例如,查找交易ID),但不能在触发器中修改响应.但是,您可以修改发送触发器的电子表格,在大多数情况下,该电子表格是等效的.例如,您可以根据交易代码在电子表格中添加一列,并带有指向PayPal交易的链接.

I am doing work for a non profit with 0 budget for IT. They need to allow users to enter information on a Google Form and then collect payment. I have done a lot of research on the topic and currently appears you can only add a hyperlink on the Google Forms to link to PayPal. However, I was wondering if there was some way to link the PayPal Express Checkout javascript(https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/add-paypal-button/) into the Google Form so it calls back with a transaction id and status. Then I would be able to somehow insert those values into the Google Form. Any thoughts on how to integrate would be helpful. I am a developer but not familiar with Google Forms.

解决方案

I recently wrestled with this exact question and ended up building a G Suite addon to make this easier for others. Coincidentally I also do volunteer IT for a small nonprofit and we wanted to use PayPal with our signup form (there's pricing for the addon but just ping me if you're a small nonprofit).

Here's what I learned while building it:

  • There's no way for Apps Script to modify the form once it's shown to the user, or to use Apps Script to respond to user input
  • There's no way to redirect the user automatically to PayPal after a form is submitted

That means if you want to send someone to PayPal, you've got to use an ordinary link. You can do this within the form by adding the URL to a question description, or you can add the URL to the text shown once someone has submitted the form. For PayPal, you've got two options for this kind of link:

  1. PayPal buttons
  2. Express checkout

PayPal buttons are a static link managed by PayPal. They don't require any coding - just go here and create a button. Then you need to get the raw text link for the button, which PayPal calls the "email" version. You can insert that into your form directly and tell users to access it. The one problem is there's no real way to get the transaction ID. You could try correlating the form submit time with the payment time, or the payer email with the form submit email. It's possible that neither of them will match up and you'll have to do it manually.

Express checkout requires you to dynamically create a new link for each payment by calling the PayPal API. That means your link needs to open a page that then generates an express checkout URL and redirects the user to it. You can do this using a web app in Google Apps Script using a doGet() trigger, or you can create your backend on your server in any language.

If you can run your own server somewhere, I recommend that (plenty of PaaS services have a free tier). It's much easier to test and debug things when you aren't using Apps Script. I used the PayPal Node SDK which works great despite being unmaintained. (Express checkout is "deprecated" by PayPal, but I'll bet it's not going away anytime soon). Their example will get you most of the way there. When the user arrives, generate a payment link and redirect them. When they finish they'll return to your server, and you can display whatever you want. For example, you can ask them to copy the transaction ID and paste it into your form.

Finally, when your form is submitted an onSubmit() trigger can be set up. There are actually two kinds of onSubmit() triggers for forms - one for the form itself, and a second for the spreadsheet linked to the form. You can register a trigger to do extra processing (e.g. look up the transaction ID), but you can't modify the response in the trigger. You can however modify the spreadsheet where the trigger gets sent, which for most cases is equivalent. For example, you could add a column to the spreadsheet with a link to the PayPal transaction based on the transaction code.

这篇关于Google Forms PayPal Express集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆