Refresh the Parse.com User through a Stripe Webhook

Despite finding many Parse / Stripe questions on this platform, none have been able to assist me with my specific issue.

In my mobile application, I have both free and paid features. A variable stored on the User class in Parse.com is used to check permissions when running a function. I am looking to create an account portal, separate from my app, where users can sign up for different plans securely via their browser.

For this account portal, I have set up a WordPress site with a Stripe plugin to handle accounting, invoicing, and form creation tasks.

After users sign up on the WordPress site, I want to receive a webhook on Parse.com and execute a function to update the User class. Ideally, this function will manage various user states based on their account status, such as putting a plan on hold if they stop paying.

My question encompasses two main points:

  1. What specific details (URL, etc.) do I need to include in my Stripe webhook settings to ensure all events are sent to my Parse.com cloud code?

  2. How can I receive and execute my function on the cloud code when a webhook is received from Parse.com?

I am open to constructive feedback and suggestions on how to improve the functionality of my app.

Thank you for your help in advance.

Answer №1

After some exploration and trial and error, here is what I discovered:

  1. To integrate with Stripe Accounts, create a webhook using the following URL:

    https://**APP_ID**:js-key=**JS_KEY**@api.custom.com/1/functions/update_account

  2. When writing your cloud code, ensure the function name matches the last part of the URL. For example, use update_account in my scenario.

  3. For testing purposes, set up a trial version of the webhook in your cloud code like so:

Custom.Cloud.define("update_account", function(req, res) {
  res.success('** WEBHOOK TEST SUCCESSFUL **' + req);
});

When testing the webhook on the Stripe dashboard, you should observe the following outcome:

I hope this insight proves helpful to someone. I welcome any feedback on my implementation or suggestions for a streamlined function to execute on my Account class update.

Answer №2

It seems like your proposed solution should do the trick.

However, it's worth noting that utilizing the javascript key could potentially open up a security vulnerability if you're not carefully validating events originating from Stripe.

Keep in mind that your javascript keys will be accessible within your website's code. This means that if someone were to obtain them, they could potentially call your cloud code function and manipulate critical billing information. To mitigate this risk, I'd recommend using the master key to ensure that requests are coming from trusted sources only.

For added security, you can incorporate a check in your cloud function to verify if the master key was utilized:

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can you center popup windows launched from the main window using jquery?

Within my web application, I frequently utilize popup windows that open at different locations on the screen. These popups are standard windows created with window.open() rather than using Jquery. Now, I am seeking a solution to automatically center all p ...

Populating Hidden Form Fields with Dynamic Identifiers

I'm facing an issue with a form where I need to input a value into a hidden field upon clicking a button. Despite using unique IDs for all elements, the data is not being submitted in the POST request. The IDs are unique because there are multiple f ...

What could be the reason for receiving no file input after submitting the form?

One of the functions triggers the input file and displays previews: $(document).on("change", "#Multifileupload", function() { var MultifileUpload = document.getElementById("Multifileupload"); if (typeof FileReader != & ...

Steps to store chosen option from dropdown list into a database's table

I am currently populating a dropdown list in my PHP file by fetching data from a database. Here is the code snippet: <script type="text/JavaScript"> //get a reference to the select element var $select = $('#bananas'); //reques ...

How to Loop through a WordPress Object in PHP

I'm brand new to PHP and I've been learning about iterating through objects and arrays. I know that you use -> for objects and ["itemInArray"] for arrays. However, I'm a bit confused on how to access the post_content from the object below ...

Tips for Utilizing CSS Overflow: Hidden to Prevent the Parent Container from Expanding

I have a fixed width column and a fluid column. In the fluid column, I want to display a string with nowrap so that it does not overflow the container. Here is an illustration of how I want the text to appear: --------------------------------------------- ...

What is the best approach for creating a test case for a bootstrap-vue modal component

Exploring ways to effectively test the bootstrap vue modal display function. On the project page, the modal toggles its visibility using the toggleModal method triggered by a button click. The modal's display style is switched between 'none' ...

Accordion featuring collapsible sections

Looking to build an accordion box using Javascript and CSS. The expanded section should have a clickable link that allows it to expand even further without any need for a vertical scroll bar. Any ideas on how this can be achieved? Thank you ...

Can the lazy load script dependent on jQuery be utilized before the jquery.js script tag in the footer?

After receiving HTML from an AJAX callback, I noticed that there is a script tag for loading code that uses jQuery. However, I consistently encounter the error of jQuery being undefined. All scripts are connected before the closing </body> tag. Is ...

Android params not being transferred to Node.js properly when using Volley

I am currently developing an application that utilizes several node.js scripts for server scripting primarily due to node.js's built-in Firebase support. However, I have encountered an issue where I am unable to send any parameters with my requests, w ...

Send data using only Javascript

Hey there, I'm a beginner in javascript and I'm having some trouble submitting a form using pure javascript. Here is my code: var myform = document.getElementById('js-post-form'); myform.addEventListener('submit', function(e ...

What are the ways in which the "npm install <module>" command can be utilized in the creation of web pages for browsers?

When incorporating a resource into a web page, I have the option to either link to the file (locally, hosted by the web server, or on a CDN) <link rel="stylesheet" href="https://somecdn.com/mycssresource.min.css"> <script src="alocalscript.js"> ...

Using Previous and Next Buttons in Bootstrap Tabs for Form Navigation

I am currently facing a challenge in splitting a form into multiple tabs and encountering issues with the next and previous buttons on the second and third tabs. My goal is for the tabs at the top to change state as you cycle through them by clicking the ...

Encountering problem while exhibiting server's response message within a modal popup in Angular 6

I have implemented two custom dialog modals in an Angular component. The objective is to open the appropriate modal and display the response message. The component receives two values as Observables from my services: The name of the modal that needs to ...

Employ a for loop to generate custom shapes within the canvas

EDIT: I will be sharing all of my code including the HTML and JS. Pardon me for the abundance of comments. I am attempting to generate rectangles in a canvas using a for loop (taking user input) and then access them in another function to perform certain ...

The visibility of the button is not functioning properly on iOS within the Kony platform

Currently, I am involved in a project using Kony and have encountered an issue where I need to hide a button based on a certain condition. I have implemented the code provided below, which functions correctly on Android devices but not on iOS. I have gone ...

Filtering data in Vue.js using JSON specifications

How can I display only the names in the data? I currently have cards filtered by cities <div v-for="item in stationCityData"> <div v-for="option in filteredCity" style="background:#eee;padding: 20px"> <!-- <div v-for="option ...

Tips for creating a tooltip above an SVG circle with AngularJS

I'm currently working on a project where I am using AngularJS and SVG to plot circles on a page. My goal is to have a tooltip appear when a user hovers over one of the circles. I came across an explanation on how to achieve this on this website, but u ...

Retrieve the ID of a specific row within a table in a datatables interface by selecting the row and then clicking a button

My goal is to have a table displayed where I can select a row and then have the option to edit or delete that row with a query. To achieve this, I need a primary key that won't be visible to the user. This is how my table is set up: <table id=&apo ...

Ways to set a default image for an <img> tag

I am looking to set a default image to the img tag in case the user has not selected a profile picture for their account. Here is the current output: http://jsfiddle.net/LvsYc/2973/ Check out the default image here: This is the script being used: funct ...