I'm trying to implement GMO payment gateway to woocommerce. Here goes the flow: 1. get credit card info from user [checkout page] 2. run a javascript api function call and it will responce by executing another js function defined by me 3. from the new executed js function, I can get the token and some other info 4. Now I need that token in the function of process_payment [woocommerce]
Here is the JS code:
<script type="text/javascript">
function execPurchase(response) {
if (response.resultCode != "000") {
window.alert("購入処理中にエラーが発生しました");
} else {
document.getElementById("token").value = response.tokenObject.token;
document.getElementById("purchaseForm").submit();
}
}
function doPurchase() {
var cardno, expire, securitycode, holdername;
var cardno = document.getElementById("CardNumber").value.replace(/\s/g, '');
var expire = document.getElementById("expireYear").value + document.getElementById("expireMonth").value;
var securitycode = document.getElementById("securityCode").value;
var holdername = document.getElementById("holderName").value;
var tokennumber = document.getElementById("tokenNumber").value;
Multipayment.init(shop_id);
Multipayment.getToken({
cardno : cardno,
expire : expire,
securitycode : securitycode,
holdername : holdername,
tokennumber : tokennumber
}, execPurchase);
}
</script>