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

@@ -397,9 +397,24 @@ extension CheckoutView {
? pixFromPayment?.expirationDate : pixFromPayload?.expirationDate
if let copyPaste, copyPaste.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false {
let itemsData = (try? JSONEncoder().encode(appState.cart.toOrderItemsPayload())).flatMap { String(data: $0, encoding: .utf8) } ?? "[]"
let storeId = appState.cart.storeId ?? ""
pixPaymentContext = PixPaymentContext(
id: orderId, orderId: orderId, shortId: result.shortId,
copyPaste: copyPaste, qrCodeImageBase64: qrCodeImage, expirationDate: expirationDate
id: orderId,
orderId: orderId,
shortId: result.shortId,
storeId: storeId,
copyPaste: copyPaste,
qrCodeImageBase64: qrCodeImage,
expirationDate: expirationDate,
total: totalValue,
profileName: appState.profile.name,
profileEmail: appState.profile.email,
profilePhone: appState.profile.phone,
addressZip: selectedCustomerAddress?.zipCode,
addressNumber: selectedCustomerAddress?.number,
deliveryType: deliveryType.rawValue,
itemsJSON: itemsData
)
return
}