Revamping Membership Plans through Stripe Integration and Parse Cloud Code

Currently, as I work on creating an app using parse.com and stripe as the payment provider for subscriptions, I am faced with a challenge. My goal is to set up a method that allows users to update their subscription plan. Following the guidelines provided in the stripe documentation, here is what my cloud code function looks like:

Parse.Cloud.define("stripeChangeSub", function(request, response) {

var currentUser = Parse.User.current();
var customer = currentUser.get('stripeCustomerId');
var subscriptionId = currentUser.get('stripeSubscriptionId');
var newPlan = request.params.plan;
var userProrate = request.params.prorate;
var stripeToken = request.params.token;

Stripe.Customers.updateSubscription(
    customer,
    subscriptionId,
    { plan: newPlan,
      prorate: userProrate,
      source: stripeToken})
.then(null, function(error) {
    response.error(error.message);
}).then(function(subscription) {
   // All tasks completed successfully!
   response.success(subscription);
});

});

However, upon running this function, I encountered the following error message:

P…e.Error {code: 141, message: "Received unknown parameter: sub_XXXXXX"}

The issue seems to be related to the correct subscription id stored in my user table as 'sub_XXXX.' Despite spending hours trying to resolve it and even conducting online research, I have not been able to find a solution...

Has anyone else faced a similar problem? Any suggestions or examples of working cloud code for this scenario would be greatly appreciated!

Thank you in advance for any assistance!

Best regards, Seb

Answer №1

Alright, I understand now:

It seems that parse only permits one subscription per user, so it doesn't require (and actually doesn't allow) the subscription ID at all. Unfortunately, parse cloud code deviates from the stripe api documentation in this particular scenario. There used to be documentation on this issue provided by Parse - however, the link to it (which is widely circulated online) is no longer valid.

Here is a link to an archived version of the old documentation though:

Seems like it still holds some value...

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

Inclusions of embedded Google Docs in iframes

I recently posted a Google Document with some helpful links. To display it on my webpage, I utilized an iframe code. However, whenever someone clicks on one of the links within the document, the iframe is replaced by the target URL of that link. In order ...

Ways to update the contents of an individual div within an ng-repeat loop

I am currently working on some Angular code. <div ng-repeat="item in items | filter:search" class="container"> <h3>{{item.name}}</h3> <p>category:{{item.category}}</p> <p>price:INR {{ ...

Tips for avoiding label overlap in JavaScript programming

I am having some trouble adding labels to a sphere. Only one label is attaching correctly, while the rest are overlapping in the corner of the screen. I have attached an image to show the issue. It may be a CSS problem, but I'm not entirely sure. Belo ...

Challenges when using deep linking to URL with AngularJS ui-router

Recently, I encountered an issue after restructuring the folder organization of my AngularJS application. Although I believe this might be a distraction from the root cause, I moved a section of functionality to its own directory for better organization. A ...

What is the best way to achieve a seamless transition between keyframes?

Currently, I am working on developing an animation system for my three.js project which involves utilizing a JSON file. While I have successfully implemented the animation playback, I am facing an issue where objects immediately move to their designated lo ...

Calculate the total of all the arrays of objects nested within the main array of objects

I have an array of objects with nested arrays, and I need to calculate the sum of certain values based on the same picker_id. Specifically, I want to sum up the current_capacity, process_time_in_minutes, and picked_qty inside the products array. Here is th ...

Modify the chosen value of a dropdown list that is created dynamically

In the JSP page, there is a dynamic drop-down list generated as shown below: <table BORDER=4 BORDERCOLOR=ORANGE width="300px"> <tr> <td>Model:</td> <td><select name="model" id="model"> &l ...

What is the best way to manage the browser tab close event specifically in Angular, without it affecting a refresh?

I am trying to delete user cookies when the browser tab is closed. Is this achievable? Can I capture the browser tab close event without affecting refreshing? If I attempt to use beforeunload or unload events, the function gets triggered when the user ref ...

Sending data through a form using AJAX and PHP

Greetings! I've developed a page that allows users to view results for a specific tournament and round. The user will first select a sport, which will then populate the available tournaments based on the sport selection. Following this, the user can ...

Tips for adding information into IndexedDB after receiving an AJAX response:

If I were to start by setting up the database outside of my Ajax call like this: // This code is compatible with all devices and browsers, utilizing IndexedDBShim as a last resort var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitInd ...

Utilizing Javascript to implement a tooltip feature for dynamically inserted text

I recently incorporated a brief jQuery tooltip plugin into my site. It consists of approximately ten lines of code and works smoothly, as demonstrated in this demo. However, I encountered an issue when attempting to add new text that should also trigger t ...

javascript varying functionality between Chrome and Firefox

My Grease monkey script/Tamper monkey is designed to click on buttons that contain the word 'attach'. Although it works perfectly, I have noticed a difference in behavior between Chrome and Firefox. In Firefox, the clicks occur in the order of a ...

Changing the Size of a Map using react-simple-maps within a React Application

I'm having difficulties with displaying a France map using react-simple-maps. The issue I'm facing is that the map appears too small despite my efforts to adjust it through CSS, width and height attributes, and by utilizing ZoomableGroup. Unfortu ...

Issue with AJAX loading functionality not functioning properly in Internet Explorer

For a project, I have a portfolio that I need to create. The front page consists of a div with a loader which determines the screen size upon landing and selects the content to be pulled in using ajax. The reason for this approach is due to the simplicity ...

AngularJS encountered an error while attempting to load a template: [$compile:tpload]

After developing my angularjs example app in my netbeans ide based local server, I encountered an issue when I tried to move the application to an nginx server. The browser displayed the following error message: Error: [$compile:tpload] Failed to load tem ...

Guide on downloading JSON from an external URL utilizing JavaScript (jQuery) Ajax

My attempt to fetch JSON content from a URL using JavaScript (jQuery) Ajax is continuously failing to retrieve the data. The code I am using is quite straightforward: <div id="content"> loading... </div> console.log("jQuery Ver ...

Guide to using Angular $resource to pass query parameter array

My goal is to implement a feature that allows users to be searched based on multiple tags (an array of tags) using the specified structure: GET '/tags/users?tag[]=test&tag[]=sample' I have managed to make this work on my node server and hav ...

Can you explain the significance of the ColSpan property in the Material UI TablePagination?

Why is ColSpan used in this code snippet? Reference: https://material-ui.com/components/tables/#table Check for the arrow symbol <TableFooter> <TableRow> <TablePagination rowsPerPageOptions={[5, ...

An error has occurred: Angular is unable to recognize the expression for ng-click and is throwing a syntax error

It's driving me crazy. The code is working fine, but I keep getting this error in the console. The line of code is part of an accordion menu created using Angular and UI-Router. <li ng-repeat="item in group.items"><a ng-click="setActiveView( ...

Click on the div to add items from an array into it

I have a unique set of lines stored in an array: var linesArr = ["abc", "def", "ghi"]; In my JavaScript, I dynamically create and style a div element using CSS: var div = document.createElement("div"); div.className = "storyArea"; div.in ...