Error when creating charge with Parse.com Stripe API - javascript

I'm trying to create a charge with a test account on stripe.
Here is my parse cloud function:
Parse.Cloud.define("charge", function(request, response) {
var Stripe = require('stripe');
Stripe.initialize('...');
Stripe.Charges.create({
amount: 1000,
currency: "usd",
customer: "..."
},{
success: function(httpResponse) {
response.success("Purchase made!");
},
error: function(httpResponse) {
response.error("Uh oh, something went wrong");
}
});
});
I've hard coded the customerID into the function just for testing.
When I call the function from my app, I get the following error:
TypeError: Object [object Object] has no method '_each'
at request (stripe.js:58:11)
at post (stripe.js:117:12)
at Object.module.exports.Charges.create (stripe.js:157:16)
at main.js:19:18 (Code: 141, Version: 1.6.2)
Can anyone help?

#user3707419 I get the same error when trying to add a customer. Comment out that line and instead add the following:
card: stripeToken //this is the token you generated
Also, if that doesn't work, you need to revert you parse cloud code version to 1.5.0 (you are probably running the latest version 1.6.0 which does not work. The way you do this is type the following into your console:
parse jssdk 1.5.0
All of my working code on version 1.5.0 is located at this post:
Complete working Stripe + Parse.com working code on version 1.5.0
We may have to revert back even further to get customer: customer.id working I'm not sure. Let me know if you figure a different solution out. Hope this helps.

For what it's worth, your code looks very similar to my cloud code that works. However, I do not have a semicolon after the first }). Just after the final one.
If that's not the error, then i'm not very sure how to interpret your errors because i cannot see the code at the mentioned lines. Best of luck

Just so you know the real reason: Parse removed underscore lib , stripe.js thats built into parse cloud code relied on it. Hence failure like this.
Parse 1.6.X no longer supports modules, they removed them from API doc as well.

Related

JavaScript runtime error: [Messenger] Required property 'target' was not provided occurred

I am using the Developers API with an App I created in LinkedIn.
When I call this method to sign in.....
IN.UI.Authorize().params({ "scope": ["r_liteprofile", "r_emailaddress"] }).place()
a Window begins to open and I get this error message:
Unhandled exception at line 7, column 56783 in
http://platform.linkedin.com/in.js 0x800a139e - JavaScript runtime
error: [Messenger] Required property 'target' was not provided
occurred
I have completed LinkedIn's App Setup, but can't figure what could be causing this. My JavaScript code is below:
[script type="text/javascript" src="//platform.linkedin.com/in.js"]
api_key: 'xxxxx......xxxxx'
authorize: true
[/script]
function LinkedInSignIn() {
IN.UI.Authorize().params({ "scope": ["r_liteprofile", "r_emailaddress"] }).place();
IN.Event.on(IN, 'auth', getProfileData);
}
function getProfileData() { // Use the API call wrapper to request the member's basic profile data
IN.API.Profile("me").fields("id,firstName,lastName,email-address,picture-urls::(original),public-profile-url,location:(name)").result(function (me) {
var profile = me.values[0];
var id = profile.id;
alert(profile.firstName);
});
}
As it turned out, the reason this is not working is becuase LinkedIn discontinued it at the end of 2018. Contacting LinkIn's support wasn't much help either. They only said they do no support thier code library and referred my back here to StackOverflow.
For anyone having the same problem, the solutions is to use Oauth2, which is documented at:
https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context
Happy Coding!
Graham

Javascript Buy SDK - Error: Not Found

I'm trying to retrieve products from my Shopify store with this code, a near copy/paste of the examples page for the Javascript Buy SDK:
$(function() {
var shopClient = ShopifyBuy.buildClient({
accessToken: '4b4e3d4bba63039f2d51db94c2e79a46',
domain: 'squatch-air-clutches-test.myshopify.com',
appId: '6'
});
shopClient.fetchQueryProducts({
collection_id: 1397227547
}).then(function(products) {
$('.test').append(JSON.stringify(products));
});
shopClient.fetchProduct('46656520219').then(function(product) {
$('.test').append(JSON.stringify(product));
});
});
Here's a fiddle.
The buildClient command seems to complete successfully, however I get a console error with the next two commands: Error: Not Found. I assume this refers to the product not able to be found, but I am sure both the product and the collection ids are correct. And I am also sure that I have read access enabled for "products, variants, and collections" for my private app. Would there be any other reason I am getting this error, and if so, what's a solution?
Got it. The App ID was incorrect. I needed to go to /admin/settings/storefront_access_tokens and grab the correct ID for my sales channel. I'm disappointed that it was so difficult to find though - the documentation on this seems convoluted.

Parse.com Javascript SDK using include, but not working

I'm trying to fetch data from a table called Book. Inside Book there's a Pointer<ParseUser> which holds the pointer of one user. The ParseUser has another pointer called Pais (which means Country in spanish). So I want to fetch every single info from any Book:
var query = new Parse.Query("Book");
query.include("user");
query.include("user.pais");
query.find({
success: function(books) {
response.success(books);
},
error: function(error) {
response.error({'resp': error.code, 'message': error.message});
}
});
and I don't get the objects, just the pointers:
Why ? I know it works ok when I call it in iOS or Android with include(String key) or includeKey: NSString* key.
Why doesn't it work with Javascript??
Thank you in advance.
Regards.
Rafael.
EDIT:
Oh and I just forgot... I've tried with:
query.include(["user"]);
and
query.include(["user", "user.pais"]);
I've seen some examples where developers used it.
SECOND EDIT:
The last thing I've used is fetch like:
Parse.Object.fetchAll(books, {
success: function(list) {
response.success(list);
},
error: function(error2) {
response.error({'resp': error2.code, 'message': error2.message});
},
});
But didn't work either.
This is starting to freak me out.
OUR WORKAROUND:
The workaround we're trying to do is fetching everything separately, and then returning back to the user together. This is not a good practice since a little change in the class in a future would ruin the whole function.
Is this a bug in the SDK ?
(This is a comment turned into an answer)
Just a thought because I recently had a problem with CloudCode that is quite similar to yours. What version of the JavaScript SDK are you using? I solved my problem by changing the version back to 1.4.2. It's just a shot in the dark in your case, but it might work.
Here is the thread where I described the problem and how to solve it by changing the SDK version.

WebAPI using BreezeJS throws an error as soon as I use $skip

I have a working WebAPI (v2) which utilizes the awesome BreezeJS product. I am attempting to add paging capabilities, but as soon as I include $skip in the URL as a parameter, the WebAPI generates this error:
{
$id: "1",
$type: "System.Web.Http.HttpError, System.Web.Http",
Message: "An error has occurred."
}
Debugging the API does not give me any additional information, since it doesn't crash.
The parameters I'm passing are: http://www.example.com/api/Test/Designs?$skip=5&$top=5&$inlinecount=allpages&
If I call it without the $skip parameter, it works fine. The other "$" params seem to work just fine, as I can call:
http://www.example.com/api/Test/Designs?$top=3
and it works as expected.
I have verified that I'm not using any BreezeQueryable attributes or anything, so $skip should be allowed.
Additional setup info if it helps:
SQL Server Express v2012
Breeze on the server side is v1.5.0.0
Entity Framework v6
Microsoft.Data.OData is v5.6
Is there something else I need to have enabled in order to utilize paging? Or is there a way I can find the true cause of this error? I can provide a working URL if requested.
Thank you.
A sort is required to use skip:
From the breeze docs:
// Skip the first 10 Products and return the rest
// Note that the '.orderBy' clause is necessary to use '.skip'
// This is required by many server-side data service implementations
var query3 = EntityQuery.from('Products')
.orderBy('ProductName')
.skip(10);

Google Drive SDK JavaScript 404 Error

We are getting since yesterday an error each time we try to execute any Drive Method from Javascript Library, such as:
gapi.client.drive.files.get({'fileId': RootFolderID});
gapi.client.drive.children.list({'folderId' : FolderGUID, 'q': 'trashed = ' + trashed});
Or any other.
When we execute this code code:
var RootFolderID = "0Bz9GhmOJPXaDMmlnc1UtNmFKb28";
var GetFileInfo = gapi.client.drive.files.get({'fileId': RootFolderID});
GetFileInfo.execute(function(GetFileInfoResp){
log("RootFolderID", RootFolderID);
log("GetFileInfoResp", GetFileInfoResp);
});
We get the following error
RootFolderID - 0Bz9GhmOJPXaDMmlnc1UtNmFKb28
GetFileInfoResp- Object {code: 404, message: "Not Found", data: Array[1], error: Object}
code: 404
data: Array[1]
error: Object
message: "Not Found"
proto: Object
Two days ago the same code was working fine.
Anyone has the same problem? do you have any clue?
When we try to execute the same method from the Drive SDK help, it works.
We have the same problem. Please vote for the issues 136 & 137 https://code.google.com/p/google-api-javascript-client/issues/list
Sergey Pisarenko spisarenko#google.com
12:41 wrote...
to google-appengi., google-cloud-s., gce-operations
Google API JavaScript client functionality has already been restored for some users, and we expect a resolution for all users in the near future. Please note this time frame is an estimate and may change. Further information for customers with a support contract will also be available in the Google Enterprise Support Center. We will provide an update by 12:30 GMT.
the issue has been solved by Google.
It seems they did a wrong udpate of libraries.
They have rollback the libraries and now it's working fine again.
Thanks and regards,
Fernando.

Categories