woocomerce payment plugin
-
Hello Team,
I am developing a plugin to allow payment through myt money gateway from woocomerce.
First I have to create a payload, then encrypt same before using it in a form.
The merTradeNo will be unique (concatenation of orderId and other fields).
Kindly advise (1) how to set the unique value for merTradeNo (2) how can I retrieve the total cost from Woocomerce cost and set the totalAmount. (3) how will the form appear on the checkout page?
https://snipboard.io/HGB9vN.jpg
`$totalAmount=”0.01″
$appID=””;
$merTradeNo=””;
$paymentType=”S”
$publicKey=””;
$apiKey=””;$payload=array(
“totalPrice”=>$totalAmount,
“currency”=>$merTradeNo,
“notifyURL”=>”https://www.myt.mu”,
“returnURL”=>”https://www.myt.mu”,
“remark”=>”This is a test payment”,
lang=>”en”
);//code to generate signature
$payload=json_encode($payload);
$rsa= new \phpseclib\Crypt\RSA();
$rsa->setHash(‘sha1’);
$rsa->setMGFHash(‘sha1’);
$rsa->setEncryptionMode(RSA::ENCRYPTION_OAEP);
$rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_PKCS1);
$rsa->loadKey($publickey);
$encryptedPayload=base64_encode($rsa->encrypt($payload));
$signaturedata=”appID&merTradeNo=$merTradeNo$merTradeNo&payload=$encryptedPayload&paymentType=$paymentType”;
$sign=base64_encode(hash_hmac(‘sha512’,$signaturedata,$apiKey,true));<form action=”https://gateway.mytmoney.mu/web/payments” method=”post”>
<input type=”hidden” name=”appId” value=”<?php echo $appID; ?>”/>
<input type=”hidden” name=”merTradeNo” value=”<?php echo $merTradeNo; ?>”/>
<input type=”hidden” name=”payload” value=”<?php echo $encryptedPayload; ?>”/>
<input type=”hidden” name=”paymentType” value=”<?php echo $paymentType; ?>”/>
<input type=”hidden” name=”sign” value=”<?php echo $sign; ?>”/>
<p><input type=”submit” value=”Pay By my.t money”/></p>
</form>//code that triggers the callback for single payment (paymentType = S) Is it hardcoded??
<form action=”https://transportation.local/callback_url” method=”post”>
<input type=”hidden” name=”merTradeNo” value=MT001/>
<input type=”hidden” name=”TradeNo” value=”123456″/>
<input type=”hidden” name=”tradeStatus” value=”S”/>
<input type=”hidden” name=”msg” value=”SUCCESS”/>
<input type=”hidden” name=”resultcode” value=”000″/>
<input type=”hidden” name=”sign” value=””/>
</form>Thanks,
Roshan
- The topic ‘woocomerce payment plugin’ is closed to new replies.