-
Notifications
You must be signed in to change notification settings - Fork 1
/
PaymentModel.swift
121 lines (111 loc) · 3.69 KB
/
PaymentModel.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// PaymentModel.swift
//
//
// Created by Danny Leiser on 4/27/23.
// Copyright © 2023-Present Forage Technology Corporation. All rights reserved.
//
import Foundation
public struct ForageAddress: Codable {
public let city: String
public let country: String
public let line1: String?
public let line2: String?
public let zipcode: String
public let state: String
}
public struct ReceiptBalance: Codable {
public let id: Int
public let snap: String
public let cash: String
public let updated: String
private enum CodingKeys: String, CodingKey {
case id
case cash = "non_snap"
case snap
case updated
}
}
public struct Receipt: Codable {
public let refNumber: String
public let isVoided: Bool
public let snapAmount: String
public let ebtCashAmount: String
public let otherAmount: String
public let salesTaxApplied: String
public let balance: ReceiptBalance?
public let last4: String
public let message: String
public let transactionType: String
public let created: String
private enum CodingKeys: String, CodingKey {
case refNumber = "ref_number"
case isVoided = "is_voided"
case snapAmount = "snap_amount"
case ebtCashAmount = "ebt_cash_amount"
case otherAmount = "other_amount"
case salesTaxApplied = "sales_tax_applied"
case balance
case last4 = "last_4"
case message
case transactionType = "transaction_type"
case created
}
}
/// `PaymentModel` used to represent a [Forage Payment object](https://docs.joinforage.app/reference/create-a-payment)
public struct PaymentModel: Codable {
public let paymentRef: String
public let merchantID: String
public let fundingType: String
public let amount: String
public let description: String
public let metadata: [String: String]
public let paymentMethodRef: String
public let deliveryAddress: ForageAddress
public let isDelivery: Bool
public let createdDate: String
public let updatedDate: String
public let status: String
public let successDate: String?
public let lastProcessingError: String?
public let receipt: Receipt?
public let platformFee: String?
public let merchantFixedSettlement: String?
public let platformFixedSettlement: String?
public let refunds: [String]
let error: VaultError?
private enum CodingKeys: String, CodingKey {
case paymentRef = "ref"
case merchantID = "merchant"
case fundingType = "funding_type"
case amount
case description
case metadata
case paymentMethodRef = "payment_method"
case deliveryAddress = "delivery_address"
case isDelivery = "is_delivery"
case createdDate = "created"
case updatedDate = "updated"
case status
case lastProcessingError = "last_processing_error"
case successDate = "success_date"
case receipt
case platformFee = "platform_fee"
case merchantFixedSettlement = "merchant_fixed_settlement"
case platformFixedSettlement = "platform_fixed_settlement"
case refunds
case error
}
}
/// When using the deferred capture flow
/// the Payment may not have some `null` properties
/// (`amount`, `delivery_address`, `is_delivery`, ...) until the
/// payment is updated and captured on the server-side.
/// In turn, we only grab what we need from `ThinPaymentModel` for
/// intermediate internal SDK requests to `GET /payments/`
struct ThinPaymentModel: Codable {
let paymentMethodRef: String
private enum CodingKeys: String, CodingKey {
case paymentMethodRef = "payment_method"
}
}