I need to send data to a card processing company, but the company api code example uses curl terminal.
this is the code format that the api accepts
curl -X POST -u "login:password" -H "Accept: application/json" -H "X-PJ-Application-Key: YOUR_PRODUCTION_APP_KEY" \
-d "action=CHARGE" \
-d "cardTrack=%B4444333322221111^First/Last^1712980100000?;4444333322221111=1712980100000?" \
-d "amountBase=1.00" \
"https://api.payjunction.com/transactions"
Now I want to know what does that mean in javascript terms.
More or less:
$.ajax({
url: "https://api.payjunction.com/transactions",
type: "POST",
data: {
action: "CHARGE",
cardTrack: "%B4444333322221111^First/Last^1712980100000?;4444333322221111=1712980100000?",
amountBase: 1.00
},
headers: {
"Accept": "application/json",
"X-PJ-Application-Key": "YOUR_PRODUCTION_APP_KEY"
},
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password));
},
dataType: 'json'
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.