Add instant payment collection flow aligned with Android.
Implement收款详情与收款记录 pages with pay-code API, QR generation, amount setting, and record grouping so merchants can collect payments from the home quick action. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
53
suixinkanTests/PaymentModelsTests.swift
Normal file
53
suixinkanTests/PaymentModelsTests.swift
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// PaymentModelsTests.swift
|
||||
// suixinkanTests
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import suixinkan
|
||||
|
||||
/// 收款模型解码测试。
|
||||
final class PaymentModelsTests: XCTestCase {
|
||||
func testPayCodeResponseDecodesSnakeCaseFields() throws {
|
||||
let json = """
|
||||
{
|
||||
"static_pay_url": "https://pay.example.com/static",
|
||||
"dynamic_pay_url": "https://pay.example.com/dynamic"
|
||||
}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
let response = try JSONDecoder().decode(PayCodeResponse.self, from: json)
|
||||
|
||||
XCTAssertEqual(response.staticPayURL, "https://pay.example.com/static")
|
||||
XCTAssertEqual(response.dynamicPayURL, "https://pay.example.com/dynamic")
|
||||
}
|
||||
|
||||
func testRepaymentCollectionRecordResponseDecodesGroupedFields() throws {
|
||||
let json = """
|
||||
{
|
||||
"analyse": [
|
||||
{
|
||||
"date": "2024-01-15",
|
||||
"order_count": 2,
|
||||
"order_amount_sum": "100.00"
|
||||
}
|
||||
],
|
||||
"list": [
|
||||
{
|
||||
"order_number": "NO001",
|
||||
"user_phone": "13800138000",
|
||||
"order_amount": "50.00",
|
||||
"create_date": "2024-01-15",
|
||||
"create_time": "10:00:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
let response = try JSONDecoder().decode(RepaymentCollectionRecordResponse.self, from: json)
|
||||
|
||||
XCTAssertEqual(response.analyse.count, 1)
|
||||
XCTAssertEqual(response.analyse[0].orderCount, 2)
|
||||
XCTAssertEqual(response.list[0].orderNumber, "NO001")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user