Skip to content

Commit

Permalink
Merge pull request #9 from skelpo/develop
Browse files Browse the repository at this point in the history
Format Money Values with Trailing 0 Characters
  • Loading branch information
calebkleveter committed Jan 23, 2019
2 parents 0680ad5 + 8477ad5 commit 54e8cf3
Show file tree
Hide file tree
Showing 33 changed files with 98 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Sources/PayPal/Models/Money/Amount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ public struct AmountType<Key>: Content, Amount, Equatable where Key: AmountCodin
}

try container.encode(self.currency, forKey: .currency)
try container.encode(String(describing: rounded), forKey: .value)
try container.encode(self.currency.string(for: self.value), forKey: .value)
}
}
36 changes: 36 additions & 0 deletions Sources/PayPal/Models/Money/Currency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,42 @@ public struct Currency: Content, Equatable {
try container.encode(self.code)
}

/// Converts a decimal number to a string with the expected number of decimal places.
///
/// let decimal = Decimal(string: "85.80")! // 85.8
/// Currency.usd.string(for: decimal) // "85.80"
///
/// - Parameter decimal: The decimal to convert to a string
///
/// - Returns: The string representation of the decimal.
func string(for decimal: Decimal) -> String {
var rounded = decimal

if let exponent = self.e {
var value = decimal
NSDecimalRound(&rounded, &value, exponent, .bankers)
} else {
return rounded.description
}

if -rounded.exponent != self.e {
var string = rounded.description
let oCount: Int

if let i = string.firstIndex(of: ".") {
oCount = string[string.index(after: i)...].count
} else {
oCount = self.e ?? 0
string.append(".")
}

string.append(String(repeating: "0", count: oCount))
return string
} else {
return rounded.description
}
}


// MARK: - Known Currencies

Expand Down
2 changes: 1 addition & 1 deletion Sources/PayPal/Models/Money/DetailedAmount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public struct DetailedAmount: Content, Equatable {
/// See [`Encodable.encode(to:)`](https://developer.apple.com/documentation/swift/encodable/2893603-encode).
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(String(describing: self.amount.value), forKey: .total)
try container.encode(self.amount.currency, forKey: .currency)
try container.encode(self.amount.currency.string(for: self.amount.value), forKey: .total)
try container.encodeIfPresent(self.details, forKey: .details)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/AcceptDisputeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class AcceptDisputeTests: XCTestCase {
let generated = try String(data: encoder.encode(body), encoding: .utf8)!
let json =
"{\"accept_claim_reason\":\"COMPANY_POLICY\",\"invoice_id\":\"3EC9D031-0DBF-446F-ABC0-31B4A6E0D2B5\"," +
"\"note\":\"Refund to customer\",\"refund_amount\":{\"value\":\"55.5\",\"currency_code\":\"USD\"}}"
"\"note\":\"Refund to customer\",\"refund_amount\":{\"value\":\"55.50\",\"currency_code\":\"USD\"}}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
6 changes: 3 additions & 3 deletions Tests/ModelTests/BillingPlanListTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ final class BillingPlanListTests: XCTestCase {
])
let generated = try String(data: encoder.encode(list), encoding: .utf8)!
let json =
"{\"plans\":[{\"payment_definitions\":[{\"frequency\":\"MONTH\",\"amount\":{\"currency\":\"USD\",\"value\":\"10\"},\"frequency_interval\":\"1\"," +
"\"cycles\":\"0\",\"name\":\"Water Charge\",\"type\":\"REGULAR\"}],\"name\":\"Monthly Water\",\"type\":\"INFINITE\"," +
"\"description\":\"Your water payment\"}],\"total_items\":\"1\"}"
"{\"plans\":[{\"payment_definitions\":[{\"frequency\":\"MONTH\",\"amount\":{\"currency\":\"USD\",\"value\":\"10.00\"}," +
"\"frequency_interval\":\"1\",\"cycles\":\"0\",\"name\":\"Water Charge\",\"type\":\"REGULAR\"}],\"name\":\"Monthly Water\"," +
"\"type\":\"INFINITE\",\"description\":\"Your water payment\"}],\"total_items\":\"1\"}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/BillingPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ final class BillingPlanTests: XCTestCase {
)
let generated = try String(data: encoder.encode(plan), encoding: .utf8)!
let json =
"{\"payment_definitions\":[{\"frequency\":\"MONTH\",\"amount\":{\"currency\":\"USD\",\"value\":\"10\"},\"frequency_interval\":\"1\"," +
"{\"payment_definitions\":[{\"frequency\":\"MONTH\",\"amount\":{\"currency\":\"USD\",\"value\":\"10.00\"},\"frequency_interval\":\"1\"," +
"\"cycles\":\"0\",\"name\":\"Water Charge\",\"type\":\"REGULAR\"}],\"name\":\"Monthly Water\",\"type\":\"INFINITE\"," +
"\"description\":\"Your water payment\"}"

Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/CaptureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class CaptureTests: XCTestCase {
transaction: CurrencyAmount(currency: .usd, value: 1.00)
)
let generated = try String(data: encoder.encode(capture), encoding: .utf8)
let json = "{\"amount\":{\"total\":\"10\",\"currency\":\"USD\"},\"transaction_fee\":{\"currency\":\"USD\",\"value\":\"1\"}}"
let json = "{\"amount\":{\"currency\":\"USD\",\"total\":\"10.00\"},\"transaction_fee\":{\"currency\":\"USD\",\"value\":\"1.00\"}}"

XCTAssertEqual(generated, json)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/DetailTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class DetailTests: XCTestCase {
let json =
"{\"final_payment_date\":\"\(later)\",\"last_payment_date\":\"\(now)\",\"failed_payment_count\":\"5\"," +
"\"cycles_remaining\":\"30\",\"cycles_completed\":\"45\",\"last_payment_amount\":{\"value\":\"19.97\",\"currency_code\":\"USD\"}," +
"\"outstanding_balance\":{\"value\":\"599\",\"currency_code\":\"USD\"},\"next_billing_date\":\"\(oneYear)\"}"
"\"outstanding_balance\":{\"value\":\"599.00\",\"currency_code\":\"USD\"},\"next_billing_date\":\"\(oneYear)\"}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/DetailedAmountTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class DetailedAmountTests: XCTestCase {
let encoder = JSONEncoder()
let amount = DetailedAmount(currency: .usd, total: 172.89, details: .init(subtotal: 134.56))
let generated = try String(data: encoder.encode(amount), encoding: .utf8)
let json = "{\"total\":\"172.89\",\"currency\":\"USD\",\"details\":{\"subtotal\":\"134.56\"}}"
let json = "{\"currency\":\"USD\",\"total\":\"172.89\",\"details\":{\"subtotal\":\"134.56\"}}"

XCTAssertEqual(generated, json)
}
Expand Down
3 changes: 2 additions & 1 deletion Tests/ModelTests/DisputeResolutionOffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ final class DisputeResolutionOfferTests: XCTestCase {
invoiceID: nil
)
let generated = try String(data: encoder.encode(offer), encoding: .utf8)!
let json = "{\"offer_type\":\"REFUND_WITH_REPLACEMENT\",\"offer_amount\":{\"value\":\"23\",\"currency_code\":\"USD\"},\"note\":\"Notable note.\"}"
let json =
"{\"offer_type\":\"REFUND_WITH_REPLACEMENT\",\"offer_amount\":{\"value\":\"23.00\",\"currency_code\":\"USD\"},\"note\":\"Notable note.\"}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/InvoiceItemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ final class InvoiceItemTests: XCTestCase {
)
let generated = try String(data: encoder.encode(item), encoding: .utf8)!
let json =
"{\"quantity\":3,\"unit_price\":{\"currency\":\"USD\",\"value\":\"50\"},\"unit_of_measure\":\"QUANTITY\",\"name\":\"Widget\"," +
"{\"quantity\":3,\"unit_price\":{\"currency\":\"USD\",\"value\":\"50.00\"},\"unit_of_measure\":\"QUANTITY\",\"name\":\"Widget\"," +
"\"description\":\"Round and white, like a ping-pong ball\",\"date\":\"\(self.now.iso8601)\"}"

var index = 0
Expand Down
4 changes: 3 additions & 1 deletion Tests/ModelTests/InvoicePaymentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ final class InvoicePaymentTests: XCTestCase {
let encoder = JSONEncoder()
let payment = Invoice.Payment(method: .cash, amount: CurrencyAmount(currency: .usd, value: 20.00), date: self.now, note: "I got the payment by cash!")
let generated = try String(data: encoder.encode(payment), encoding: .utf8)!
let json = "{\"amount\":{\"currency\":\"USD\",\"value\":\"20\"},\"method\":\"CASH\",\"note\":\"I got the payment by cash!\",\"date\":\"\(self.now.iso8601)\"}"
let json =
"{\"amount\":{\"currency\":\"USD\",\"value\":\"20.00\"},\"method\":\"CASH\",\"note\":\"I got the payment by cash!\"," +
"\"date\":\"\(self.now.iso8601)\"}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/ModelTests/InvoiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ final class InvoiceTests: XCTestCase {
"{\"tax_calculated_after_discount\":true,\"invoice_date\":\"\(now.iso8601)\"," +
"\"logo_url\":\"https:\\/\\/vapor.codes\\/dist\\/e032390c38279fbdf18ebf0e763eb44f.png\"," +
"\"note\":\"Thanks for your donation!\",\"billing_info\":[],\"allow_partial_payment\":false,\"template_id\":\"PayPal system template\"," +
"\"minimum_amount_due\":{\"currency\":\"USD\",\"value\":\"1\"},\"merchant_info\":{\"email\":\"hello@vapor.codes\"" +
"\"minimum_amount_due\":{\"currency\":\"USD\",\"value\":\"1.00\"},\"merchant_info\":{\"email\":\"hello@vapor.codes\"" +
",\"last_name\":\"Nelson\",\"website\":\"https:\\/\\/vapor.codes\\/\",\"business_name\":\"Qutheory LLC.\",\"first_name\":\"Tanner\"}," +
"\"cc_info\":[{\"email\":\"collective@vapor.codes\"},{\"email\":\"donator@example.com\"}],\"payment_term\":{" +
"\"due_date\":\"\(self.dueStr)\",\"term_type\":\"DUE_ON_RECEIPT\"},\"custom\":{\"amount\":{\"currency\":\"USD\",\"value\":\"10\"}}," +
"\"due_date\":\"\(self.dueStr)\",\"term_type\":\"DUE_ON_RECEIPT\"},\"custom\":{\"amount\":{\"currency\":\"USD\",\"value\":\"10.00\"}}," +
"\"allow_tip\":true,\"reference\":\"PO number\",\"tax_inclusive\":true,\"merchant_memo\":\"Open Collective donation\"}"
print(json.count)
var index = 0
Expand Down
6 changes: 3 additions & 3 deletions Tests/ModelTests/MerchantPreferancesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ final class MerchantPreferancesTests: XCTestCase {

let generated = try String(data: encoder.encode(preferances), encoding: .utf8)!
let json =
"{\"max_fail_attempts\":\"0\",\"char_set\":\"UTF-8\",\"initial_fail_amount_action\":\"CONTINUE\",\"cancel_url\":\"https:\\/\\/example.com\\/agreements\"," +
"\"return_url\":\"https:\\/\\/example.com\\/agreements\\/latest\",\"setup_fee\":{\"value\":\"0\",\"currency_code\":\"USD\"}," +
"\"auto_bill_amount\":\"YES\"}"
"{\"max_fail_attempts\":\"0\",\"char_set\":\"UTF-8\",\"initial_fail_amount_action\":\"CONTINUE\"," +
"\"cancel_url\":\"https:\\/\\/example.com\\/agreements\",\"return_url\":\"https:\\/\\/example.com\\/agreements\\/latest\"," +
"\"setup_fee\":{\"value\":\"0.00\",\"currency_code\":\"USD\"},\"auto_bill_amount\":\"YES\"}"

// JSON is 434 characters long.
var index = 0
Expand Down
3 changes: 2 additions & 1 deletion Tests/ModelTests/MoneyRangeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ final class MoneyRangeTests: XCTestCase {
let encoder = JSONEncoder()
let range = MoneyRange(min: CurrencyCodeAmount(currency: .usd, value: 12.25), max: CurrencyCodeAmount(currency: .usd, value: 50.00))
let generated = try String(data: encoder.encode(range), encoding: .utf8)
let json = "{\"minimum_amount\":{\"value\":\"12.25\",\"currency_code\":\"USD\"},\"maximum_amount\":{\"value\":\"50\",\"currency_code\":\"USD\"}}"
let json =
"{\"minimum_amount\":{\"value\":\"12.25\",\"currency_code\":\"USD\"},\"maximum_amount\":{\"value\":\"50.00\",\"currency_code\":\"USD\"}}"

XCTAssertEqual(json, generated)
}
Expand Down
6 changes: 5 additions & 1 deletion Tests/ModelTests/MoneyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ final class MoneyTests: XCTestCase {
let xxx = try String(data: encoder.encode(CurrencyCodeAmount(currency: .xxx, value: 0)), encoding: .utf8)
let eur = try String(data: encoder.encode(CurrencyCodeAmount(currency: .eur, value: 4.5)), encoding: .utf8)

let usdO = try String(data: encoder.encode(CurrencyCodeAmount(currency: .usd, value: 0)), encoding: .utf8)

XCTAssertEqual(usd, "{\"value\":\"12.25\",\"currency_code\":\"USD\"}")
XCTAssertEqual(xxx, "{\"value\":\"0\",\"currency_code\":\"XXX\"}")
XCTAssertEqual(eur, "{\"value\":\"4.5\",\"currency_code\":\"EUR\"}")
XCTAssertEqual(eur, "{\"value\":\"4.50\",\"currency_code\":\"EUR\"}")

XCTAssertEqual(usdO, "{\"value\":\"0.00\",\"currency_code\":\"USD\"}")
}

func testDecoding()throws {
Expand Down
5 changes: 3 additions & 2 deletions Tests/ModelTests/OrderUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ final class OrderUnitTests: XCTestCase {
let generated = try String(data: encoder.encode(unit), encoding: .utf8)!
let json =
"{\"description\":\"Descript\",\"payment_summary\":{},\"payment_descriptor\":\"PayScript\"," +
"\"notify_url\":\"https:\\/\\/example.com\\/notify\",\"amount\":{\"total\":\"5\",\"currency\":\"USD\"}," +
"\"notify_url\":\"https:\\/\\/example.com\\/notify\",\"amount\":{\"currency\":\"USD\",\"total\":\"5.00\"}," +
"\"invoice_number\":\"B5382984-3B90-4BC4-9F7A-6A6AFA61AC25\",\"metadata\":{\"supplementary_data\":[]},\"payee\":{}," +
"\"reference_id\":\"C1C099F2-D7E7-4E19-BBBF-98DD11EA911A\",\"payment_linked_group\":1,\"shipping_address\":{\"country_code\":\"US\"," +
"\"line1\":\"1 Infinate Loop\",\"city\":\"Cupertino\",\"postal_code\":\"94024\"},\"custom\":\"C2B9FBFB-B97D-46E4-8553-522C6A25A2FC\"," +
"\"items\":[],\"shipping_method\":\"USPSParcel\",\"partner_fee_details\":{\"amount\":{\"currency\":\"USD\",\"value\":\"2.5\"},\"receiver\":{}}}"
"\"items\":[],\"shipping_method\":\"USPSParcel\",\"partner_fee_details\":{\"amount\":{\"currency\":\"USD\",\"value\":\"2.50\"}," +
"\"receiver\":{}}}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/PaymentDetailTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class PaymentDetailTests: XCTestCase {
let detail = PaymentDetail(date: self.now, method: .cash, note: "Hello World", amount: CurrencyAmount(currency: .usd, value: 4.50))
let generated = try String(data: encoder.encode(detail), encoding: .utf8)!
let json =
"{\"amount\":{\"currency\":\"USD\",\"value\":\"4.5\"},\"method\":\"CASH\",\"note\":\"Hello World\",\"date\":\"\(self.now.iso8601)\"}"
"{\"amount\":{\"currency\":\"USD\",\"value\":\"4.50\"},\"method\":\"CASH\",\"note\":\"Hello World\",\"date\":\"\(self.now.iso8601)\"}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/PaymentExecutorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class PaymentExecutorTests: XCTestCase {
let encoder = JSONEncoder()
let executor = Payment.Executor(payer: "payer", amounts: [DetailedAmount(currency: .usd, total: 10.00, details: nil)])
let generated = try String(data: encoder.encode(executor), encoding: .utf8)!
let json = "{\"payer_id\":\"payer\",\"transactions\":[{\"amount\":{\"total\":\"10\",\"currency\":\"USD\"}}]}"
let json = "{\"payer_id\":\"payer\",\"transactions\":[{\"amount\":{\"currency\":\"USD\",\"total\":\"10.00\"}}]}"

XCTAssertEqual(generated, json)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/PaymentRefundTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class PaymentRefundTests: XCTestCase {
invoice: .init("inv")
)
let generated = try String(data: encoder.encode(refund), encoding: .utf8)!
let json = "{\"amount\":{\"total\":\"10\",\"currency\":\"USD\"},\"reason\":\"reas\",\"description\":\"desc\",\"invoice_number\":\"inv\"}"
let json = "{\"amount\":{\"currency\":\"USD\",\"total\":\"10.00\"},\"reason\":\"reas\",\"description\":\"desc\",\"invoice_number\":\"inv\"}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/PaymentTransactionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ final class PaymentTransactionTests: XCTestCase {
)
let generated = try String(data: encoder.encode(transaction), encoding: .utf8)!
let json =
"{\"amount\":{\"total\":\"54.56\",\"currency\":\"USD\"},\"custom\":\"custom\",\"item_list\":{}," +
"{\"amount\":{\"currency\":\"USD\",\"total\":\"54.56\"},\"custom\":\"custom\",\"item_list\":{}," +
"\"notify_url\":\"https:\\/\\/example.com\\/notify\",\"payment_options\":{\"allowed_payment_method\":\"UNRESTRICTED\"}," +
"\"soft_descriptor\":\"22\",\"description\":\"Description\",\"invoice_number\":\"12-654-89\",\"payee\":{},\"note_to_payee\":\"noted\"}"

Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/RefundDetailTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class RefundDetailTests: XCTestCase {
let encoder = JSONEncoder()
let detail = RefundDetail(date: self.now, note: "Hello World", amount: CurrencyAmount(currency: .usd, value: 4.50))
let generated = try String(data: encoder.encode(detail), encoding: .utf8)!
let json = "{\"date\":\"\(self.now.iso8601)\",\"amount\":{\"currency\":\"USD\",\"value\":\"4.5\"},\"note\":\"Hello World\"}"
let json = "{\"date\":\"\(self.now.iso8601)\",\"amount\":{\"currency\":\"USD\",\"value\":\"4.50\"},\"note\":\"Hello World\"}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ModelTests/RefundTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class RefundTests: XCTestCase {
let encoder = JSONEncoder()
let refund = Refund(amount: DetailedAmount(currency: .usd, total: 10.00, details: nil))
let generated = try String(data: encoder.encode(refund), encoding: .utf8)!
let json = "{\"amount\":{\"total\":\"10\",\"currency\":\"USD\"}}"
let json = "{\"amount\":{\"currency\":\"USD\",\"total\":\"10.00\"}}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
6 changes: 5 additions & 1 deletion Tests/ModelTests/RelatedResourceAuthorizationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ final class RelatedResourceAuthorizationTests: XCTestCase {
)
let generated = try String(data: encoder.encode(auth), encoding: .utf8)!

let json = "{\"amount\":{\"total\":\"5896\",\"currency\":\"USD\"},\"fmf_details\":{\"filter_id\":\"BILLING_OR_SHIPPING_ADDRESS_MISMATCH\",\"name\":\"Name\",\"description\":\"Desc.\",\"filter_type\":\"DENY\"},\"processor_response\":{\"avs_code\":\"e\",\"response_code\":\"6399\",\"advice_code\":\"01_NEW_ACCOUNT_INFORMATION\",\"cvv_code\":\"h\",\"eci_submitted\":\"152823\",\"vpas\":\"stat\"}}"
let json =
"{\"amount\":{\"currency\":\"USD\",\"total\":\"5896.00\"},\"fmf_details\":{\"filter_id\":\"BILLING_OR_SHIPPING_ADDRESS_MISMATCH\"," +
"\"name\":\"Name\",\"description\":\"Desc.\",\"filter_type\":\"DENY\"},\"processor_response\":{\"avs_code\":\"e\"," +
"\"response_code\":\"6399\",\"advice_code\":\"01_NEW_ACCOUNT_INFORMATION\",\"cvv_code\":\"h\",\"eci_submitted\":\"152823\"," +
"\"vpas\":\"stat\"}}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
4 changes: 3 additions & 1 deletion Tests/ModelTests/RelatedResourceCaptureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ final class RelatedResourceCaptureTests: XCTestCase {
)
let generated = try String(data: encoder.encode(capture), encoding: .utf8)!

let json = "{\"amount\":{\"total\":\"67.23\",\"currency\":\"USD\"},\"transaction_fee\":{\"currency\":\"USD\",\"value\":\"2.71\"},\"note_to_payer\":\"Notable text\",\"is_final_capture\":false,\"invoice_number\":\"242841E3-7ADE-4C5C-AC88-78103E2132F2\"}"
let json =
"{\"amount\":{\"currency\":\"USD\",\"total\":\"67.23\"},\"transaction_fee\":{\"currency\":\"USD\",\"value\":\"2.71\"}," +
"\"note_to_payer\":\"Notable text\",\"is_final_capture\":false,\"invoice_number\":\"242841E3-7ADE-4C5C-AC88-78103E2132F2\"}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down
4 changes: 3 additions & 1 deletion Tests/ModelTests/RelatedResourceOrderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ final class RelatedResourceOrderTests: XCTestCase {
)
let generated = try String(data: encoder.encode(order), encoding: .utf8)!

let json = "{\"amount\":{\"total\":\"645.12\",\"currency\":\"USD\"},\"fmf_details\":{\"filter_id\":\"MAXIMUM_TRANSACTION_AMOUNT\",\"filter_type\":\"ACCEPT\"}}"
let json =
"{\"amount\":{\"currency\":\"USD\",\"total\":\"645.12\"},\"fmf_details\":{\"filter_id\":\"MAXIMUM_TRANSACTION_AMOUNT\"," +
"\"filter_type\":\"ACCEPT\"}}"

var index = 0
for (jsonChar, genChar) in zip(json, generated) {
Expand Down

0 comments on commit 54e8cf3

Please sign in to comment.