我正在开发一个类似市场的应用程序,并使用 Stripe 的 API 进行订阅等。
该应用程序是一个 Web 应用程序,将在移动设备上大量使用,但它不是 native 应用程序 - 它是一个基于浏览器的应用程序。
最终用户需要亲自接受客户的付款,我正在尝试通过刷客户的卡来找到解决方案。然而,我发现的所有技术解决方案(例如 Cardflight 等)都是专门针对 native 应用程序(iOS 或 Android)的。
有人在网络应用程序上听说过或做过这样的事情吗?
最佳答案
如果属实,我也遇到过同样的问题(如我今年早些时候的评论所示)。我想出了如何做到这一点,但它也有缺点(安全性、PCI 等)。首先,我需要一种 JavaScript 方法来触发基于滑动、扫描等的事件。我找到了这个库,https://github.com/CarlRaymond/jquery.cardswipe ,它为您提供与扫描事件相关的 JavaScript 回调(扫描完成、扫描成功和扫描错误)。我特别喜欢的是,您不必专注于表单即可将滑动的数据发送到需要发送的地方,您只需选择表单,无论您在应用程序中的哪个位置,它都会填充该表单形成。作者再次在自述文件中警告可能存在的安全风险。
一旦我有了解析的信用卡扫描数据,我就使用了 stripes jquery. payments 库,它为您提供了验证数据以及使用输入构建您自己的表单的功能。关键是能够实际使用表单输入,因此我可以在表单提交之前将解析数据的值分配给每个输入。 http://stripe.github.io/jquery.payment/example/
Stripe 一直在努力改变这种做法。由于 PCI 问题和其他相关的安全问题,他们不热衷于人们构建自己的表单输入。我最终没有这样做,因为我不想承担额外的 PCI 法规的责任。此外,通过那些基本的 USB 刷卡器(我正在使用的),有人可以从技术上拦截数据。这是我知道如何做到这一点的唯一方法,而且效果很好,如果不是因为安全问题,我仍然会使用它。这是我的一些代码。希望这会有所帮助。
var complete = function(data) {
if (data.type == "generic") {
sweetAlert("Oops...", "Card Type Not Recognized!", "error");
return false;
}
$("#cc-fullname").val(data.firstName + " " + data.lastName);
$("#cc-number").val(data.account);
$("#cc-exp").val(data.expMonth + " / " + data.expYear);
window["stripe_fullname"] = data.firstName + " " + data.lastName;
window["stripe_number"] = data.account;
window["stripe_exp_month"] = data.expMonth;
window["stripe_exp_year"] = data.expYear;
};
var failure = function() {
swal("Oops...", "Something went wrong... Please try again!", "error");
}
/* Success Function
========================================= */
var success = function(event, data) {
Stripe.setPublishableKey("{{ stripe_publishable_key }}");
/* Create Token
======================= */
Stripe.card.createToken({
name: window["stripe_fullname"],
number: window["stripe_number"],
exp_month: window["stripe_exp_month"],
exp_year: window["stripe_exp_year"],
}, stripeResponseHandler);
/* Response Callback
======================== */
function stripeResponseHandler(status, response) {
var $form = $('#payment-card-form');
if (response.error) {
$form.find('.payment-errors').text(response.error.message);
$form.find('button').prop('disabled', false);
} else {
var token = response.id;
$form.append($('<input type="hidden" name="stripeToken" />').val(token));
$form.get(0).submit();
}
}
}
$.cardswipe({
firstLineOnly: true,
success: complete,
parsers: ["visa", "amex", "mastercard", "discover", "generic"],
debug: false
});
$(document).on("success.cardswipe", success).on("failure.cardswipe", failure);
关于web-applications - 有什么方法可以接受来自非 native Web 应用程序的读卡器的信用卡刷卡吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41152985/