热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

从StripeWebhook更新Parse.com用户-UpdateParse.comUserfromStripeWebhook

FirstlyIseethereareseveralParseStripequestionsonherehowevernoneareofanyhelptome.

Firstly I see there are several Parse / Stripe questions on here however none are of any help to me.

首先我看到这里有几个Parse / Stripe问题,但没有一个对我有任何帮助。

I have a mobile application that has both free and paid features. A variable is stored on the User class in Parse.com and it is checked for permissions when running a function. I would like to setup an account portal (separate to my app) so when users wish to signup they are sent to their browser and can signup to a plan over SSL etc etc.

我有一个具有免费和付费功能的移动应用程序。变量存储在Parse.com中的User类中,并在运行函数时检查其权限。我想设置一个帐户门户(与我的应用程序分开),因此当用户希望注册时,他们会被发送到他们的浏览器,并可以通过SSL等注册到计划。

For the account portal i'm having a Wordpress site with a Stripe plugin that will do my accounting, invoicing and form creation work for me.

对于帐户门户网站,我有一个带有Stripe插件的Wordpress网站,可以为我的会计,发票和表单创建工作。

Following signup on the Wordpress site I would like to receive the webhook on Parse.com and run a function to update User class. Ideally this will be a catch all function that will change the user to a number of states depending on their account status (i.e they stop paying and the plan will be on hold).

在Wordpress网站上注册后,我想在Parse.com上收到webhook并运行一个更新User类的函数。理想情况下,这将是一个捕获所有功能,将根据他们的帐户状态将用户更改为多个州(即他们停止支付并且计划将被暂停)。

My question is two fold:

我的问题有两个:

  1. What details (URL etc) do I need to place in my Stripe webhook settings to send all events to my Parse.com cloud code?

    我需要在Stripe webhook设置中放置哪些详细信息(URL等)以将所有事件发送到我的Parse.com云代码?

  2. How do I receive / run my function on the Cloud code upon receipt of a webhook from Parse.com?

    在收到Parse.com的webhook后,如何在Cloud代码上接收/运行我的功能?

I am open to criticism and remain flexible in my implementation if you have suggestions on how my app should work.

如果您对我的应用程序应该如何工作有任何建议,我会批评并在我的实施中保持灵活性。

Many thanks in advance.

提前谢谢了。

2 个解决方案

#1


6  

Ok after some experimenting:

经过一些实验后确定:

  1. create a webhook on in the Stripe Accounts area using the URL: https://**APPLICATION_ID**:Javascript-key=**Javascript_KEY**@api.parse.com/1/functions/update_user

    使用以下URL在Stripe Accounts区域中创建webhook:https:// ** APPLICATION_ID **:Javascript-key=**Javascript_KEY**@api.parse.com/1/functions/update_user

  2. In your cloud code use the same function name as the final part of your URL. in my case update_user.

    在您的云代码中,使用与URL最后部分相同的函数名称。在我的情况下update_user。

  3. Create a test version of the webhook and place this in your cloud code for testing :

    创建webhook的测试版本并将其放在您的云代码中进行测试:

Parse.Cloud.define("update_user", function(request, response) { response.success('** WEBHOOK WORKING **' + request); });

Parse.Cloud.define(“update_user”,function(request,response){response.success('** WEBHOOK WORKING **'+ request);});

When running the test in the stripe dashboard you should see:

在条带仪表板中运行测试时,您应该看到:

enter image description here

Hope that this helps someone - Would be grateful of any input anyone has as to my implementation or a slick function to run on my User class update.

希望这有助于某人 - 感谢任何人对我的实现所做的任何输入或者在我的User类更新上运行的光滑功能。

#2


1  

Mostly I think your solution will work.

我认为你的解决方案大多数都可以。

I think using the Javascript key could pose a security risk if you are not validating events that come from stripe.

我认为如果您没有验证来自条带的事件,使用Javascript密钥可能会带来安全风险。

Your Javascript keys will be present in your web site. Someone could get it and call your cloud code function. I'd use the master key so you know its only from sources you trust. They might be able change important billing information.

您的Javascript密钥将出现在您的网站上。有人可以得到它并调用您的云代码功能。我会使用主密钥,因此您只能从您信任的来源获知它。他们可能会更改重要的结算信息。

In your cloud function definition you can check if the master key was used.

在您的云功能定义中,您可以检查是否使用了主密钥。

Parse.Cloud.define('stripeEvents', function (request, response) {
if (request.master){
    return response.success('stripeEvents - master');
}
response.error('stripeEvents - must use master key');});

推荐阅读
author-avatar
一林泽鹏_444
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有