热门标签 | 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');});

推荐阅读
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • MySQL 数据库迁移指南:从本地到远程及磁盘间迁移
    本文详细介绍了如何在不同场景下进行 MySQL 数据库的迁移,包括从一个硬盘迁移到另一个硬盘、从一台计算机迁移到另一台计算机,以及解决迁移过程中可能遇到的问题。 ... [详细]
  • Scala 实现 UTF-8 编码属性文件读取与克隆
    本文介绍如何使用 Scala 以 UTF-8 编码方式读取属性文件,并实现属性文件的克隆功能。通过这种方式,可以确保配置文件在多线程环境下的一致性和高效性。 ... [详细]
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 本文详细介绍了如何在BackTrack 5中配置和启动SSH服务,确保其正常运行,并通过Windows系统成功连接。涵盖了必要的密钥生成步骤及常见问题解决方法。 ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 本文详细介绍了Java编程语言中的核心概念和常见面试问题,包括集合类、数据结构、线程处理、Java虚拟机(JVM)、HTTP协议以及Git操作等方面的内容。通过深入分析每个主题,帮助读者更好地理解Java的关键特性和最佳实践。 ... [详细]
  • ImmutableX Poised to Pioneer Web3 Gaming Revolution
    ImmutableX is set to spearhead the evolution of Web3 gaming, with its innovative technologies and strategic partnerships driving significant advancements in the industry. ... [详细]
  • MongoDB集群配置:副本集与分片详解
    本文详细介绍了如何在MongoDB中配置副本集(Replica Sets)和分片(Sharding),并提供了具体的步骤和命令,帮助读者理解并实现高可用性和水平扩展的MongoDB集群。 ... [详细]
  • 本文详细解析了Python中的os和sys模块,介绍了它们的功能、常用方法及其在实际编程中的应用。 ... [详细]
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社区 版权所有