feat: wire payment return url payloads
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { CreateOrderResult, MethodLimit } from '@/types/payment'
|
||||
import {
|
||||
buildCreateOrderPayload,
|
||||
decidePaymentLaunch,
|
||||
getVisibleMethods,
|
||||
readPaymentRecoverySnapshot,
|
||||
@@ -106,6 +107,42 @@ describe('decidePaymentLaunch', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildCreateOrderPayload', () => {
|
||||
it('normalizes visible method aliases and attaches a canonical result URL', () => {
|
||||
expect(buildCreateOrderPayload({
|
||||
amount: 88,
|
||||
paymentType: 'alipay_direct',
|
||||
orderType: 'balance',
|
||||
origin: 'https://app.example.com/',
|
||||
isWechatBrowser: false,
|
||||
})).toEqual({
|
||||
amount: 88,
|
||||
payment_type: 'alipay',
|
||||
order_type: 'balance',
|
||||
return_url: 'https://app.example.com/payment/result',
|
||||
payment_source: 'hosted_redirect',
|
||||
})
|
||||
})
|
||||
|
||||
it('uses WeChat in-app resume source for visible WeChat payments in the WeChat browser', () => {
|
||||
expect(buildCreateOrderPayload({
|
||||
amount: 128,
|
||||
paymentType: 'wxpay',
|
||||
orderType: 'subscription',
|
||||
planId: 7,
|
||||
origin: 'https://app.example.com',
|
||||
isWechatBrowser: true,
|
||||
})).toEqual({
|
||||
amount: 128,
|
||||
payment_type: 'wxpay',
|
||||
order_type: 'subscription',
|
||||
plan_id: 7,
|
||||
return_url: 'https://app.example.com/payment/result',
|
||||
payment_source: 'wechat_in_app_resume',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('readPaymentRecoverySnapshot', () => {
|
||||
it('restores an unexpired snapshot when the resume token matches', () => {
|
||||
const snapshot: PaymentRecoverySnapshot = {
|
||||
|
||||
Reference in New Issue
Block a user