komola / paymill-node

Node.JS wrapper for the Paymill v2 API
MIT License
24 stars 11 forks source link

Adapted to support usage on Parse.com's Cloud platform. #12

Closed testower closed 10 years ago

testower commented 11 years ago

Example:

paymill.clients.create({
  email: "test@example.com"
},
{
  success: function(result) {
    var client = result.data.data;
  },
  error: function(error) {
    console.log(error.text);
  }
});
thomaschaaf commented 11 years ago

Could you briefly elaborate, what advantages parse brings with it?

yields commented 11 years ago

wait, parse.com requires it's clients to change modules ?

testower commented 11 years ago

You can't use the 'https' module in Parse Cloud, so to make https requests, you must use Parse.Cloud.httpRequest. Also, Buffer has to be explicitly required.

I realize this is perhaps not something you'd want to have in the normal distribution, but I'm sure others could find it useful to easily integrate paymill as an alternative to Stripe.

Edit: Stripe is the payment solution that Parse.com supports (by providing their module in their "Cloud")

testower commented 11 years ago

You can't just use any module in Parse.com. There are only some predefined modules available, and https is not one of them.

yields commented 11 years ago

@testower wow, thanks for that, i'm never going to use parse.com.

thomaschaaf commented 11 years ago

Please explain what parse.com is.

testower commented 11 years ago

Parse.com is a Backend-as-a-Service for mobile and web apps. You can also deploy node.js-type code to its "cloud" and expose it to your clients.

thomaschaaf commented 11 years ago

Would it be possible to make this more generic? I would think a flag "usehttps" and have that set to true by default and parse users would simply set that to false?

testower commented 11 years ago

Yeah, I like that. It would require an injection of the alternative request function though.

Edit:

thomaschaaf commented 11 years ago

Acutally that will not work as: "All your requests must be made via https. Requests which will be made in another way will fail. This is for security reasons of the submitted data." - https://www.paymill.com/de-de/dokumentation/referenz/api-referenz/#document-authentication

testower commented 11 years ago

Parse.Cloud.httpRequest will make https request if "https" is given in request url, as opposed to "http". The solution is tested and works against paymill.

testower commented 11 years ago

Sorry, I understood what you meant now by "setting a flag" now, and simply use a normal http request if "usehttps" is set to false. That will not work with Parse either, as all http requests, https or not, must be made with Parse's internal method.

thomaschaaf commented 11 years ago

What now? I don't think I want to merge a cloud provider specific implementation. Next thing you know there will be 100 if statements at the top.

testower commented 11 years ago

For now I could just post the Parse-specific solution on my own github, for anyone that's interested. I completely understand that you don't want to merge this :-)