Created
January 29, 2019 06:35
-
-
Save AMEYCHAVAN/f9289684d16d52aafb1e41219b88d244 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Demo shop</title> | |
<script src="https://api-test.wirecard.com/engine/hpp/paymentPageLoader.js" type="text/javascript"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-sha256/0.9.0/sha256.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<script> | |
console.log('loaded') | |
</script> | |
<script> | |
console.log('loadeddddd') | |
function processSucceededResult(err) { | |
console.log('processSucceededResulterr:', err); | |
console.log('processSucceededResulterr:', JSON.stringify(err)); | |
} | |
function processErrorResult(err) { | |
console.log('processErrorResulterr:', err); | |
console.log('processErrorResulterr:', JSON.stringify(err)); | |
} | |
function pay() { | |
function getSHA256() { | |
return sha256(request_time_stamp + request_id + merchant_account_id + transaction_type + requested_amount + | |
requested_amount_currency + ip_address + secret_key); | |
} | |
function convertToTens(value) { | |
var number = value.toString(); | |
if (number.length == 1) { | |
return "0" + number; | |
} else { | |
return number; | |
} | |
} | |
function utcTimeStamp() { | |
var date = new Date(); | |
var utcTime = date.getUTCFullYear() + (convertToTens(date.getUTCMonth() + 1)) + (convertToTens(date.getUTCDate())) + | |
convertToTens(date.getUTCHours()) + convertToTens(date.getUTCMinutes()) + convertToTens(date.getUTCSeconds()); | |
return utcTime; | |
} | |
var request_id = "c63b9d39-96qd-1c7b279f6-0he9abebcb18" + utcTimeStamp(); | |
var request_time_stamp = utcTimeStamp(); | |
var merchant_account_id = "51b671b8-17da-4ab6-af90-d86d46d774c9"; | |
var transaction_type = "authorization"; | |
var requested_amount = "39.37"; | |
var requested_amount_currency = "EUR"; | |
var ip_address = "111.125.208.18"; | |
var locale = "EN"; | |
var secret_key = "9dd5042d-79db-4f6b-9b2c-9e8a71696996"; | |
var requestedData = { | |
"request_id": request_id, | |
"request_time_stamp": request_time_stamp, | |
"merchant_account_id": merchant_account_id, | |
"transaction_type": transaction_type, | |
"requested_amount": requested_amount, | |
"requested_amount_currency": requested_amount_currency, | |
"ip_address": ip_address, | |
"locale": locale, | |
"request_signature": getSHA256(), | |
"payment_method": "creditcard" | |
}; | |
var sig = | |
requestedData.request_time_stamp + | |
requestedData.request_id + | |
requestedData.merchant_account_id + | |
requestedData.transaction_type + | |
requestedData.requested_amount + | |
requestedData.requested_amount_currency + | |
secret_key; | |
console.log('sigsig', sig) | |
// WirecardPaymentPage.embeddedPay(requestedData); | |
// WirecardPaymentPage.seamlessPay({ | |
// requestData : requestedData, | |
// onSuccess : processSucceededResult, | |
// onError : processErrorResult, | |
// wrappingDivId : "seamless-target", | |
// }); | |
WirecardPaymentPage.seamlessRenderForm({ | |
requestData: requestedData, | |
wrappingDivId: "seamless-target", | |
onSuccess: processSucceededResult, | |
onError: processErrorResult | |
}); | |
} | |
function submitPaymentForm() { | |
// this.displayStyleLoader = 'block'; | |
WirecardPaymentPage.seamlessSubmitForm({ | |
onSuccess: processSucceededResultSubmitForm, | |
onError: processErrorResultSubmitForm | |
}); | |
} | |
function processSucceededResultSubmitForm(result) { | |
console.log("result:", result) | |
} | |
function processErrorResultSubmitForm(result) { | |
console.log("error:", result) | |
} | |
</script> | |
<input id="wirecard_pay_btn" type="button" onclick="pay()" value="PayNow" /> | |
<div id="seamless-target"></div> | |
<input id="wirecard_pay_btn" type="button" onclick="submitPaymentForm()" value="Submit" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment