From ebf61c187fdd2614cea048c4ad0ed7c6246cb0fb Mon Sep 17 00:00:00 2001 From: kira <164851225@qq.com> Date: Fri, 14 Sep 2018 19:48:46 +0800 Subject: [PATCH] add rpay --- .../core/impls/ClientManagerImpl.java | 14 +- .../resources/application-rpay.properties | 6 +- src/main/ui/static/images/rpay_horizental.png | Bin 0 -> 8157 bytes .../templates/partner_bankaccounts.html | 1 + .../ui/static/templates/payment/payment.css | 7 + .../static/templates/payment/v1/payment.css | 4 + .../templates/rpay/v1/bill_retail_jsapi.js | 79 +++ .../static/templates/rpay/v1/gateway_jsapi.js | 139 ++++++ .../ui/static/templates/rpay/v1/payment.js | 465 ++++++++++++++++++ .../static/templates/rpay/v1/retail_jsapi.js | 97 ++++ 10 files changed, 804 insertions(+), 8 deletions(-) create mode 100644 src/main/ui/static/images/rpay_horizental.png create mode 100644 src/main/ui/static/templates/rpay/v1/bill_retail_jsapi.js create mode 100644 src/main/ui/static/templates/rpay/v1/gateway_jsapi.js create mode 100644 src/main/ui/static/templates/rpay/v1/payment.js create mode 100644 src/main/ui/static/templates/rpay/v1/retail_jsapi.js diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index a9aa50311..8747d6b01 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -1,15 +1,13 @@ package au.com.royalpay.payment.manage.merchants.core.impls; -import au.com.royalpay.payment.channels.jd.runtime.RpayApi; -import au.com.royalpay.payment.channels.jd.runtime.beans.SubRpayMerchantInfo; +import au.com.royalpay.payment.channels.rpay.runtime.RpayApi; +import au.com.royalpay.payment.channels.rpay.runtime.beans.SubRpayMerchantInfo; import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment; import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient; import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo; - import au.com.royalpay.payment.core.PaymentChannelApi; -import au.com.royalpay.payment.core.beans.PayChannel; import au.com.royalpay.payment.core.exceptions.EmailException; import au.com.royalpay.payment.core.exceptions.InvalidShortIdException; import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver; @@ -158,8 +156,14 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URISyntaxException; import java.net.URL; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashSet; import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.TimeZone; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.zip.ZipEntry; diff --git a/src/main/resources/application-rpay.properties b/src/main/resources/application-rpay.properties index e39b8bf00..1b361a41f 100644 --- a/src/main/resources/application-rpay.properties +++ b/src/main/resources/application-rpay.properties @@ -1,3 +1,3 @@ -app.privateKey=MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKikZJwvKZ3dj5QsRy6xN/cPinAZa3leg8X40YzGrMEYWc2nmZY/EczYPq/kUp1uL2uikweDO35fuVpA4rALmJwXhHzsZyhVk4lEjHaqH8rNpVpmrwKP9rMmbFD23Mfvvt+BkKWan2T2dAMbSdjPY0+DTS4sN1ZrqzycRFxKFpohAgMBAAECgYBoO0Mb7WJxehFV6ZANYedPQkG0S2HL4AjeAY2yztDTf/NxUpdw74ZW74i/OgV93C5e/lqVmBzbXNq418XEPUaSohOqbcv+QRlEdlTAtn82aAUp/c9oSogPiHWs2VKiGoutejwVXQ6V9BAGMMegLwVphUu9dgrPC4dnfGO11fvLiQJBANt0VPmdqdG52rNVllKhF5+d+dIamOOQewWZf7HnkW0uYt9kWSbZCYyey4nP7NlONL7NEdUxn9exg/DYzegB99sCQQDEudve+jV2Ay6gbOS+ylH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74ZW74i/OgV93C5e/lqVmBzbXNq418XEPUaSohOqbcv+QRlEdlTAtn82aAUp/c9oSogPiHWs2VKiGoutejwVXQ6V9BAGMMegLwVphUu9dgrPC4dnfGO11fvLiQJBANt0VPmdqdG52rNVllKhF5+d+dIamOOQewWZf7HnkW0uYt9kWSbZCYyey4nP7NlONL7NEdUxn9exg/DYzegB99sCQQDEudve+jV2Ay6gbOS+ylHoCxSroF6jlkBQ0q7LIsWAAzIVLOuo5skC+wJmHzKXDoQBLXcFerP/T/iUSzisKqSzAkEAmjRVXY02/gLttWQnm+pMckGMgOFlm0oz18xzmSwR2TlmCnk12AFcH26ZsT3kvRGiKIxqwnb7TZIUF1IQ5b00TwJALD7xKNF1vLkyf3p+aDrw+ROk7oT/RCPDC2qXTbDgYs5VMVYNGsvtYfI6s+VIZ5koL2ueXWkfmsjNy+yvLmnY6QJADV9xlAa1+mWN2TfzAugd3L0fNLqPJPHBKQS5/bBKcoZlwfXwByrcCceKaCntJRZ056eQ7IeqkJfxjkEo/kgaRg== +app.rpay.rpay-public-key=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw4QOJdajtax5/EQ/Tm65tLnaRB3LXrac3jhdOGp+PsQL1tQyRnvKfWDD5qJ2VZ+rSsLUGg//7ubHtuQHFgH8N9BfSDf9PSZLXsgdA0ikAj6/0P+D7VsSAGsw97plXElh3jx1OvKIW46ZFtPgXuotTx1B+4plafhv5JMHMcVYwOGghaDH9Yoh4vaVU6JNw7IWATaycrmAwEns5VVN6uvz2aTYsH8Rb4j2PA8oKW+7ckcF+sCTNJhFK29iHcvLwzGTXrUTaOfk3ZXNhB9g1ou9aolDszUKvj1R7gSoyoq05w6ICno/d0Fu6Oj0H1N36k7OjUt3wX2lm40yu6ymEV6U0QIDAQAB +app.rpay.app-id=ae8c8000-d774-42ad-8008-810b55c96aa9 \ No newline at end of file diff --git a/src/main/ui/static/images/rpay_horizental.png b/src/main/ui/static/images/rpay_horizental.png new file mode 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W>-D1v*N(!8ryi*LF3|k7+&rzl9%`h2g&?Z_!s|net|YxZFW_cks)do-2iEYbEvc z%B<_1>#2B;R}M=th~~y-otVaS(SS>o!4E^6Re=nYZRr7Z1@ruTTF#5rdrUGD(D%Ssu~2e z5RefK2T)vhEL7gtDm0=*QJD31g;sS<;C}xiYGc*q9gW`+5jd#IwN56{AW#$p;tX%{ znt^$(CS@eaBCRN;cEZs(Dq#tRs{R+<<&FXG0kk%TaU2s20tNwB1Q_S?=!c3@l#%Ru z<0Qh77_j~^2KvWlf6j6g;=PQ}WG6SV27z9V0M2$g1jm+qRll0@sy=P>C?lgNo!P&- z@uy=p_y>UbSl0n)vDFK3XY?M2k=P(mBn0C2EhtHE5xrWIIjFQpGZYD>&SJ`5QA+K2 z>>iMDR5xxMl;fVAlDl6hi_!#xfI%P&0#Y~rM6&G@vLtzo;@5cooQiT8SJq>cIOBN? z*3d1&800lRl%!hSv!~Qg*xTb%H`xpV6@!4YIz((|t*UmVh1Aix6&1=_QBqCce`!Ar zv5i%!4W1$FjR;`JPk*cqc?^ccF8cMu29=r`y`y9G3oSWic`M58WAAGtBottvTDw$3 zXb>n%1h5ff5K+rx=x)^o6!7UN`WFaTXKax#dGJnZi9AFK>J?FrNrAD1Svs{IVvlOtJPOHE9i*K_IdSz~zM`{hA!5%n@wZRrJ@)i`CiPAc>yF;oVDf*|0m?yzMyIAqxkt3wV%_xe=Y z)^a!sgAt_T?IMSm%(I*W<8mbT_UQ6glsgVvK^s}?g1)CwNXaty6P_>-NPu3+{GB$$S`L7+Sl;EmX;{U@T>OjB6zRjMkg z#u?aR`#+7%=50l<)XG_JQtkMS(3t-HOp0-kQS|3!3M>r*Ov>T4I check + \ No newline at end of file diff --git a/src/main/ui/static/templates/payment/payment.css b/src/main/ui/static/templates/payment/payment.css index e32c60cf9..9d13e26d0 100644 --- a/src/main/ui/static/templates/payment/payment.css +++ b/src/main/ui/static/templates/payment/payment.css @@ -433,6 +433,9 @@ input.value:focus { .keyboard-grids .key.paynow.alipay { background: #108ee9; } +.keyboard-grids .key.paynow.rpay { + background: #FF2D55; +} .alipay { color: #108ee9; @@ -442,6 +445,10 @@ input.value:focus { color: #09bb07; } +.rpay { + color: #FF2D55; +} + .keyboard-grids .key.paynow > .label { display: block; position: absolute; diff --git a/src/main/ui/static/templates/payment/v1/payment.css b/src/main/ui/static/templates/payment/v1/payment.css index c61863f70..5c535ec04 100644 --- a/src/main/ui/static/templates/payment/v1/payment.css +++ b/src/main/ui/static/templates/payment/v1/payment.css @@ -366,6 +366,10 @@ input.value:focus { background-color: #108ee9; } +.button_sp_area.alipay .paynow { + background-color: #FF2D55; +} + .button_sp_area .remark-btn { width: 35%; background: #20C1ED diff --git a/src/main/ui/static/templates/rpay/v1/bill_retail_jsapi.js b/src/main/ui/static/templates/rpay/v1/bill_retail_jsapi.js new file mode 100644 index 000000000..7e7290d52 --- /dev/null +++ b/src/main/ui/static/templates/rpay/v1/bill_retail_jsapi.js @@ -0,0 +1,79 @@ +/** + * Created by yixian on 2016-07-15. + */ +$(document).ready(function () { + 'use strict'; + decode(); + function decode() { + var redirect = window.redirect; + while(redirect.indexOf('://')<0){ + redirect = decodeURIComponent(redirect); + if(redirect==window.redirect){ + break; + } + window.redirect = redirect; + } + } + var dataCache = {paying: false}; + $('#key_P').bind('touchstart', startPay); + function startPay() { + $('#wdiv').show(); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + + $.ajax({ + url: '/api/v1.0/alipay/partners/' + window.client_moniker + '/orders/'+window.order_id+'/order_params', + method: 'GET', + dataType: 'json', + success: function (pay) { + if (pay.direct_paid) { + location.href = window.redirect; + return; + } + if (window.AlipayJSBridge) { + callPayment(); + } else { + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', callPayment, false); + } + + function callPayment() { + try { + AlipayJSBridge.call('tradePay', { + tradeNO: pay.trade_no + }, function (res) { + dataCache.paying = false; + if (res.resultCode == '9000') { + AlipayJSBridge.call('startApp', { + appId: '20000056', + param: { + actionType: 'showSuccPage', + payResult: res.result + }, + closeCurrentApp: false + }); + location.href = window.redirect; + } else { + alert(res.memo); + } + $('#wdiv').hide(); + }) + } catch (err) { + alert(err); + $('#wdiv').hide(); + } + } + }, + error: function (jqXhr) { + alert(jqXhr.responseJSON.message); + $('#wdiv').hide(); + dataCache.paying = false; + } + }) + + + } + +}); \ No newline at end of file diff --git a/src/main/ui/static/templates/rpay/v1/gateway_jsapi.js b/src/main/ui/static/templates/rpay/v1/gateway_jsapi.js new file mode 100644 index 000000000..9f876394f --- /dev/null +++ b/src/main/ui/static/templates/rpay/v1/gateway_jsapi.js @@ -0,0 +1,139 @@ +/** + * Created by yixian on 2016-07-15. + */ +$(document).ready(function () { + 'use strict'; + decode(); + + function decode() { + if (window.client_moniker == 'PINE') { + alert('debug:origin redirect:' + window.redirect); + } + var redirect = window.redirect; + while (redirect.indexOf('://') < 0) { + redirect = decodeURIComponent(redirect); + if (redirect == window.redirect) { + break; + } + window.redirect = redirect; + } + + } + + var dataCache = {paying: false}; + $('#key_P').bind('touchstart', startPay); + if (window.tradeNo) { + + if (window.AlipayJSBridge) { + callPayment(window.tradeNo); + } else { + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', function () { + callPayment(window.tradeNo); + }, false); + } + } + + function startPay() { + $('#wdiv').show(); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + + $.ajax({ + url: './preorder', + method: 'GET', + dataType: 'json', + success: function (pay) { + if (pay.direct_paid) { + location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true'; + return; + } + if (window.AlipayJSBridge) { + callPayment(pay.trade_no); + } else { + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', function () { + callPayment(pay.trade_no); + }, false); + } + + }, + error: function (jqXhr) { + alert(jqXhr.responseJSON.message); + $('#wdiv').hide(); + dataCache.paying = false; + } + }) + + + } + + function callPayment(tradeNo) { + try { + if (window.client_moniker == 'PINE') { + alert('debug:trade no=' + tradeNo) + } + AlipayJSBridge.call('tradePay', { + tradeNO: tradeNo + }, function (res) { + dataCache.paying = false; + if (res.resultCode == '9000') { + AlipayJSBridge.call('startApp', { + appId: '20000056', + param: { + actionType: 'showSuccPage', + payResult: res.result + }, + closeCurrentApp: false + }); + startCheckOrder(window.client_moniker, window.merchant_orderid); + } else { + alert(res.memo); + if (window.tradeNo) { + location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=false'; + } + } + $('#wdiv').hide(); + }) + } catch (err) { + alert(err); + $('#wdiv').hide(); + } + } + + function startCheckOrder(clientMoniker, merchantOrderId) { + function checkOrderStd() { + $.ajax({ + url: '/api/v1.0/payment/clients/' + clientMoniker + '/orders/' + merchantOrderId + '/status', + method: 'GET', + dataType: 'json', + success: function (res) { + if (res.paid) { + location.href = window.redirect + (window.redirect.indexOf('?') < 0 ? '?' : '&') + 'success=true'; + } else { + setTimeout(checkOrderStd, 500); + } + } + }) + } + + checkOrderStd(); + } + + function waitForPaymentSuccess(orderId) { + var sock = new SockJS('/register'); + var client = Stomp.over(sock); + client.connect({}, function () { + client.subscribe('/app/payment/orders/' + orderId, function (msg) { + var json = JSON.parse(msg.body); + var concat = '?'; + if (window.redirect.indexOf('?') > 0) { + concat = '&'; + } + location.href = window.redirect + concat + 'time=' + json.time + '&nonce_str=' + json.nonce_str + '&sign=' + json.sign + '&success=true'; + }) + }) + } +}); \ No newline at end of file diff --git a/src/main/ui/static/templates/rpay/v1/payment.js b/src/main/ui/static/templates/rpay/v1/payment.js new file mode 100644 index 000000000..0f34739ab --- /dev/null +++ b/src/main/ui/static/templates/rpay/v1/payment.js @@ -0,0 +1,465 @@ +/** + * Created by yixian on 2017-05-08 + */ +$(function () { + 'use strict'; + // document.querySelector('body').addEventListener('touchmove', function (e) { + // if (!document.querySelector('.coupons').contains(e.target)) { + // e.preventDefault(); + // } + // }) + var dataCache = {price: '0', coupons: [], coupon_groups: {}}; + var exchangeRate = parseFloat(window.exchange_rate); + + // if (window.AlipayJSBridge) { + // AlipayJSBridge.call('hideOptionMenu'); + // } else { + // document.addEventListener('AlipayJSBridgeReady', function () { + // AlipayJSBridge.call('hideOptionMenu'); + // }, false); + // } + dataCache.paying = false; + var ctrl = {}; + + $('.ff.key').bind('touchstart', function () { + if (dataCache.paying) { + return; + } + var char = $(this).attr('data-char'); + appendChar(char); + }); + + $('.coupons .use-check').click(function () { + if ($(this).hasClass('disabled')) { + return; + } + var couponId = $(this).attr('data-coupon-id'); + var couponGroup = $(this).attr('data-coupon-group'); + if (couponGroup) { + var prevCouponId = dataCache.coupon_groups[couponGroup]; + if (prevCouponId) { + var prevIdx = dataCache.coupons.indexOf(prevCouponId); + if (prevIdx >= 0) { + dataCache.coupons.splice(prevIdx, 1); + } + if (prevCouponId != couponId) { + $('.coupons .use-check[data-coupon-id="' + prevCouponId + '"]').removeClass('checked').addClass('unchecked'); + dataCache.coupon_groups[couponGroup] = couponId; + } else { + dataCache.coupon_groups[couponGroup] = null; + } + } else { + dataCache.coupon_groups[couponGroup] = couponId; + } + + } + + if ($(this).is('.checked')) { + $(this).removeClass('checked').addClass('unchecked'); + } else { + $(this).removeClass('unchecked').addClass('checked'); + } + var checked = $(this).is('.checked'); + if (checked) { + dataCache.coupons.push(couponId); + updatePrice(); + } else { + var idx = dataCache.coupons.indexOf(couponId); + dataCache.coupons.splice(idx, 1); + updatePrice(); + } + }); + + $('#key_B').bind('touchstart', function () { + backspace(); + }); + + function updatePoundage(price) { + if (window.extensions.indexOf('customerrate') >= 0 && window.rateValue != null) { + if (window.use_customised_rate) { + var rate = new Decimal(100).plus(window.rateValue).div(100); + var poundageValue = new Decimal(dataCache.price).mul(rate).sub(dataCache.price); + } else { + var rateRemain = new Decimal(100).sub(window.rateValue).div(100); + poundageValue = new Decimal(dataCache.price).div(rateRemain).sub(dataCache.price); + } + dataCache.poundageValue = poundageValue.toFixed(2, Decimal.ROUND_HALF_UP); + return poundageValue.plus(price).toFixed(2, Decimal.ROUND_HALF_UP); + } + return price; + } + + function updatePrice() { + $('#audVal').html(dataCache.price); + var realPrice = dataCache.price; + $('#audValReal').html(realPrice); + var surchargeData = calculateSurcharge(realPrice); + + var price = surchargeData.newPrice || realPrice; + var priceBeforeDiscount = price; + dataCache.discounts = []; + dataCache.tax = surchargeData.tax; + dataCache.surcharge = surchargeData.surcharge; + + $(window.coupons).each(function () { + price = this.handleDiscount(price, dataCache.price, dataCache.discounts, dataCache.coupons); + }); + dataCache.customSurcharge = new Decimal(price).sub(realPrice).toFixed(2,Decimal.ROUND_HALF_UP); + dataCache.finalPrice = new Decimal(price).toFixed(2, Decimal.ROUND_FLOOR); + var rate = 'CNY' == window.currency ? 1 : exchangeRate; + var cnyVal = Decimal.mul(price, rate).toFixed(2, Decimal.ROUND_HALF_UP); + $('#cnyVal').html(cnyVal); + dataCache.currencyPrice = 'CNY' == window.currency ? Decimal.div(priceBeforeDiscount, exchangeRate).toFixed(2, Decimal.ROUND_FLOOR) : priceBeforeDiscount; + } + + function updatePoundageStatus() { + $(window.coupons).each(function () { + var coupon = this; + var couponId = coupon.couponId(); + if (coupon.isEnable(dataCache.currencyPrice || 0)) { + $('.coupons .use-check[data-coupon-id=' + couponId + ']').removeClass('disabled'); + } else { + var dom = $('.coupons .use-check[data-coupon-id=' + couponId + ']').addClass('disabled'); + var couponGroup = dom.attr('data-coupon-group'); + if (couponGroup) { + if (dataCache.coupon_groups[couponGroup] == couponId) { + dataCache.coupon_groups[couponGroup] = null; + } + } + var idx = dataCache.coupons.indexOf(couponId); + if (idx >= 0) { + dataCache.coupons.splice(idx, 1); + } + dom.removeClass('checked').addClass('unchecked'); + } + }) + } + + updatePoundageStatus(); + + function backspace() { + dataCache.price = dataCache.price.substring(0, dataCache.price.length - 1); + if (dataCache.price.length == 0) { + dataCache.price = '0'; + } + updatePrice(); + updatePoundageStatus(); + } + + function appendChar(char) { + var pointLocation = dataCache.price.indexOf('.'); + if (pointLocation >= 0 || char == '.' || dataCache.price.length < 5) { + if (pointLocation >= 0 && char == '.') { + return; + } + if (pointLocation >= 0 && pointLocation <= dataCache.price.length - 3) { + return; + } + if (dataCache.price == '0' && char != '.') { + dataCache.price = ''; + } + dataCache.price += char; + updatePrice(); + updatePoundageStatus(); + } + } + + $('#coupon-box-toggle').click(function () { + $('.coupons-container').addClass('show'); + }); + $('.coupons-container>.coupons-mask,.coupons-container #close-coupon-box').click(function () { + $(this).parents('.coupons-container').removeClass('show'); + }); + + + $('.remark-btn').click(function () { + var cfg = { + title: '备注 Remark', + template: '', + initialize: function (dialog) { + $('').addClass('remark-input').attr('name', 'remark').val(dataCache.remark || '').appendTo($('.weui_dialog_bd', dialog)); + }, + confirm: function (dialog, chosen) { + if (chosen) { + var remark = $('textarea[name="remark"]', dialog).val(); + if (remark) { + $('#remark-box').text('备注:' + remark).show() + } else { + $('#remark-box').text('').hide(); + } + dataCache.remark = remark; + } + + } + }; + showWeuiDialog(cfg); + }); + + $('.paydetail').click(function () { + var config = { + title: 'Payment Detail', + template: '', + initialize: function (dialog) { + var bd = $('.weui_dialog_bd', dialog); + var currencySymbol = window.currency == 'AUD' ? '$' : '¥'; + $('

