I know this question has been asked before, but none of them have quite matched what I was looking for.
I have some JavaScript which is creating a post request.
var request = new
var method = 'post';
var url = 'https://api.worldpay.com/v1/orders';
var content = {
"paymentMethod":{
"type":"Card",
"name":card_name,
"expiryMonth":card_exp_month,
"expiryYear":card_exp_year,
"cardNumber":card_number,
"cvc":card_cvc,
"issueNumber":"1"
},
"orderType": "ECOM",
"orderDescription": "coolio-beans",
"customerOrderCode" : 123,
"amount": 1337,
"currencyCode": "GBP"
}
request.open(method, url);
request.setRequestHeader("Content-Type", "application/json");
request.setRequestHeader("Authorization", "T_S_73c02fe7-f9f6-4d07-a594-9d1774181890");
request.send(JSON.stringify(content));
console.log(request.responseText);
}
This is just a test account on WorldPay, so it is safe. I'm assuming I have set the headers and content correctly as it does actually sent. I read one post where it said I should install a plugin, Allow-Control-Allow-Origin: *
. This actually works for me. However, it doesn't seem like best practice to have to install plugins. So i tried:
request.setRequsetHeader("Access-Control-Allow-Origin", "*");
But that did not work either.
I understand that this has been answered before, but I cannot seem to find a fix. Any help is greatly appreciated.