Authorize + Capture
All card not present transaction require a one time payment token before we can process your payment request. It is recommended that you use the Hosted Iframe to generate the payment token. Tokens are generated using "Tokens" endpoint.
Once a token has been generated you process your payment request.
The Hosted Iframe requires a "PUBLIC-API-KEY". You will need to use your "PRIVATE-API-KEY" for all other actions.
Functions Overview:
• Hosted Iframe
• Authorize
• Capture
Continue reading to understand the the commands and responses for each function.
<!-- Add this element anywhere you want in the Body -->
<div id="ecrypt-iframe-wrapper"></div>
<!-- Place this right before the closing body tag -->
<script type="text/javascript">
var ecryptConfig = {
appearance: {
bodyBackground: "#1A1A1A",
formBackground: "#1A1A1A",
inputColor: "#5C5C5C",
inputBorderColor: "#1A1A1A",
inputBackground: "#282828",
errorColor: "#d90429",
successColor: "#2BBD53",
focusColor: "#FDD745",
hidealerts: false,
googleFontFamily: "'Roboto', sans-serif",
},
theme: "long-form-border-light",
publicKey: "[PLACE YOUR PUBLIC KEY HERE]",
}
</script>
<script src="https://iframe.ecrypt.com/js/ecrypt_iframe.js"></script>// USE THIS LISTNER TO GRAB THE RESPOSNSE FROM THE SERVER
window.addEventListener('message', (event) => {
if(event.origin !== window.location.origin ) {
var msg = event.data;
//grab success message
if(msg.includes('token')) {
console.log(JSON.parse(msg));
// THIS WILL CONSOLE LOG THE RESPOSNSE FROM THE SERVER. RESPONSE EXAMPLE:
//{"token":"ee104649-7b21-4d38-b3d5-78eb55d08639","metadata":{"credit_card_number":"4***********1111","credit_card_network":"visa"},"request_id":"0HMJB7MC4MPOF0000000C"}
}
}
});curl --location --request POST 'https://api.preferredpayments.com/v1/transactions/authorize' \
--header 'X-API-Key: PRIVATE-API-KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"payment": {
"token": "00000000-0000-0000-0000-000000000000"
},
"amount": {
"currency": "USD",
"value": 1.00
}
}'{
"transaction_id": "1234567890",
"auth_code": "123456",
"response_code": "APPROVED",
"response_text": "SUCCESS",
"latency": 1690,
"avs": {
"code": "N",
"text": "No address or ZIP match only"
},
"cvv": {
"code": "M",
"text": "CVV2/CVC2 match"
},
"request_id": "ABCD1234567890"
}{
"transaction_id": "1234567890",
"auth_code": "",
"response_code": "DECLINED",
"response_text": "DECLINED",
"avs": {
"code": "N",
"text": "No address or ZIP match only"
},
"cvv": {
"code": "M",
"text": "CVV2/CVC2 match"
},
"request_id": "ABCD1234567890"
}curl --location --request POST 'https://api.preferredpayments.com/v1/transactions/capture' \
--header 'X-API-Key: PRIVATE-API-KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"transaction_id":"1234567890",
"amount":1.00
}'{
"transaction_id": "1234567890",
"auth_code": "123456",
"response_code": "APPROVED",
"response_text": "SUCCESS",
"request_id": "ABCD1234567890"
}Updated 12 months ago