0

这可能吗?

我有一个电子商务网站,它有一个 eWay 支付网关,所以我想使用可以在代码中看到的客户端加密密钥来获取加密的卡详细信息$(".form").attr("data-eway-encrypt-key", "The encryption key is placed here");我想知道这是否可能,因为我想通过加密此处的另一种形式的数据是加密 js 的链接https://secure.ewaypayments.com/scripts/eCrypt.js

4

1 回答 1

0

我做了类似的事情,不确定您在哪里需要问题的帮助,但这是我的代码。我使用“RealCardNumber”作为文本字段,使用“CardNumber”作为隐藏字段,填充加密数据并发送到服务器(卡代码相同)。

   $.getScript("https://secure.ewaypayments.com/scripts/eCrypt.min.js")
       .done(function (script, textStatus) {
           if (eCrypt !== undefined) {
               $('#card-details').show(); // Form details initially hidden
               $('#card-loading').hide(); // Placeholder div shown while loading the eWay script (which should happen pretty quick)
               // Setup the hooks to encrypt the card number once it is submitted
               $(".payment-info-next-step-button")[0].onclick = null; // This is the payment button in my scenario
               $(".payment-info-next-step-button").click(function () {
                   var eWayKey = "<Key goes here>"; // Get from Settings ....
                   try {
                       $('#CardNumber').val(eCrypt.encryptValue($('#RealCardNumber').val(), eWayKey));
                       $('#CardCode').val(eCrypt.encryptValue($('#RealCardCode').val(), eWayKey));
                       // Ready to go .... hook in your normal submit here
                   } catch (e) {
                       alert('Sorry there was a problem with submitting the card details securely');
                       console.log(e);
                   }
               });
           } else {
               $('#card-loading').hide();
               alert('eWay not available - please select a different payment method if available');
           }
       })
       .fail(function (jqxhr, settings, exception) {
           $('#card-loading').hide();
           alert('eWay not available - please select a different payment method if available');
       });
于 2020-08-26T04:01:09.603 回答