更新充值 H5 支付配置
This commit is contained in:
parent
5f5f169768
commit
9d3b43bee6
@ -542,12 +542,10 @@ var default_api = 'https://api.global-interaction.com/';
|
||||
options.country_code || options.countryCode || ''
|
||||
).toUpperCase();
|
||||
var matchedCountries = countries.filter(function (country) {
|
||||
return (
|
||||
String(country.country_code || '').toUpperCase() === countryCode
|
||||
);
|
||||
return countryMatchesCode(country, countryCode);
|
||||
});
|
||||
var globalCountries = countries.filter(function (country) {
|
||||
return String(country.country_code || '').toUpperCase() === 'GLOBAL';
|
||||
return countryMatchesCode(country, 'GLOBAL');
|
||||
});
|
||||
var matchedMethods = collectMifaPayMethods(
|
||||
matchedCountries,
|
||||
@ -569,24 +567,23 @@ var default_api = 'https://api.global-interaction.com/';
|
||||
function collectMifaPayMethods(countries, mifapay, options, fallbackAll) {
|
||||
var methods = [];
|
||||
(countries || []).forEach(function (country) {
|
||||
var countryCode = primaryCountryCode(country);
|
||||
(country.methods || []).forEach(function (method, index) {
|
||||
methods.push(
|
||||
Object.assign({}, method, {
|
||||
method_id: [
|
||||
mifapay.provider_code || 'mifapay',
|
||||
country.country_code,
|
||||
countryCode,
|
||||
method.pay_way,
|
||||
method.pay_type,
|
||||
index,
|
||||
].join(':'),
|
||||
provider_code: mifapay.provider_code || 'mifapay',
|
||||
provider_name: mifapay.provider_name || 'MiFaPay',
|
||||
country_code: country.country_code,
|
||||
country_code: countryCode,
|
||||
country_name: country.country_name,
|
||||
currency_code:
|
||||
fallbackAll ||
|
||||
String(country.country_code || '').toUpperCase() ===
|
||||
'GLOBAL'
|
||||
fallbackAll || countryMatchesCode(country, 'GLOBAL')
|
||||
? options.currency_code || country.currency_code
|
||||
: country.currency_code,
|
||||
usd_to_currency_rate:
|
||||
@ -606,6 +603,49 @@ var default_api = 'https://api.global-interaction.com/';
|
||||
return methods;
|
||||
}
|
||||
|
||||
function primaryCountryCode(country) {
|
||||
country = country || {};
|
||||
var codes = countryCodeAliases(country);
|
||||
return codes[0] || '';
|
||||
}
|
||||
|
||||
function countryMatchesCode(country, code) {
|
||||
code = String(code || '')
|
||||
.trim()
|
||||
.toUpperCase();
|
||||
if (!code) return false;
|
||||
return countryCodeAliases(country).indexOf(code) >= 0;
|
||||
}
|
||||
|
||||
function countryCodeAliases(country) {
|
||||
country = country || {};
|
||||
var rawCodes = []
|
||||
.concat(country.country_code || [])
|
||||
.concat(country.countryCode || [])
|
||||
.concat(country.country_codes || [])
|
||||
.concat(country.countryCodes || []);
|
||||
var codes = [];
|
||||
rawCodes.forEach(function (value) {
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(function (item) {
|
||||
pushCountryCodeAlias(codes, item);
|
||||
});
|
||||
return;
|
||||
}
|
||||
pushCountryCodeAlias(codes, value);
|
||||
});
|
||||
return codes;
|
||||
}
|
||||
|
||||
function pushCountryCodeAlias(codes, value) {
|
||||
value = String(value || '')
|
||||
.trim()
|
||||
.toUpperCase();
|
||||
if (value && codes.indexOf(value) < 0) {
|
||||
codes.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
function firstValue(object, keys) {
|
||||
object = object || {};
|
||||
for (var i = 0; i < keys.length; i += 1) {
|
||||
|
||||
@ -1,173 +1,372 @@
|
||||
{
|
||||
"app": "aslan",
|
||||
"adapter": "aslan-web-pay",
|
||||
"application_id": "1963531459019739137",
|
||||
"sys_origin": "ATYOU",
|
||||
"type": "GOLD",
|
||||
"api": {
|
||||
"prod": "https://api.atuchat.com/",
|
||||
"test": "https://api.atuchat.com/",
|
||||
"local": "http://127.0.0.1:1100/"
|
||||
},
|
||||
"headers": {
|
||||
"req-sys-origin": "origin=ATYOU;originChild=ATYOU",
|
||||
"Req-Atyou": "true"
|
||||
},
|
||||
"endpoints": {
|
||||
"context": "/order/web/pay/h5/context",
|
||||
"options": "/order/web/pay/h5/options",
|
||||
"orders": "/order/web/pay/h5/orders",
|
||||
"order": "/order/web/pay/h5/orders/{orderId}"
|
||||
},
|
||||
"providers": {
|
||||
"mifapay": {
|
||||
"provider_code": "mifapay",
|
||||
"provider_name": "MiFaPay",
|
||||
"status": "active",
|
||||
"countries": [
|
||||
{
|
||||
"country_code": "AE",
|
||||
"country_name": "United Arab Emirates",
|
||||
"currency_code": "AED",
|
||||
"methods": [
|
||||
{ "pay_way": "Card", "pay_type": "CreditCard", "method_name": "UAE Credit Card", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/ae/card-creditcard.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "BD",
|
||||
"country_name": "Bangladesh",
|
||||
"currency_code": "BDT",
|
||||
"methods": [
|
||||
{ "pay_way": "Ewallet", "pay_type": "bKash", "method_name": "bKash", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/bd/ewallet-bkash.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "BH",
|
||||
"country_name": "Bahrain",
|
||||
"currency_code": "BHD",
|
||||
"methods": [
|
||||
{ "pay_way": "Card", "pay_type": "CreditCard", "method_name": "Bahrain Credit Card", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/bh/card-creditcard.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "EG",
|
||||
"country_name": "Egypt",
|
||||
"currency_code": "EGP",
|
||||
"methods": [
|
||||
{ "pay_way": "Ewallet", "pay_type": "FawryPay", "method_name": "FawryPay", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/eg/ewallet-fawrypay.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "Meeza", "method_name": "Meeza", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/eg/ewallet-meeza.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "Orange", "method_name": "Orange", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/eg/ewallet-orange.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "Vodafone", "method_name": "Vodafone", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/eg/ewallet-vodafone.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "ID",
|
||||
"country_name": "Indonesia",
|
||||
"currency_code": "IDR",
|
||||
"methods": [
|
||||
{ "pay_way": "BankTransfer", "pay_type": "BCA", "method_name": "BCA Bank", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-bca.png" },
|
||||
{ "pay_way": "BankTransfer", "pay_type": "BNI", "method_name": "BNI Bank", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-bni.png" },
|
||||
{ "pay_way": "BankTransfer", "pay_type": "BRI", "method_name": "BRI Bank", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-bri.png" },
|
||||
{ "pay_way": "BankTransfer", "pay_type": "Mandiri", "method_name": "Mandiri Bank", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-mandiri.png" },
|
||||
{ "pay_way": "BankTransfer", "pay_type": "Permata", "method_name": "Permata Bank", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-permata.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "DANA", "method_name": "DANA", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/ewallet-dana.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "LinkAja", "method_name": "LinkAja", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/ewallet-linkaja.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "OVO", "method_name": "OVO", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/ewallet-ovo.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "ShopeePay", "method_name": "ShopeePay", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/ewallet-shopeepay.png" },
|
||||
{ "pay_way": "QR", "pay_type": "QRIS", "method_name": "QRIS", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/qr-qris.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "IN",
|
||||
"country_name": "India",
|
||||
"currency_code": "INR",
|
||||
"methods": [
|
||||
{ "pay_way": "Ewallet", "pay_type": "BHIM", "method_name": "BHIM", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-bhim.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "GooglePay", "method_name": "Google Pay", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-googlepay.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "Mobikwik", "method_name": "Mobikwik", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-mobikwik.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "Paytm", "method_name": "Paytm", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-paytm.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "PhonePe", "method_name": "PhonePe", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-phonepe.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "UPI", "method_name": "UPI", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-upi.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "KW",
|
||||
"country_name": "Kuwait",
|
||||
"currency_code": "KWD",
|
||||
"methods": [
|
||||
{ "pay_way": "Card", "pay_type": "Knet", "method_name": "KNET", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/kw/card-knet.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "MY",
|
||||
"country_name": "Malaysia",
|
||||
"currency_code": "MYR",
|
||||
"methods": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "OM",
|
||||
"country_name": "Oman",
|
||||
"currency_code": "OMR",
|
||||
"methods": [
|
||||
{ "pay_way": "Card", "pay_type": "CreditCard", "method_name": "Oman Credit Card", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/om/card-creditcard.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "PH",
|
||||
"country_name": "Philippines",
|
||||
"currency_code": "PHP",
|
||||
"methods": [
|
||||
{ "pay_way": "Ewallet", "pay_type": "Gcash", "method_name": "GCash", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/ph/ewallet-gcash.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "PayMaya", "method_name": "PayMaya", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/ph/ewallet-paymaya.png" },
|
||||
{ "pay_way": "QR", "pay_type": "QRPH", "method_name": "QRPH", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/ph/qr-qrph.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "PK",
|
||||
"country_name": "Pakistan",
|
||||
"currency_code": "PKR",
|
||||
"methods": [
|
||||
{ "pay_way": "Ewallet", "pay_type": "Easypaisa", "method_name": "Easypaisa", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/pk/ewallet-easypaisa.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "JazzCash", "method_name": "JazzCash", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/pk/ewallet-jazzcash.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "QA",
|
||||
"country_name": "Qatar",
|
||||
"currency_code": "QAR",
|
||||
"methods": [
|
||||
{ "pay_way": "Card", "pay_type": "CreditCard", "method_name": "Qatar Credit Card", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/qa/card-creditcard.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "SA",
|
||||
"country_name": "Saudi Arabia",
|
||||
"currency_code": "SAR",
|
||||
"methods": [
|
||||
{ "pay_way": "Card", "pay_type": "MADA", "method_name": "MADA", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/sa/card-mada.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "ApplePay", "method_name": "Apple Pay", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/sa/ewallet-applepay.png" },
|
||||
{ "pay_way": "Ewallet", "pay_type": "STCPay", "method_name": "STCPay", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/sa/ewallet-stcpay.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "TH",
|
||||
"country_name": "Thailand",
|
||||
"currency_code": "THB",
|
||||
"methods": [
|
||||
{ "pay_way": "Ewallet", "pay_type": "TrueMoney", "method_name": "TrueMoney", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/th/ewallet-truemoney.png" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "VN",
|
||||
"country_name": "Vietnam",
|
||||
"currency_code": "VND",
|
||||
"methods": [
|
||||
{ "pay_way": "BankTransfer", "pay_type": "VN_BankTransfer", "method_name": "Vietnam Bank Transfer", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/vn/banktransfer-vn-banktransfer.png" },
|
||||
{ "pay_way": "QR", "pay_type": "VietQR", "method_name": "VietQR", "logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/vn/qr-vietqr.png" }
|
||||
]
|
||||
"app": "aslan",
|
||||
"adapter": "aslan-web-pay",
|
||||
"application_id": "1963531459019739137",
|
||||
"sys_origin": "ATYOU",
|
||||
"type": "GOLD",
|
||||
"api": {
|
||||
"prod": "https://api.atuchat.com/",
|
||||
"test": "https://api.atuchat.com/",
|
||||
"local": "http://127.0.0.1:1100/"
|
||||
},
|
||||
"headers": {
|
||||
"req-sys-origin": "origin=ATYOU;originChild=ATYOU",
|
||||
"Req-Atyou": "true"
|
||||
},
|
||||
"endpoints": {
|
||||
"context": "/order/web/pay/h5/context",
|
||||
"options": "/order/web/pay/h5/options",
|
||||
"orders": "/order/web/pay/h5/orders",
|
||||
"order": "/order/web/pay/h5/orders/{orderId}"
|
||||
},
|
||||
"providers": {
|
||||
"mifapay": {
|
||||
"provider_code": "mifapay",
|
||||
"provider_name": "MiFaPay",
|
||||
"status": "active",
|
||||
"countries": [
|
||||
{
|
||||
"country_code": "AE",
|
||||
"country_codes": ["AE", "ARE"],
|
||||
"country_name": "United Arab Emirates",
|
||||
"currency_code": "AED",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Card",
|
||||
"pay_type": "CreditCard",
|
||||
"method_name": "UAE Credit Card",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/ae/card-creditcard.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "BD",
|
||||
"country_codes": ["BD", "BGD"],
|
||||
"country_name": "Bangladesh",
|
||||
"currency_code": "BDT",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "bKash",
|
||||
"method_name": "bKash",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/bd/ewallet-bkash.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "BH",
|
||||
"country_codes": ["BH", "BHR"],
|
||||
"country_name": "Bahrain",
|
||||
"currency_code": "BHD",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Card",
|
||||
"pay_type": "CreditCard",
|
||||
"method_name": "Bahrain Credit Card",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/bh/card-creditcard.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "EG",
|
||||
"country_codes": ["EG", "EGY"],
|
||||
"country_name": "Egypt",
|
||||
"currency_code": "EGP",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "FawryPay",
|
||||
"method_name": "FawryPay",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/eg/ewallet-fawrypay.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "Meeza",
|
||||
"method_name": "Meeza",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/eg/ewallet-meeza.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "Orange",
|
||||
"method_name": "Orange",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/eg/ewallet-orange.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "Vodafone",
|
||||
"method_name": "Vodafone",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/eg/ewallet-vodafone.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "ID",
|
||||
"country_codes": ["ID", "IDN"],
|
||||
"country_name": "Indonesia",
|
||||
"currency_code": "IDR",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "BankTransfer",
|
||||
"pay_type": "BCA",
|
||||
"method_name": "BCA Bank",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-bca.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "BankTransfer",
|
||||
"pay_type": "BNI",
|
||||
"method_name": "BNI Bank",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-bni.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "BankTransfer",
|
||||
"pay_type": "BRI",
|
||||
"method_name": "BRI Bank",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-bri.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "BankTransfer",
|
||||
"pay_type": "Mandiri",
|
||||
"method_name": "Mandiri Bank",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-mandiri.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "BankTransfer",
|
||||
"pay_type": "Permata",
|
||||
"method_name": "Permata Bank",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/banktransfer-permata.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "DANA",
|
||||
"method_name": "DANA",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/ewallet-dana.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "LinkAja",
|
||||
"method_name": "LinkAja",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/ewallet-linkaja.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "OVO",
|
||||
"method_name": "OVO",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/ewallet-ovo.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "ShopeePay",
|
||||
"method_name": "ShopeePay",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/ewallet-shopeepay.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "QR",
|
||||
"pay_type": "QRIS",
|
||||
"method_name": "QRIS",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/id/qr-qris.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "IN",
|
||||
"country_codes": ["IN", "IND"],
|
||||
"country_name": "India",
|
||||
"currency_code": "INR",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "BHIM",
|
||||
"method_name": "BHIM",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-bhim.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "GooglePay",
|
||||
"method_name": "Google Pay",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-googlepay.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "Mobikwik",
|
||||
"method_name": "Mobikwik",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-mobikwik.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "Paytm",
|
||||
"method_name": "Paytm",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-paytm.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "PhonePe",
|
||||
"method_name": "PhonePe",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-phonepe.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "UPI",
|
||||
"method_name": "UPI",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/in/ewallet-upi.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "KW",
|
||||
"country_codes": ["KW", "KWT"],
|
||||
"country_name": "Kuwait",
|
||||
"currency_code": "KWD",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Card",
|
||||
"pay_type": "Knet",
|
||||
"method_name": "KNET",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/kw/card-knet.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "MY",
|
||||
"country_codes": ["MY", "MYS"],
|
||||
"country_name": "Malaysia",
|
||||
"currency_code": "MYR",
|
||||
"methods": []
|
||||
},
|
||||
{
|
||||
"country_code": "OM",
|
||||
"country_codes": ["OM", "OMN"],
|
||||
"country_name": "Oman",
|
||||
"currency_code": "OMR",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Card",
|
||||
"pay_type": "CreditCard",
|
||||
"method_name": "Oman Credit Card",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/om/card-creditcard.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "PH",
|
||||
"country_codes": ["PH", "PHL"],
|
||||
"country_name": "Philippines",
|
||||
"currency_code": "PHP",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "Gcash",
|
||||
"method_name": "GCash",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/ph/ewallet-gcash.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "PayMaya",
|
||||
"method_name": "PayMaya",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/ph/ewallet-paymaya.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "QR",
|
||||
"pay_type": "QRPH",
|
||||
"method_name": "QRPH",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/ph/qr-qrph.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "PK",
|
||||
"country_codes": ["PK", "PAK"],
|
||||
"country_name": "Pakistan",
|
||||
"currency_code": "PKR",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "Easypaisa",
|
||||
"method_name": "Easypaisa",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/pk/ewallet-easypaisa.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "JazzCash",
|
||||
"method_name": "JazzCash",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/pk/ewallet-jazzcash.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "QA",
|
||||
"country_codes": ["QA", "QAT"],
|
||||
"country_name": "Qatar",
|
||||
"currency_code": "QAR",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Card",
|
||||
"pay_type": "CreditCard",
|
||||
"method_name": "Qatar Credit Card",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/qa/card-creditcard.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "KSA",
|
||||
"country_codes": ["KSA", "SA", "SAU", "SP"],
|
||||
"country_name": "Saudi Arabia",
|
||||
"currency_code": "SAR",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Card",
|
||||
"pay_type": "MADA",
|
||||
"method_name": "MADA",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/sa/card-mada.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "ApplePay",
|
||||
"method_name": "Apple Pay",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/sa/ewallet-applepay.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "STCPay",
|
||||
"method_name": "STCPay",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/sa/ewallet-stcpay.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "TH",
|
||||
"country_codes": ["TH", "THA"],
|
||||
"country_name": "Thailand",
|
||||
"currency_code": "THB",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "Ewallet",
|
||||
"pay_type": "TrueMoney",
|
||||
"method_name": "TrueMoney",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/th/ewallet-truemoney.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"country_code": "VN",
|
||||
"country_codes": ["VN", "VNM"],
|
||||
"country_name": "Vietnam",
|
||||
"currency_code": "VND",
|
||||
"methods": [
|
||||
{
|
||||
"pay_way": "BankTransfer",
|
||||
"pay_type": "VN_BankTransfer",
|
||||
"method_name": "Vietnam Bank Transfer",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/vn/banktransfer-vn-banktransfer.png"
|
||||
},
|
||||
{
|
||||
"pay_way": "QR",
|
||||
"pay_type": "VietQR",
|
||||
"method_name": "VietQR",
|
||||
"logo_url": "https://media.haiyihy.com/admin/payment/mifapay/logos/vn/qr-vietqr.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
749
recharge/create.html
Normal file
749
recharge/create.html
Normal file
@ -0,0 +1,749 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>三方临时支付链接</title>
|
||||
<link rel="stylesheet" href="../common/theme.css" />
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--hy-theme-bg);
|
||||
color: var(--hy-theme-text);
|
||||
font-family:
|
||||
-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
}
|
||||
|
||||
button,
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.page {
|
||||
width: min(1120px, 100%);
|
||||
margin: 0 auto;
|
||||
padding: 28px 18px 42px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.meta {
|
||||
margin: 6px 0 0;
|
||||
color: var(--hy-theme-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
|
||||
}
|
||||
|
||||
.panel {
|
||||
border: 1px solid var(--hy-theme-line);
|
||||
border-radius: 14px;
|
||||
background: var(--hy-theme-surface);
|
||||
box-shadow: var(--hy-theme-shadow);
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.panel h2 {
|
||||
margin: 0 0 16px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.field.full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
label {
|
||||
color: var(--hy-theme-muted);
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
border: 1px solid var(--hy-theme-line);
|
||||
border-radius: 10px;
|
||||
outline: none;
|
||||
background: var(--hy-theme-surface-soft);
|
||||
color: var(--hy-theme-text);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
min-height: 86px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
select:focus,
|
||||
textarea:focus {
|
||||
border-color: var(--hy-theme-primary-strong);
|
||||
box-shadow: 0 0 0 4px var(--hy-theme-focus-ring);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.button {
|
||||
min-height: 42px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
padding: 0 16px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.button.primary {
|
||||
background: var(--hy-theme-button);
|
||||
color: #fff;
|
||||
box-shadow: var(--hy-theme-button-shadow);
|
||||
}
|
||||
|
||||
.button.secondary {
|
||||
border-color: var(--hy-theme-line);
|
||||
background: var(--hy-theme-surface-soft);
|
||||
color: var(--hy-theme-primary-deep);
|
||||
}
|
||||
|
||||
.button:disabled {
|
||||
cursor: not-allowed;
|
||||
background: var(--hy-theme-button-disabled);
|
||||
color: var(--hy-theme-button-disabled-text);
|
||||
box-shadow: var(--hy-theme-button-disabled-shadow);
|
||||
}
|
||||
|
||||
.result {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.result-row {
|
||||
display: grid;
|
||||
min-width: 0;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.result-row strong {
|
||||
color: var(--hy-theme-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.value {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
border-radius: 10px;
|
||||
background: var(--hy-theme-primary-soft);
|
||||
padding: 10px 12px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: inline-flex;
|
||||
width: fit-content;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
background: var(--hy-theme-primary-soft);
|
||||
color: var(--hy-theme-primary-deep);
|
||||
padding: 5px 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.status.paid {
|
||||
background: rgba(49, 198, 168, 0.14);
|
||||
color: var(--hy-theme-success);
|
||||
}
|
||||
|
||||
.status.failed {
|
||||
background: rgba(217, 93, 114, 0.12);
|
||||
color: var(--hy-theme-danger);
|
||||
}
|
||||
|
||||
.message {
|
||||
min-height: 22px;
|
||||
margin-top: 12px;
|
||||
color: var(--hy-theme-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.message.error {
|
||||
color: var(--hy-theme-danger);
|
||||
}
|
||||
|
||||
.message.success {
|
||||
color: var(--hy-theme-success);
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.header {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.grid,
|
||||
.form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="page">
|
||||
<header class="header">
|
||||
<div>
|
||||
<h1 class="title">三方临时支付链接</h1>
|
||||
<p class="meta" id="envMeta">加载环境中...</p>
|
||||
</div>
|
||||
<button
|
||||
class="button secondary"
|
||||
type="button"
|
||||
id="reloadMethods"
|
||||
>
|
||||
刷新支付方式
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<section class="grid">
|
||||
<div class="panel">
|
||||
<h2>创建支付链接</h2>
|
||||
<form id="createForm">
|
||||
<div class="form-grid">
|
||||
<div class="field full">
|
||||
<label for="paymentMethod">支付方式</label>
|
||||
<select id="paymentMethod" required>
|
||||
<option value="">
|
||||
正在加载支付方式...
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="coinAmount">金币数量</label>
|
||||
<input
|
||||
id="coinAmount"
|
||||
inputmode="numeric"
|
||||
min="1"
|
||||
placeholder="例如 1000"
|
||||
required
|
||||
type="number"
|
||||
/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="usdAmount">美金金额</label>
|
||||
<input
|
||||
id="usdAmount"
|
||||
inputmode="decimal"
|
||||
min="0.01"
|
||||
placeholder="例如 9.99"
|
||||
required
|
||||
step="0.01"
|
||||
type="number"
|
||||
/>
|
||||
</div>
|
||||
<div class="field full">
|
||||
<label for="returnUrl">支付完成返回地址</label>
|
||||
<input
|
||||
id="returnUrl"
|
||||
placeholder="不填则返回当前页面"
|
||||
type="url"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button
|
||||
class="button primary"
|
||||
type="submit"
|
||||
id="createButton"
|
||||
>
|
||||
创建链接
|
||||
</button>
|
||||
</div>
|
||||
<div class="message" id="createMessage"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h2>创建结果</h2>
|
||||
<div class="result" id="createResult">
|
||||
<div class="value">还没有创建支付链接</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button
|
||||
class="button secondary"
|
||||
disabled
|
||||
type="button"
|
||||
id="copyLink"
|
||||
>
|
||||
复制链接
|
||||
</button>
|
||||
<button
|
||||
class="button secondary"
|
||||
disabled
|
||||
type="button"
|
||||
id="openLink"
|
||||
>
|
||||
打开支付
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h2>验证支付链接</h2>
|
||||
<div class="field">
|
||||
<label for="verifyInput">订单号或支付链接</label>
|
||||
<input
|
||||
id="verifyInput"
|
||||
placeholder="输入 order_id,或粘贴创建出来的支付链接"
|
||||
/>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button
|
||||
class="button primary"
|
||||
type="button"
|
||||
id="verifyButton"
|
||||
>
|
||||
验证支付状态
|
||||
</button>
|
||||
</div>
|
||||
<div class="message" id="verifyMessage"></div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h2>验证结果</h2>
|
||||
<div class="result" id="verifyResult">
|
||||
<div class="value">还没有验证订单</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<script src="../common/api.js"></script>
|
||||
<script>
|
||||
(function () {
|
||||
var methods = [];
|
||||
var latestPaymentLink = '';
|
||||
var latestOrderID = '';
|
||||
var els = {
|
||||
coinAmount: document.getElementById('coinAmount'),
|
||||
copyLink: document.getElementById('copyLink'),
|
||||
createButton: document.getElementById('createButton'),
|
||||
createForm: document.getElementById('createForm'),
|
||||
createMessage: document.getElementById('createMessage'),
|
||||
createResult: document.getElementById('createResult'),
|
||||
envMeta: document.getElementById('envMeta'),
|
||||
openLink: document.getElementById('openLink'),
|
||||
paymentMethod: document.getElementById('paymentMethod'),
|
||||
reloadMethods: document.getElementById('reloadMethods'),
|
||||
returnUrl: document.getElementById('returnUrl'),
|
||||
usdAmount: document.getElementById('usdAmount'),
|
||||
verifyButton: document.getElementById('verifyButton'),
|
||||
verifyInput: document.getElementById('verifyInput'),
|
||||
verifyMessage: document.getElementById('verifyMessage'),
|
||||
verifyResult: document.getElementById('verifyResult'),
|
||||
};
|
||||
|
||||
els.envMeta.textContent =
|
||||
'App:' +
|
||||
window.HyAppAPI.getAppCode() +
|
||||
' | API:' +
|
||||
window.HyAppAPI.baseURL();
|
||||
els.createForm.addEventListener('submit', createPaymentLink);
|
||||
els.reloadMethods.addEventListener('click', loadMethods);
|
||||
els.copyLink.addEventListener('click', function () {
|
||||
copyText(latestPaymentLink, els.createMessage);
|
||||
});
|
||||
els.openLink.addEventListener('click', function () {
|
||||
if (latestPaymentLink)
|
||||
window.open(
|
||||
latestPaymentLink,
|
||||
'_blank',
|
||||
'noopener,noreferrer'
|
||||
);
|
||||
});
|
||||
els.verifyButton.addEventListener('click', verifyPaymentLink);
|
||||
loadMethods();
|
||||
|
||||
function loadMethods() {
|
||||
setMessage(els.createMessage, '正在加载支付方式...', '');
|
||||
els.paymentMethod.disabled = true;
|
||||
return window.HyAppAPI.get(
|
||||
'/api/v1/recharge/h5/temporary/methods'
|
||||
)
|
||||
.then(function (data) {
|
||||
methods = Array.isArray(data.methods)
|
||||
? data.methods
|
||||
: [];
|
||||
renderMethods();
|
||||
setMessage(
|
||||
els.createMessage,
|
||||
methods.length
|
||||
? '支付方式已加载'
|
||||
: '没有可用支付方式',
|
||||
methods.length ? 'success' : 'error'
|
||||
);
|
||||
})
|
||||
.catch(function (err) {
|
||||
methods = [];
|
||||
renderMethods();
|
||||
setMessage(
|
||||
els.createMessage,
|
||||
err.message || '加载支付方式失败',
|
||||
'error'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function renderMethods() {
|
||||
els.paymentMethod.innerHTML = '';
|
||||
if (!methods.length) {
|
||||
appendOption('', '没有可用支付方式');
|
||||
els.paymentMethod.disabled = true;
|
||||
return;
|
||||
}
|
||||
appendOption('', '请选择支付方式');
|
||||
methods.forEach(function (method) {
|
||||
var label = [
|
||||
method.provider_name || method.provider_code,
|
||||
method.method_name || method.pay_way,
|
||||
method.pay_type,
|
||||
method.currency_code,
|
||||
method.country_code,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' / ');
|
||||
appendOption(String(method.method_id), label);
|
||||
});
|
||||
els.paymentMethod.disabled = false;
|
||||
}
|
||||
|
||||
function appendOption(value, label) {
|
||||
var option = document.createElement('option');
|
||||
option.value = value;
|
||||
option.textContent = label;
|
||||
els.paymentMethod.appendChild(option);
|
||||
}
|
||||
|
||||
function createPaymentLink(event) {
|
||||
event.preventDefault();
|
||||
var method = selectedMethod();
|
||||
var coinAmount = parseInt(els.coinAmount.value, 10);
|
||||
var usdMinorAmount = dollarsToMinor(els.usdAmount.value);
|
||||
if (
|
||||
!method ||
|
||||
!coinAmount ||
|
||||
coinAmount <= 0 ||
|
||||
!usdMinorAmount ||
|
||||
usdMinorAmount <= 0
|
||||
) {
|
||||
setMessage(
|
||||
els.createMessage,
|
||||
'请选择支付方式,并填写大于 0 的金币和美金金额',
|
||||
'error'
|
||||
);
|
||||
return;
|
||||
}
|
||||
setLoading(els.createButton, true, '创建中...');
|
||||
setMessage(els.createMessage, '正在创建支付链接...', '');
|
||||
window.HyAppAPI.post(
|
||||
'/api/v1/recharge/h5/temporary/orders',
|
||||
{
|
||||
coin_amount: coinAmount,
|
||||
usd_minor_amount: usdMinorAmount,
|
||||
provider_code: method.provider_code,
|
||||
payment_method_id: method.method_id,
|
||||
return_url:
|
||||
els.returnUrl.value.trim() ||
|
||||
window.location.href,
|
||||
}
|
||||
)
|
||||
.then(function (data) {
|
||||
latestPaymentLink = data.payment_link || '';
|
||||
latestOrderID =
|
||||
data.order && data.order.order_id
|
||||
? data.order.order_id
|
||||
: '';
|
||||
renderOrder(els.createResult, data);
|
||||
els.copyLink.disabled = !latestPaymentLink;
|
||||
els.openLink.disabled = !latestPaymentLink;
|
||||
if (latestOrderID)
|
||||
els.verifyInput.value = latestOrderID;
|
||||
setMessage(
|
||||
els.createMessage,
|
||||
'支付链接已创建',
|
||||
'success'
|
||||
);
|
||||
})
|
||||
.catch(function (err) {
|
||||
setMessage(
|
||||
els.createMessage,
|
||||
err.message || '创建支付链接失败',
|
||||
'error'
|
||||
);
|
||||
})
|
||||
.finally(function () {
|
||||
setLoading(els.createButton, false, '创建链接');
|
||||
});
|
||||
}
|
||||
|
||||
function verifyPaymentLink() {
|
||||
var orderID = extractOrderID(els.verifyInput.value);
|
||||
if (!orderID) {
|
||||
setMessage(
|
||||
els.verifyMessage,
|
||||
'请输入订单号,或粘贴包含订单号的支付链接',
|
||||
'error'
|
||||
);
|
||||
return;
|
||||
}
|
||||
setLoading(els.verifyButton, true, '验证中...');
|
||||
setMessage(
|
||||
els.verifyMessage,
|
||||
'正在向后端查询支付状态...',
|
||||
''
|
||||
);
|
||||
window.HyAppAPI.get(
|
||||
'/api/v1/recharge/h5/temporary/orders/' +
|
||||
encodeURIComponent(orderID)
|
||||
)
|
||||
.then(function (data) {
|
||||
renderOrder(els.verifyResult, data);
|
||||
setMessage(
|
||||
els.verifyMessage,
|
||||
statusText(data.order && data.order.status),
|
||||
data.order && data.order.status === 'paid'
|
||||
? 'success'
|
||||
: ''
|
||||
);
|
||||
})
|
||||
.catch(function (err) {
|
||||
setMessage(
|
||||
els.verifyMessage,
|
||||
err.message || '验证支付状态失败',
|
||||
'error'
|
||||
);
|
||||
})
|
||||
.finally(function () {
|
||||
setLoading(els.verifyButton, false, '验证支付状态');
|
||||
});
|
||||
}
|
||||
|
||||
function renderOrder(target, data) {
|
||||
var order = data.order || {};
|
||||
var paymentLink = data.payment_link || order.pay_url || '';
|
||||
target.innerHTML = [
|
||||
resultRow('订单号', order.order_id || '-'),
|
||||
resultRow(
|
||||
'支付状态',
|
||||
'<span class="status ' +
|
||||
escapeHTML(order.status || '') +
|
||||
'">' +
|
||||
escapeHTML(statusLabel(order.status)) +
|
||||
'</span>'
|
||||
),
|
||||
resultRow(
|
||||
'金币/美金',
|
||||
escapeHTML(
|
||||
formatNumber(order.coin_amount) +
|
||||
' 金币 / USD ' +
|
||||
formatMoney(order.usd_minor_amount)
|
||||
)
|
||||
),
|
||||
resultRow(
|
||||
'支付方式',
|
||||
escapeHTML(
|
||||
[
|
||||
order.provider_code,
|
||||
order.pay_way,
|
||||
order.pay_type,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' / ') || '-'
|
||||
)
|
||||
),
|
||||
resultRow('支付链接', escapeHTML(paymentLink || '-')),
|
||||
data.wrapped
|
||||
? resultRow(
|
||||
'中转说明',
|
||||
escapeHTML(
|
||||
data.wrapped_note ||
|
||||
'已生成 COS 中转 HTML'
|
||||
)
|
||||
)
|
||||
: '',
|
||||
data.raw_pay_url
|
||||
? resultRow(
|
||||
'原始链接',
|
||||
escapeHTML(data.raw_pay_url)
|
||||
)
|
||||
: '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('');
|
||||
}
|
||||
|
||||
function resultRow(label, valueHTML) {
|
||||
return (
|
||||
'<div class="result-row"><strong>' +
|
||||
escapeHTML(label) +
|
||||
'</strong><div class="value">' +
|
||||
valueHTML +
|
||||
'</div></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function selectedMethod() {
|
||||
var id = Number(els.paymentMethod.value || 0);
|
||||
return methods.find(function (method) {
|
||||
return Number(method.method_id) === id;
|
||||
});
|
||||
}
|
||||
|
||||
function dollarsToMinor(value) {
|
||||
var text = String(value || '').trim();
|
||||
if (!/^\d+(\.\d{1,2})?$/.test(text)) return 0;
|
||||
return Math.round(Number(text) * 100);
|
||||
}
|
||||
|
||||
function extractOrderID(value) {
|
||||
var text = String(value || '').trim();
|
||||
if (!text) return '';
|
||||
try {
|
||||
var url = new URL(text, window.location.href);
|
||||
var queryID =
|
||||
url.searchParams.get('order_id') ||
|
||||
url.searchParams.get('orderId');
|
||||
if (queryID) return queryID.trim();
|
||||
var match = url.pathname.match(
|
||||
/temporary-pay\/([^/]+)\.html$/
|
||||
);
|
||||
if (match) return decodeURIComponent(match[1]);
|
||||
} catch (_) {
|
||||
// 输入可能就是订单号,不是 URL。
|
||||
}
|
||||
return text.replace(/^order_id=/, '').trim();
|
||||
}
|
||||
|
||||
function setLoading(button, loading, text) {
|
||||
button.disabled = loading;
|
||||
button.textContent = text;
|
||||
}
|
||||
|
||||
function setMessage(node, text, tone) {
|
||||
node.textContent = text || '';
|
||||
node.className = ['message', tone || '']
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
function statusText(status) {
|
||||
return status === 'paid'
|
||||
? '支付已成功'
|
||||
: '当前状态:' + statusLabel(status);
|
||||
}
|
||||
|
||||
function statusLabel(status) {
|
||||
if (status === 'paid') return '已支付';
|
||||
if (status === 'redirected') return '已生成链接';
|
||||
if (status === 'pending') return '待支付';
|
||||
if (status === 'failed') return '失败';
|
||||
if (status === 'credited') return '已入账';
|
||||
return status || '-';
|
||||
}
|
||||
|
||||
function formatNumber(value) {
|
||||
if (value === 0 || value)
|
||||
return Number(value).toLocaleString('zh-CN');
|
||||
return '-';
|
||||
}
|
||||
|
||||
function formatMoney(value) {
|
||||
if (!(value === 0 || value)) return '-';
|
||||
return (Number(value) / 100).toLocaleString('zh-CN', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
});
|
||||
}
|
||||
|
||||
function escapeHTML(value) {
|
||||
return String(value || '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function copyText(value, messageNode) {
|
||||
if (!value) return;
|
||||
var done = function () {
|
||||
setMessage(messageNode, '已复制支付链接', 'success');
|
||||
};
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard
|
||||
.writeText(value)
|
||||
.then(done)
|
||||
.catch(function () {
|
||||
fallbackCopy(value);
|
||||
done();
|
||||
});
|
||||
return;
|
||||
}
|
||||
fallbackCopy(value);
|
||||
done();
|
||||
}
|
||||
|
||||
function fallbackCopy(value) {
|
||||
var input = document.createElement('textarea');
|
||||
input.value = value;
|
||||
input.setAttribute('readonly', '');
|
||||
input.style.position = 'fixed';
|
||||
input.style.opacity = '0';
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
input.remove();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -2268,10 +2268,15 @@
|
||||
function selectPayCountryFromConfig(context) {
|
||||
var configured = selectedConfiguredPayCountry(context);
|
||||
if (configured) {
|
||||
var resolved = payCountryFromContext(
|
||||
context,
|
||||
configured.country_code || configured.countryCode
|
||||
);
|
||||
var configuredCode =
|
||||
primaryConfiguredCountryCode(configured);
|
||||
var resolved =
|
||||
payCountryFromContext(
|
||||
context,
|
||||
userCountryCodeFromContext(context)
|
||||
) ||
|
||||
payCountryFromContext(context, configuredCode) ||
|
||||
{};
|
||||
// app JSON 只控制国家和支付方式是否展示;后台 payCountryId 必须从账号 context 的国家映射里取,
|
||||
// 否则 Yumi 这类旧下单接口会在商品已展示后因为 payCountryId 为空被参数校验拦截。
|
||||
state.selectedPayCountryID =
|
||||
@ -2283,8 +2288,7 @@
|
||||
resolved.id ||
|
||||
'';
|
||||
state.selectedCountryCode = String(
|
||||
configured.country_code ||
|
||||
configured.countryCode ||
|
||||
configuredCode ||
|
||||
resolved.country_code ||
|
||||
resolved.countryCode ||
|
||||
''
|
||||
@ -2346,12 +2350,9 @@
|
||||
if (!userCountryCode) return null;
|
||||
return (
|
||||
countries.find(function (country) {
|
||||
return (
|
||||
String(
|
||||
country.country_code ||
|
||||
country.countryCode ||
|
||||
''
|
||||
).toUpperCase() === userCountryCode
|
||||
return configuredCountryMatchesCode(
|
||||
country,
|
||||
userCountryCode
|
||||
);
|
||||
}) || null
|
||||
);
|
||||
@ -2366,6 +2367,47 @@
|
||||
: [];
|
||||
}
|
||||
|
||||
function primaryConfiguredCountryCode(country) {
|
||||
return configuredCountryCodes(country)[0] || '';
|
||||
}
|
||||
|
||||
function configuredCountryMatchesCode(country, code) {
|
||||
code = String(code || '')
|
||||
.trim()
|
||||
.toUpperCase();
|
||||
if (!code) return false;
|
||||
return configuredCountryCodes(country).indexOf(code) >= 0;
|
||||
}
|
||||
|
||||
function configuredCountryCodes(country) {
|
||||
country = country || {};
|
||||
var rawCodes = []
|
||||
.concat(country.country_code || [])
|
||||
.concat(country.countryCode || [])
|
||||
.concat(country.country_codes || [])
|
||||
.concat(country.countryCodes || []);
|
||||
var codes = [];
|
||||
rawCodes.forEach(function (value) {
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(function (item) {
|
||||
pushConfiguredCountryCode(codes, item);
|
||||
});
|
||||
return;
|
||||
}
|
||||
pushConfiguredCountryCode(codes, value);
|
||||
});
|
||||
return codes;
|
||||
}
|
||||
|
||||
function pushConfiguredCountryCode(codes, value) {
|
||||
value = String(value || '')
|
||||
.trim()
|
||||
.toUpperCase();
|
||||
if (value && codes.indexOf(value) < 0) {
|
||||
codes.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
function payCountryFromContext(context, countryCode) {
|
||||
var countries =
|
||||
(context &&
|
||||
@ -2392,7 +2434,7 @@
|
||||
''
|
||||
).toUpperCase() === normalizedCountryCode
|
||||
);
|
||||
}) || {}
|
||||
}) || null
|
||||
);
|
||||
}
|
||||
|
||||
@ -2474,7 +2516,8 @@
|
||||
|
||||
function isLegacyWebPayApp() {
|
||||
var adapter =
|
||||
state.appConfig && String(state.appConfig.adapter || '');
|
||||
state.appConfig &&
|
||||
String(state.appConfig.adapter || '');
|
||||
// Aslan/Yumi 仍走旧支付网关,保持原来的字符串商品 ID,避免影响老接口的字段兼容。
|
||||
return (
|
||||
adapter === 'aslan-web-pay' ||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user