Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 31 additions & 30 deletions Sources/BraintreeVenmo/BTVenmoLineItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
15 changes: 10 additions & 5 deletions UnitTests/BraintreeVenmoTests/BTVenmoClient_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion V7_MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading