feat(payment): implement change payment method (PATCH /payment-method)

- ChangePaymentMethodPayload + ChangePaymentMethodResult models
- ApiService.changePaymentMethod()
- PixPaymentContext gains storeId + order data for payment switch
- PaymentPixView: Trocar button opens ChangePaymentSheet with 3 options
- ChangePaymentSheet: Novo PIX (new QR), Cartão (saved or new), Pagar na Entrega
- ChangePaymentCardSheet + ChangePaymentNewCardView with same card masks/validation
- OrdersView/OrderEntryDestinationView: threaded appState binding
This commit is contained in:
Daniel Arantes Loverde
2026-06-03 18:49:07 -03:00
parent 9525c19b6b
commit ee8745553e
6 changed files with 487 additions and 21 deletions

View File

@@ -451,6 +451,12 @@ final class ApiService {
return try await sendEnvelope(req)
}
func changePaymentMethod(storeId: String, orderId: String, payload: ChangePaymentMethodPayload) async throws -> ApiEnvelope<ChangePaymentMethodResult> {
let body = try JSONEncoder().encode(payload)
let req = ApiRequest(path: "/api/store/\(storeId)/orders/\(orderId)/payment-method", method: "PATCH", module: .store, requiresAuth: true, body: body)
return try await sendEnvelope(req)
}
// MARK: - Profile CPF
func updateProfileCpf(cpf: String) async throws -> ApiEnvelope<EmptyResult> {