支付宝电脑支付生成支付链接 设置time_expire

This commit is contained in:
wkj 2025-06-16 13:07:52 +08:00
parent 23dc8bcd36
commit 412a20186c
4 changed files with 10 additions and 4 deletions

View File

@ -181,6 +181,7 @@ export default class AliPay extends AliPayDebug {
const out_trade_no = compressTo32(pay.id);
// 支付宝金额单位为元,需要转换
const totalAmount = ToYuan(pay.price);
const timeoutAt = Date.now() + PREPAY_TIMEOUT;
switch (this.apProduct.type) {
case 'native': {
const method = this.apProduct.config?.prepayMethod || 'GET';
@ -196,6 +197,7 @@ export default class AliPay extends AliPayDebug {
notify_url: payNotifyUrl,
qr_pay_mode: qrPayMode,
qrcode_width: qrCodeWidth,
time_expire: dayJs(timeoutAt).format('yyyy-MM-dd HH:mm:ss'),
},
notify_url: payNotifyUrl,
needEncrypt: this.needEncrypt,
@ -217,7 +219,7 @@ export default class AliPay extends AliPayDebug {
}
}
// pay加一个过期时间到期自动close
data.timeoutAt = Date.now() + PREPAY_TIMEOUT;
data.timeoutAt = timeoutAt + 1000 * 60 * 3;
}
async getState(pay) {
const outTradeNo = compressTo32(pay.id);

View File

@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
* @param context
* @param refunds
*/
export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>;
export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
export default triggers;

View File

@ -184,6 +184,7 @@ class AliPay extends AliPay_debug_1.default {
const out_trade_no = (0, uuid_1.compressTo32)(pay.id);
// 支付宝金额单位为元,需要转换
const totalAmount = (0, money_1.ToYuan)(pay.price);
const timeoutAt = Date.now() + PREPAY_TIMEOUT;
switch (this.apProduct.type) {
case 'native': {
const method = this.apProduct.config?.prepayMethod || 'GET';
@ -199,6 +200,7 @@ class AliPay extends AliPay_debug_1.default {
notify_url: payNotifyUrl,
qr_pay_mode: qrPayMode,
qrcode_width: qrCodeWidth,
time_expire: (0, dayjs_1.default)(timeoutAt).format('yyyy-MM-dd HH:mm:ss'),
},
notify_url: payNotifyUrl,
needEncrypt: this.needEncrypt,
@ -220,7 +222,7 @@ class AliPay extends AliPay_debug_1.default {
}
}
// pay加一个过期时间到期自动close
data.timeoutAt = Date.now() + PREPAY_TIMEOUT;
data.timeoutAt = timeoutAt + 1000 * 60 * 3;
}
async getState(pay) {
const outTradeNo = (0, uuid_1.compressTo32)(pay.id);

View File

@ -211,6 +211,7 @@ export default class AliPay extends AliPayDebug implements PayClazz {
const out_trade_no = compressTo32(pay.id);
// 支付宝金额单位为元,需要转换
const totalAmount = ToYuan(pay.price);
const timeoutAt = Date.now() + PREPAY_TIMEOUT;
switch (this.apProduct.type!) {
case 'native': {
const method = this.apProduct.config?.prepayMethod || 'GET';
@ -226,6 +227,7 @@ export default class AliPay extends AliPayDebug implements PayClazz {
notify_url: payNotifyUrl,
qr_pay_mode: qrPayMode,
qrcode_width: qrCodeWidth,
time_expire: dayJs(timeoutAt).format('yyyy-MM-dd HH:mm:ss'),
},
notify_url: payNotifyUrl,
needEncrypt: this.needEncrypt,
@ -249,7 +251,7 @@ export default class AliPay extends AliPayDebug implements PayClazz {
}
}
// pay加一个过期时间到期自动close
data.timeoutAt = Date.now() + PREPAY_TIMEOUT;
data.timeoutAt = timeoutAt + 1000 * 60 * 3;
}
async getState(pay: OpPay): Promise<[EntityDict['pay']['OpSchema']['iState'], PayUpdateData]> {