Hello,
I’m fairly new to Wix and Corvid, while i took a look at the documentation before asking i can’t seem to find out how to pass my parameters to an external API (Mollie).
The fetch request reaches the target webhook and the API key is successfully passed with the headers of the request, however any parameters that i try to pass with the body or anywhere else fail, and that’s where i could use some help. They have to be passed as a string, I’m posting my Backend functions and a link to the Mollie API reference for the hook that i’m trying to reach. Mollie has a node.js library that could be used but is not yet supported in Wix. Thanks in advance.
https://docs.mollie.com/reference/v2/payments-api/create-payment#example
import {fetch} from 'wix-fetch';
import {getJSON} from 'wix-fetch';
import wixData from 'wix-data';export function serialize (){serialize = function (obj) {
var str = [];
for (var p in obj)
if (obj.hasOwnProperty (p)) {
str.push(encodeURIComponent(p) + encodeURIComponent(obj[p]));
}
return str.join ("&");
};
}
export function newMolliePayment(){
const payment = ({
amount: {
currency: 'EUR',
value: '10.00',
},
description: 'Order #12345',
redirectUrl: 'https://webshop.example.org/order/12345/',
webhookUrl: 'https://webshop.example.org/payments/webhook/',
metadata: {
order_id: '12345',
},
}); return fetch("https://api.mollie.com/v2/payments&", {method: 'post',
headers: { 'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer test_key',
body: JSON.stringify(payment),
}})
.then (httpResponse => httpResponse.json());
}