万事达卡托管会话集成问题 [英] mastercard hosted session integration issue
问题描述
我想使用万事达卡支付网关系统在我的网站中集成支付.我使用托管会话方法进行集成.我遵循 万事达卡托管会话一个>
我的 javascript 代码是
<script src="https://network.gateway.mastercard.com/form/version/51/merchant/**<testmerchantID>**/session.js"></script><脚本>if (self === top) {var antiClickjack = document.getElementById("antiClickjack");antiClickjack.parentNode.removeChild(antiClickjack);} 别的 {top.location = self.location;}PaymentSession.configure({字段:{//将托管字段附加到您的信用卡支付页面卡片: {number: "#card-number",securityCode: "#security-code",expiryMonth: "#expiry-month",expiryYear: "#expiry-year"}},会话:'abc456',//在此处指定您的缓解选项frameEmbeddingMitigation: ["javascript"],回调:{初始化:函数(响应){//console.log(response.status);},formSessionUpdate:函数(响应){//处理更新会话的响应如果(响应.状态){if ("ok" == response.status) {console.log("会话更新数据:" + response.session.id);//检查安全码是否由用户提供如果(response.sourceOfFunds.provided.card.securityCode){console.log("提供了安全码.");}//检查用户是否输入了万事达信用卡如果(response.sourceOfFunds.provided.card.scheme == 'MASTERCARD'){console.log("用户输入了万事达信用卡.")}} else if ("fields_in_error" == response.status) {console.log("会话更新失败,字段错误.");如果(response.errors.cardNumber){console.log("卡号无效或丢失.");}如果(response.errors.expiryYear){console.log("到期年份无效或丢失.");}如果(response.errors.expiryMonth){console.log("到期月份无效或丢失.");}如果(响应.错误.安全代码){console.log("安全码无效.");}} else if ("request_timeout" == response.status) {console.log("会话更新失败,请求超时:" + response.errors.message);} else if ("system_error" == response.status) {console.log("会话更新失败,系统错误:" + response.errors.message);}} 别的 {console.log("会话更新失败:" + response);}}},相互作用: {显示控制:{formatCard: "EMBOSSED",invalidFieldCharacters: "拒绝"}},命令: {金额:10.00,货币:AED",编号:123}});功能支付(){//使用来自托管字段的输入更新会话PaymentSession.updateSessionFromForm('card');}
我在配置选项中使用了 session:'dummy data' 选项,因为我需要识别每个事务.它给了我一个错误
会话更新失败,系统错误:找不到表单会话或已过期.
当我评论这些行时,我在响应中得到了库生成的 sessionID.我很困惑如何识别每笔交易.请帮助我
我遇到了同样的问题,我通过确保所有表单字段(卡号、ccv、到期月份、到期年份和持卡人姓名)都有一个 readonly
属性.
<输入类型=文本"id=卡号"类=输入字段"标题=卡号"aria-label="输入您的卡号";值="tabindex=1"只读=只读"><div class="form-group"><label>到期月份:</label><输入类型=文本"id="到期月";类=输入字段"标题=到期月份"aria-label=两位数的到期月";值="tabindex=2"只读=只读">
<div class="form-group"><label>到期年份:</label><输入类型=文本"id=到期年"类=输入字段"标题=到期年份"aria-label=两位数的到期年份";值="tabindex=3"只读=只读">
<div class="form-group"><label>安全代码:</label><输入类型=文本"id=安全代码"类=输入字段"标题=安全代码"aria-label =三位数字 CCV 安全代码";值="tabindex=4";只读=只读">
<div class="form-group"><label>持卡人姓名:</label><输入类型=文本"id="持卡人姓名"类=输入字段"标题=持卡人姓名"aria-label="在卡片上输入姓名";值="tabindex=5"只读=只读"></div>
I want to integrate payment in my website using mastercard payment gateway system. I use the hosted session method for the integration. I follow the mastercard hosted session
My javascript code is
<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>
I have used option session:'dummy data' inside configuration option since I need to identify each transaction. It gives me an error
Session update failed with system error: Form Session not found or expired.
When I comment these line, I am getting sessionID genereated by the library in the response. I am confused how to identify each transaction.Please help me
I had the same issue and I solved it by ensuring all form fields (card number, ccv, expiry month, expiry year and cardholders name) have a readonly
attribute.
<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>
这篇关于万事达卡托管会话集成问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!