diff --git a/CHANGELOG.md b/CHANGELOG.md index 49b4fc508..9056c29be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## unreleased * BraintreePayPal * Update `BTPayPalLineItem` to make all properties accessible on the initializer only vs via the dot syntax. +* BraintreeVenmo + * Update `BTVenmoLineItem` to make all properties accessible on the initializer only vs via the dot syntax. ## 6.39.0 (2025-10-01) * BraintreeCore diff --git a/Sources/BraintreeVenmo/BTVenmoLineItem.swift b/Sources/BraintreeVenmo/BTVenmoLineItem.swift index 10f589140..9ec4bcf91 100644 --- a/Sources/BraintreeVenmo/BTVenmoLineItem.swift +++ b/Sources/BraintreeVenmo/BTVenmoLineItem.swift @@ -12,45 +12,46 @@ import Foundation /// A Venmo line item to be displayed in the Venmo Paysheet. @objcMembers public class BTVenmoLineItem: NSObject { - // MARK: - Public Properties + // MARK: - Internal Properties - /// Number of units of the item purchased. This value must be a whole number and can't be negative or zero. - public var quantity: Int - - /// Per-unit price of the item. Can include up to 2 decimal places. This value can't be negative or zero. - public var unitAmount: String - - /// Item name. Maximum 127 characters. - public var name: String - - /// Indicates whether the line item is a debit (sale) or credit (refund) to the customer. - public var kind: BTVenmoLineItemKind - - /// Optional: Per-unit tax price of the item. Can include up to 2 decimal places. This value can't be negative or zero. - public var unitTaxAmount: String? - - /// Optional: Item description. Maximum 127 characters. - public var itemDescription: String? - - /// Optional: Product or UPC code for the item. Maximum 127 characters. - public var productCode: String? - - /// Optional: The URL to product information. - public var url: URL? + let quantity: Int + let unitAmount: String + let name: String + let kind: BTVenmoLineItemKind + let unitTaxAmount: String? + let itemDescription: String? + let productCode: String? + let url: URL? // MARK: - Public Initializer /// Initialize a BTVenmoLineItem /// - Parameters: - /// - quantity: Number of units of the item purchased. Can include up to 4 decimal places. This value can't be negative or zero. - /// - unitAmount: Per-unit price of the item. Can include up to 4 decimal places. This value can't be negative or zero. - /// - name: Item name. Maximum 127 characters. - /// - kind: Indicates whether the line item is a debit (sale) or credit (refund) to the customer. - @objc(initWithQuantity:unitAmount:name:kind:) - public init(quantity: Int, unitAmount: String, name: String, kind: BTVenmoLineItemKind) { + /// - quantity: Required. Number of units of the item purchased. Can include up to 4 decimal places. This value must be a whole number and can't be negative or zero. + /// - unitAmount: Required. Per-unit price of the item. Can include up to 2 decimal places. This value can't be negative or zero. + /// - name: Required. Item name. Maximum 127 characters. + /// - kind: Required. Indicates whether the line item is a debit (sale) or credit (refund) to the customer. + /// - unitTaxAmount: Optional: Per-unit tax price of the item. Can include up to 2 decimal places. This value can't be negative or zero. + /// - itemDescription: Optional: Item description. Maximum 127 characters. + /// - productCode: Optional: Product or UPC code for the item. Maximum 127 characters. + /// - url: Optional: The URL to product information. + public init( + quantity: Int, + unitAmount: String, + name: String, + kind: BTVenmoLineItemKind, + unitTaxAmount: String? = nil, + itemDescription: String? = nil, + productCode: String? = nil, + url: URL? = nil + ) { self.quantity = quantity self.unitAmount = unitAmount self.name = name self.kind = kind + self.unitTaxAmount = unitTaxAmount + self.itemDescription = itemDescription + self.productCode = productCode + self.url = url } } diff --git a/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift b/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift index bba92c92f..1852a78c5 100644 --- a/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift +++ b/UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift @@ -179,11 +179,16 @@ class BTVenmoClient_Tests: XCTestCase { venmoRequest.discountAmount = "9" venmoRequest.taxAmount = "9" venmoRequest.shippingAmount = "9" - let lineItem = BTVenmoLineItem(quantity: 1, unitAmount: "9", name: "name", kind: .debit) - lineItem.unitTaxAmount = "1" - lineItem.itemDescription = "some-description" - lineItem.productCode = "some-product-code" - lineItem.url = URL(string: "some.fake.url")! + let lineItem = BTVenmoLineItem( + quantity: 1, + unitAmount: "9", + name: "name", + kind: .debit, + unitTaxAmount: "1", + itemDescription: "some-description", + productCode: "some-product-code", + url: URL(string: "some.fake.url")! + ) venmoRequest.lineItems = [lineItem] let fakeApplication = FakeApplication() venmoClient.application = fakeApplication diff --git a/V7_MIGRATION.md b/V7_MIGRATION.md index 2fccc1ddc..2fe235d85 100644 --- a/V7_MIGRATION.md +++ b/V7_MIGRATION.md @@ -34,7 +34,7 @@ Update initializer for `BTCardClient`: ``` ## Venmo -All properties within `BTVenmoRequest` can only be accessed on the initializer vs via the dot syntax. +All properties within `BTVenmoRequest` and `BTVenmoLineItem` can only be accessed on the initializer vs via the dot syntax. Remove the `fallbackToWeb` boolean parameter from `BTVenmoRequest`. If a Buyer has the Venmo app installed and taps on "Pay with Venmo", they will automatically be switched to the Venmo app. If the Venmo app isn't installed, the Buyer will fallback to their default web browser to checkout.