').html('Input Price 输入金额:' + currencySymbol + dataCache.price).appendTo(bd); + if (parseFloat(dataCache.customSurcharge) > 0) { + $('

').html('Surcharge 手续费(' + window.rateValue + '%):+' + currencySymbol + dataCache.customSurcharge).appendTo(bd); + } + $(dataCache.discounts).each(function () { + $('

').html(this.title + ':-' + currencySymbol + this.amount).appendTo(bd); + }); + $('

').addClass('final').html('Final 支付金额:' + currencySymbol + (dataCache.finalPrice || 0)).appendTo(bd); + } + }; + showWeuiDialog(config); + }); + + $('#key_P').click(function () { + if (window.requireRemark) { + if (!dataCache.remark) { + var config = { + title: '请先输入备注', + template: '' + }; + showWeuiDialog(config); + } + + } + }); + + $('#key_P').bind('touchstart', function () { + if (window.requireRemark) { + if (!dataCache.remark) { + return; + } + } + $('#key_P').addClass('hidden'); + $('#key_Loading').removeClass('hidden'); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + var data = {price: dataCache.price + '', original_number: true, currency: window.currency}; + if (dataCache.remark) { + data.description = dataCache.remark; + } + if (window.extensions.indexOf('preauthorize') >= 0) { + data.preauthorize = true; + } + if (window.extensions.indexOf('qrcodemode') >= 0) { + data.qrmode = true; + } + if (window.extensions.indexOf('customerrate') >= 0) { + data.customerrate = true; + } + data.coupons = dataCache.coupons; + data.qrcodeVersion = window.qrcodeVersion; + + dataCache.remark = ''; + $.ajax({ + url: '/api/v1.0/rpay/partners/' + window.client_moniker + '/orders', + method: 'POST', + data: JSON.stringify(data), + contentType: 'application/json', + dataType: 'json', + success: function (resp) { + pay(resp); + if (resp.direct_paid) { + location.href = '/api/v1.0/rpay/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'; + return; + } + // if (window.AlipayJSBridge) { + // callPayment(); + // } else { + // // 如果没有注入则监听注入的事件 + // document.addEventListener('AlipayJSBridgeReady', callPayment, false); + // } + // + // function callPayment() { + // try { + // AlipayJSBridge.call('tradePay', { + // tradeNO: pay.trade_no + // }, function (res) { + // dataCache.paying = false; + // if (res.resultCode == '9000') { + // AlipayJSBridge.call('startApp', { + // appId: '20000056', + // param: { + // actionType: 'showSuccPage', + // payResult: res.result + // }, + // closeCurrentApp: false + // }); + // startCheckOrder(pay.order_id, '/api/v1.0/alipay/partners/' + window.client_moniker + '/orders/' + pay.order_id + '/result'); + // } else if (res.resultCode == '6001') { + // //do nothing + // } else { + // if (res.memo) { + // weuiAlert(res.memo); + // } + // } + // $('#key_P').removeClass('hidden'); + // $('#key_Loading').addClass('hidden'); + // }) + // } catch (err) { + // weuiAlert(err) + // } + // } + }, + error: function (jqXhr) { + weuiAlert(jqXhr.responseJSON.message); + $('#key_P').removeClass('hidden'); + $('#key_Loading').addClass('hidden'); + dataCache.paying = false; + } + }) + }); + + function startCheckOrder(orderId, url) { + function checkOrderStd() { + $.ajax({ + url: '/api/v1.0/payment/orders/' + orderId + '/status', + method: 'GET', + dataType: 'json', + success: function (res) { + if (res.paid) { + location.href = url; + } else { + setTimeout(checkOrderStd, 500); + } + } + }) + } + + checkOrderStd(); + } + + function weuiAlert(msg) { + var config = { + template: msg + }; + showWeuiDialog(config); + } + + function showWeuiDialog(config) { + if (config.templateUrl) { + $.ajax({ + url: config.templateUrl, + dataType: 'html', + success: function (template) { + buildDialog(template); + } + }); + } else { + buildDialog(config.template); + } + + + function buildDialog(template) { + var defaultConfig = {backdrop: true}; + config = $.extend({}, defaultConfig, config); + var dialog = $("
", {class: 'weui_dialog_confirm'}); + var mask = $('
', {class: 'weui_mask'}).appendTo(dialog); + if (config.backdrop) { + mask.click(function () { + dialog.remove(); + if ($.isFunction(config.dismiss)) { + config.dismiss(); + } + }) + } + var dialogBox = $("
", {class: 'weui_dialog'}).appendTo(dialog); + if (config.title) { + $('
', {class: 'weui_dialog_hd'}).append($('', {class: 'weui_dialog_title'}).html(config.title)).appendTo(dialogBox); + } + var dialogBody = $("
", {class: 'weui_dialog_bd'}).appendTo(dialogBox); + if (template) { + dialogBody.append(template); + } + if ($.isFunction(config.initialize)) { + config.initialize(dialog); + } + var ft = $('
').appendTo(dialogBox); + if ($.isFunction(config.confirm)) { + var yes = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #108ee9;color: #fff;' + }).appendTo(ft); + yes.click(function () { + config.confirm(dialog, true); + dialog.remove(); + }); + var no = $('', {class: 'weui_btn_dialog default', text: 'Cancel'}).appendTo(ft); + no.click(function () { + config.confirm(dialog, false); + dialog.remove(); + }) + } else { + var ok = $('', { + class: 'weui_btn_dialog primary', + text: 'OK', + style: 'background: #108ee9;color: #fff;' + }).appendTo(ft); + ok.click(function () { + dialog.remove(); + }) + } + dialog.appendTo($('body')); + } + + } + + + function getUserId(){ + window.RPayPlus.send("getUserId", null, function(data){ + alert(data); + }); + } + + function pay(param){ + var order={ + nonce_str:param.nonce_str, + rpay_order_id:param.rpay_order_id, + mch_order_id:param.mch_order_id + }; + alert("rpay_order_info: nonce_str:"+param.nonce_str+"rpay_order_id:"+param.rpay_order_id+"mch_order_id:"+param.mch_order_id); + window.RPayPlus.send('pay', order, function(data){ + alert('this is callback from native and data='+JSON.stringify(data)); + }); + } + + function back(){ + window.RPayPlus.send("back", null, null); + } + + function jsInvoke(){ + window.RPayPlus.send("jsInvoke", 'Native Test', null); + } + + function createOrder(msg){ + alert('create order information='+JSON.stringify(msg)); + } + + function queryOrder(msg){ + alert('query order information='+JSON.stringify(msg)); + + var order={ + orderId:'00001', + amount:'$10.98', + title:'Balance Top-UP' + }; + setTimeout("window.RPayPlus.onResult("+JSON.stringify(order)+");", 1500); + } + + function registerJs(){ + window.RPayPlus.register('createOrder', function(data){ + createOrder(data); + }); + window.RPayPlus.register('queryOrder', function(data){ + queryOrder(data); + }); + } + getUserId(); +}); \ No newline at end of file diff --git a/src/main/ui/static/templates/rpay/v1/retail_jsapi.js b/src/main/ui/static/templates/rpay/v1/retail_jsapi.js new file mode 100644 index 000000000..6b74c75cf --- /dev/null +++ b/src/main/ui/static/templates/rpay/v1/retail_jsapi.js @@ -0,0 +1,97 @@ +/** + * Created by yixian on 2016-07-15. + */ +$(document).ready(function () { + 'use strict'; + decode(); + function decode() { + var redirect = window.redirect; + while(redirect.indexOf('://')<0){ + redirect = decodeURIComponent(redirect); + if(redirect==window.redirect){ + break; + } + window.redirect = redirect; + } + } + var dataCache = {paying: false}; + $('#key_P').bind('touchstart', startPay); + function startPay() { + $('#wdiv').show(); + if (dataCache.paying) { + return; + } + dataCache.paying = true; + + $.ajax({ + url: '/api/v1.0/alipay/partners/' + window.client_moniker + '/orders/'+window.order_id+'/order_params', + method: 'GET', + dataType: 'json', + success: function (pay) { + if (pay.direct_paid) { + location.href = window.redirect; + return; + } + if (window.AlipayJSBridge) { + callPayment(); + } else { + // 如果没有注入则监听注入的事件 + document.addEventListener('AlipayJSBridgeReady', callPayment, false); + } + + function callPayment() { + try { + AlipayJSBridge.call('tradePay', { + tradeNO: pay.trade_no + }, function (res) { + dataCache.paying = false; + if (res.resultCode == '9000') { + AlipayJSBridge.call('startApp', { + appId: '20000056', + param: { + actionType: 'showSuccPage', + payResult: res.result + }, + closeCurrentApp: false + }); + startCheckOrder(window.order_id, window.redirect); + } else { + alert(res.memo); + } + $('#wdiv').hide(); + }) + } catch (err) { + alert(err); + $('#wdiv').hide(); + } + } + }, + error: function (jqXhr) { + alert(jqXhr.responseJSON.message); + $('#wdiv').hide(); + dataCache.paying = false; + } + }) + + + } + + function startCheckOrder(orderId, url) { + function checkOrderStd() { + $.ajax({ + url: '/api/v1.0/payment/orders/' + orderId + '/status', + method: 'GET', + dataType: 'json', + success: function (res) { + if (res.paid) { + location.href = url; + } else { + setTimeout(checkOrderStd, 500); + } + } + }) + } + + checkOrderStd(); + } +}); \ No newline at end of file