-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DO NOT REVIEW] Merge RBA Metadata
feature branch
#1423
Open
richherrera
wants to merge
14
commits into
main
Choose a base branch
from
rba-metadata-feature
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f031476
Fix Constraints Error in `PayPalWebCheckoutViewController` (#1342)
jaxdesmarais 50982c3
Recurring Billing Agreement (RBA) Metadata Support (#1343)
scannillo b39cb34
Recurring Billing Agreement Add total amount. (#1373)
warmkesselj fcfaf8b
Rba updated demo values (#1377)
warmkesselj cce9098
Merge branch 'main' into rba-metadata-feature
warmkesselj 0019fc8
Updated Changelog
warmkesselj e9ffaa5
Rba metadata feature tokenization key (#1393)
warmkesselj 279a31a
Merge branch 'main' into rba-metadata-feature
jaxdesmarais 777967a
Merge branch 'main' into rba-metadata-feature
jaxdesmarais 5b5803f
Merge branch 'main' into rba-metadata-feature
jaxdesmarais 22a4495
make price optional; default all optional inits to nil; update docstr…
jaxdesmarais 386d5bd
Merge branch 'main' into rba-metadata-feature
jaxdesmarais 706bdb6
[QL] Update `interval` and `intervalCount` (#1417)
jaxdesmarais 5b8d324
Merge branch 'main' into rba-metadata-feature
richherrera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingCycle.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import Foundation | ||
|
||
/// PayPal recurring billing cycle details. | ||
public struct BTPayPalBillingCycle { | ||
|
||
// MARK: - Public Types | ||
|
||
/// The interval at which the payment is charged or billed. | ||
public enum BillingInterval: String { | ||
case day = "DAY" | ||
case week = "WEEK" | ||
case month = "MONTH" | ||
case year = "YEAR" | ||
} | ||
|
||
// MARK: - Private Properties | ||
|
||
private let isTrial: Bool | ||
private let numberOfExecutions: Int | ||
private let interval: BillingInterval? | ||
private let intervalCount: Int? | ||
private let sequence: Int? | ||
private let startDate: String? | ||
private let pricing: BTPayPalBillingPricing? | ||
|
||
// MARK: - Initializer | ||
|
||
/// Initialize a `BTPayPalBillingCycle` object. | ||
/// - Parameters: | ||
/// - isTrial: Required: The tenure type of the billing cycle. In case of a plan having trial cycle, only 2 trial cycles are allowed per plan. | ||
/// - numberOfExecutions: Required: 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). | ||
/// - interval: Optional: The number of intervals after which a subscriber is charged or billed. | ||
/// - intervalCount: Optional: 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}. | ||
/// - sequence: Optional: 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. | ||
/// - startDate: Optional: The date and time when the billing cycle starts, in Internet date and time format `YYYY-MM-DD`. If not provided the billing cycle starts at the time of checkout. If provided and the merchant wants the billing cycle to start at the time of checkout, provide the current time. Otherwise the `startDate` can be in future. | ||
/// - pricing: Optional: The active pricing scheme for this billing cycle. Required if `trial` is false. Optional if `trial` is true. | ||
public init( | ||
isTrial: Bool, | ||
numberOfExecutions: Int, | ||
interval: BillingInterval? = nil, | ||
intervalCount: Int? = nil, | ||
sequence: Int? = nil, | ||
startDate: String? = nil, | ||
pricing: BTPayPalBillingPricing? = nil | ||
) { | ||
self.isTrial = isTrial | ||
self.numberOfExecutions = numberOfExecutions | ||
self.interval = interval | ||
self.intervalCount = intervalCount | ||
self.sequence = sequence | ||
self.startDate = startDate | ||
self.pricing = pricing | ||
} | ||
|
||
// MARK: - Internal Methods | ||
|
||
func parameters() -> [String: Any] { | ||
var parameters: [String: Any] = [ | ||
"number_of_executions": numberOfExecutions, | ||
"trial": isTrial | ||
] | ||
|
||
if let interval { | ||
parameters["billing_frequency_unit"] = interval.rawValue | ||
} | ||
|
||
if let intervalCount { | ||
parameters["billing_frequency"] = intervalCount | ||
} | ||
|
||
if let sequence { | ||
parameters["sequence"] = sequence | ||
} | ||
|
||
if let startDate { | ||
parameters["start_date"] = startDate | ||
} | ||
|
||
if let pricing { | ||
parameters["pricing_scheme"] = pricing.parameters() | ||
} | ||
|
||
return parameters | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
Sources/BraintreePayPal/RecurringBillingMetadata/BTPayPalBillingPricing.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Foundation | ||
|
||
/// PayPal Recurring Billing Agreement pricing details. | ||
public struct BTPayPalBillingPricing { | ||
|
||
// MARK: - Public Types | ||
|
||
/// Recurring Billing Agreement pricing model types. | ||
public enum PricingModel: String { | ||
case fixed = "FIXED" | ||
case variable = "VARIABLE" | ||
case autoReload = "AUTO_RELOAD" | ||
} | ||
|
||
// MARK: - Private Properties | ||
|
||
private let pricingModel: PricingModel | ||
private let amount: String? | ||
private let reloadThresholdAmount: String? | ||
|
||
// MARK: - Initializer | ||
|
||
/// Initialize a `BTPayPalBillingPricing` object. | ||
/// - Parameters: | ||
/// - pricingModel: Required: The pricing model associated with the billing agreement. | ||
/// - amount: Optional: Price. The amount to charge for the subscription, recurring, UCOF or installments. | ||
/// - reloadThresholdAmount: Optional: The reload trigger threshold condition amount when the customer is charged. | ||
public init(pricingModel: PricingModel, amount: String? = nil, reloadThresholdAmount: String? = nil) { | ||
self.pricingModel = pricingModel | ||
self.amount = amount | ||
self.reloadThresholdAmount = reloadThresholdAmount | ||
} | ||
|
||
// MARK: - Internal Methods | ||
|
||
func parameters() -> [String: Any] { | ||
var parameters: [String: Any] = [ | ||
"pricing_model": pricingModel.rawValue | ||
] | ||
|
||
if let amount { | ||
parameters["price"] = amount | ||
} | ||
|
||
if let reloadThresholdAmount { | ||
parameters["reload_threshold_amount"] = reloadThresholdAmount | ||
} | ||
|
||
return parameters | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to revert this. ModXO is live
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker for this merge though!