diff --git a/Sources/BraintreePayPal/BTPayPalVaultRequest.swift b/Sources/BraintreePayPal/BTPayPalVaultRequest.swift index c02443a615..5da9d3dfab 100644 --- a/Sources/BraintreePayPal/BTPayPalVaultRequest.swift +++ b/Sources/BraintreePayPal/BTPayPalVaultRequest.swift @@ -47,7 +47,7 @@ import BraintreeCore /// - Parameters: /// - offerCredit: Optional: Offers PayPal Credit if the customer qualifies. Defaults to `false`. /// - recurringBillingDetails: Optional: Recurring billing product details. - /// - recurringBillingPlanType: Optional: Recurring billing plan type. + /// - recurringBillingPlanType: Optional: Recurring billing plan type, or charge pattern. /// - userAuthenticationEmail: Optional: User email to initiate a quicker authentication flow in cases where the user has a PayPal Account with the same email. public init( offerCredit: Bool = false, diff --git a/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingCycle.swift b/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingCycle.swift index 9dc958768a..a0c0e3b1c9 100644 --- a/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingCycle.swift +++ b/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingCycle.swift @@ -4,7 +4,7 @@ import Foundation public struct BTPayPalBillingCycle { // MARK: - Public Types - + /// The interval at which the payment is charged or billed. public enum BillingInterval: String { case day = "DAY" @@ -16,24 +16,18 @@ public struct BTPayPalBillingCycle { // MARK: - Private Properties private let interval: BillingInterval - private let intervalCount: Int - private let numberOfExecutions: Int - private let sequence: Int? - private let startDate: String? - private let isTrial: Bool - private let pricing: BTPayPalBillingPricing? // MARK: - Initializer /// Initialize a `BTPayPalBillingCycle` object. /// - Parameters: - /// - intervalCount: The number of intervals after which a subscriber is charged or billed. + /// - interval: The number of intervals after which a subscriber is charged or billed. /// - intervalCount: The number of times this billing cycle gets executed. For example, if the `intervalCount` is DAY with an `intervalCount` of 2, the subscription is billed once every two days. Maximum values {DAY -> 365}, {WEEK, 52}, {MONTH, 12}, {YEAR, 1}. /// - numberOfExecutions: The number of times this billing cycle gets executed. Trial billing cycles can only be executed a finite number of times (value between 1 and 999). Regular billing cycles can be executed infinite times (value of 0) or a finite number of times (value between 1 and 999). /// - sequence: The sequence of the billing cycle. Used to identify unique billing cycles. For example, sequence 1 could be a 3 month trial period, and sequence 2 could be a longer term full rater cycle. Max value 100. All billing cycles should have unique sequence values. @@ -61,12 +55,12 @@ public struct BTPayPalBillingCycle { // MARK: - Internal Methods func parameters() -> [String: Any] { - var parameters: [String: Any] = [:] - - parameters["billing_frequency"] = intervalCount - parameters["billing_frequency_unit"] = interval.rawValue - parameters["number_of_executions"] = numberOfExecutions - parameters["trial"] = isTrial + var parameters: [String: Any] = [ + "billing_frequency": intervalCount, + "billing_frequency_unit": interval.rawValue, + "number_of_executions": numberOfExecutions, + "trial": isTrial + ] if let sequence { parameters["sequence"] = sequence diff --git a/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingPricing.swift b/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingPricing.swift index ef0ebb0f64..8df85ff1b5 100644 --- a/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingPricing.swift +++ b/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingPricing.swift @@ -15,9 +15,7 @@ public struct BTPayPalBillingPricing { // MARK: - Private Properties private let pricingModel: PricingModel - private let amount: String - private let reloadThresholdAmount: String? // MARK: - Initializer @@ -36,10 +34,10 @@ public struct BTPayPalBillingPricing { // MARK: - Internal Methods func parameters() -> [String: Any] { - var parameters: [String: Any] = [:] - - parameters["pricing_model"] = pricingModel.rawValue - parameters["price"] = amount + var parameters: [String: Any] = [ + "pricing_model": pricingModel.rawValue, + "price": amount + ] if let reloadThresholdAmount { parameters["reload_threshold_amount"] = reloadThresholdAmount diff --git a/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalRecurringBillingDetails.swift b/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalRecurringBillingDetails.swift index 4b491e512f..ba15e88a05 100644 --- a/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalRecurringBillingDetails.swift +++ b/Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalRecurringBillingDetails.swift @@ -6,21 +6,13 @@ public struct BTPayPalRecurringBillingDetails { // MARK: - Private Properties private let billingCycles: [BTPayPalBillingCycle] - private let currencyISOCode: String - private let productName: String? - private let productDescription: String? - private let productQuantity: Int? - private let oneTimeFeeAmount: String? - private let shippingAmount: String? - private let productAmount: String? - private let taxAmount: String? // MARK: - Initializer @@ -61,10 +53,10 @@ public struct BTPayPalRecurringBillingDetails { // MARK: - Internal Methods func parameters() -> [String: Any] { - var parameters: [String: Any] = [:] - - parameters["currency_iso_code"] = currencyISOCode - parameters["billing_cycles"] = billingCycles.map({ $0.parameters() }) + var parameters: [String: Any] = [ + "currency_iso_code": currencyISOCode, + "billing_cycles": billingCycles.map { $0.parameters() } + ] if let productName { parameters["name"] = productName