Backendless Stripe Integration Issue

After Intializing Backendless, and setting up the webhook on Stripes end (I tested the webhook, it functions fine)

whenever I run this piece of code

async submit(ev) {
ev.preventDefault();
let { token } = await this.props.stripe.createToken({ name: “Name” });
console.log(“TOKEN”, token);
let chargeData = {
token: token.id,
amount: 2
};

Backendless.CustomServices.invoke("Stripe", "charge", [chargeData])
  .then(function(result) {
     var channel = Backendless.Messaging.subscribe("stripe/" + result.id);
     channel.addMessageListener(this.onMessage);
  })
  .catch(function(error) {
    console.log("Error", error);
  });

}
onMessage = message => {
console.log("Message received: ");
};

I keep getting the following Error:
POST: https://api.backendless.com/APP ID/JS KEY/services/Stripe/charge 400 (Bad Request)

Here is the Printed Message:

Error: Service invocation failed: ExceptionClass:“RuntimeException” {Msg:"com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.HashMap out of START_ARRAY token

(I removed the Keys for obvious reasons)

I followed this documentation exactly, here’s proof of the Stripe test webhooks working

Any help would be greatly appreciated :slight_smile:

Hi Shalv

Could you try to replace [chargeData] with chargeData

Backendless.CustomServices.invoke("Stripe", "charge", chargeData)

Regards, Vlad

If I wanted to make a payment to this user in question what would I replace “charge” with?

no, I mean do not wrap "chargeData" parameter into array, just pass it as it is

I know, thats what I did. It works fine which is why I marked it as the solution. I just wanted to know how to payout to a user instead of charging them, but I realised that can only be done through the user setting up a Stripoe account at registration time