万事达卡托管会话集成问题
Posted
技术标签:
【中文标题】万事达卡托管会话集成问题【英文标题】:mastercard hosted session integration issue 【发布时间】:2019-08-16 19:34:48 【问题描述】:我想使用万事达卡支付网关系统在我的网站中集成支付。我使用托管会话方法进行集成。我关注mastercard hosted session
我的javascript代码是
<script src="https://network.gateway.mastercard.com/form/version/51/merchant/
**<testmerchantID>**/session.js"></script>
<script>
if (self === top)
var antiClickjack = document.getElementById("antiClickjack");
antiClickjack.parentNode.removeChild(antiClickjack);
else
top.location = self.location;
PaymentSession.configure(
fields:
// ATTACH HOSTED FIELDS TO YOUR PAYMENT PAGE FOR A CREDIT CARD
card:
number: "#card-number",
securityCode: "#security-code",
expiryMonth: "#expiry-month",
expiryYear: "#expiry-year"
,
session: 'abc456',
//SPECIFY YOUR MITIGATION OPTION HERE
frameEmbeddingMitigation: ["javascript"],
callbacks:
initialized: function(response)
//console.log(response.status);
,
formSessionUpdate: function(response)
// HANDLE RESPONSE FOR UPDATE SESSION
if (response.status)
if ("ok" == response.status)
console.log("Session updated with data: " + response.session.id);
//check if the security code was provided by the user
if (response.sourceOfFunds.provided.card.securityCode)
console.log("Security code was provided.");
//check if the user entered a Mastercard credit card
if (response.sourceOfFunds.provided.card.scheme == 'MASTERCARD')
console.log("The user entered a Mastercard credit card.")
else if ("fields_in_error" == response.status)
console.log("Session update failed with field errors.");
if (response.errors.cardNumber)
console.log("Card number invalid or missing.");
if (response.errors.expiryYear)
console.log("Expiry year invalid or missing.");
if (response.errors.expiryMonth)
console.log("Expiry month invalid or missing.");
if (response.errors.securityCode)
console.log("Security code invalid.");
else if ("request_timeout" == response.status)
console.log("Session update failed with request timeout: " + response.errors.message);
else if ("system_error" == response.status)
console.log("Session update failed with system error: " + response.errors.message);
else
console.log("Session update failed: " + response);
,
interaction:
displayControl:
formatCard: "EMBOSSED",
invalidFieldCharacters: "REJECT"
,
order:
amount: 10.00,
currency: "AED" ,
id:123
);
function pay()
// UPDATE THE SESSION WITH THE INPUT FROM HOSTED FIELDS
PaymentSession.updateSessionFromForm('card');
</script>
我在配置选项中使用了选项 session:'dummy data',因为我需要识别每个事务。它给了我一个错误
Session update failed with system error: Form Session not found or expired.
当我评论这些行时,我得到了库在响应中生成的 sessionID。我很困惑如何识别每笔交易。请帮助我
【问题讨论】:
使用session: 'abc456'
,您正在指定要使用的会话ID,但这只有在您已经有来自先前请求的会话ID时才有意义,并且 出于某种原因,您首先需要明确提供会话 ID。
“我很困惑如何识别每笔交易。” - 你的意思是什么,识别何时、何地、为什么?您已经在发送的数据中包含了特定的订单 ID,还需要什么?
这个有点晚了,但根据我的经验,“表单会话未找到或过期”通常表明用于创建会话/令牌的商家 ID 与制作时使用的商家 ID 之间存在差异对 MC api 服务器的 api 调用。
您对此有什么解决办法吗?
@karanshah ..我已经尝试了一些其他的方法,它的工作原理
【参考方案1】:
我遇到了同样的问题,我通过确保所有表单字段(卡号、ccv、到期月份、到期年份和持卡人姓名)具有readonly
属性来解决它。
<div class="form-group"><label>Card Number:</label>
<input type="text" id="card-number" class="input-field" title="card number" aria-label="enter your card number" value="" tabindex="1" readonly="readonly">
</div>
<div class="form-group"><label>Expiry Month:</label>
<input type="text" id="expiry-month" class="input-field" title="expiry month" aria-label="two digit expiry month" value="" tabindex="2" readonly="readonly">
</div>
<div class="form-group">
<label>Expiry Year:</label>
<input type="text" id="expiry-year" class="input-field" title="expiry year" aria-label="two digit expiry year" value="" tabindex="3" readonly="readonly">
</div>
<div class="form-group">
<label>Security Code: </label>
<input type="text" id="security-code" class="input-field" title="security code" aria-label="three digit CCV security code" value="" tabindex="4" readonly="readonly" >
</div>
<div class="form-group">
<label>Cardholder Name:</label>
<input type="text" id="cardholder-name" class="input-field" title="cardholder name" aria-label="enter name on card" value="" tabindex="5" readonly="readonly"></div>
【讨论】:
你好ovicko,当加载这个js文件时,无法加载 @Credit将<testmerchantID>
替换为实际测试商户ID
谢谢 ovicko,我需要创建任何 testmerchantID 来进行测试吗?以上是关于万事达卡托管会话集成问题的主要内容,如果未能解决你的问题,请参考以下文章