Skip to content
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

[V7] Add Encodable protocol for PayPal Vault #1492

Merged
merged 55 commits into from
Jan 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d53299c
Add file with paypal request properties
richherrera Dec 30, 2024
cf7ad1e
Add var to BTConfiguration extension
richherrera Dec 30, 2024
964d7e8
Add country iso code var
richherrera Dec 30, 2024
7460d9d
Add checkout properties to POST body model
richherrera Dec 30, 2024
0a3dbf4
Disable nesting lint
richherrera Jan 2, 2025
f5952e6
Address some lints
richherrera Jan 2, 2025
3168bf5
Add dot
richherrera Jan 2, 2025
623c681
Rename struct
richherrera Jan 2, 2025
8006e18
Add Encodable protocol to BTPostalAddress class
richherrera Jan 3, 2025
d1c1cd1
Add Encodable protocol to BTPayPalBillingCycle struct
richherrera Jan 3, 2025
14390fd
Add Encodable protocol to BTPayPalBillingPricing struct
richherrera Jan 3, 2025
06fd294
Add Encodable protocol to BTPayPalRecurringBillingDetails struct
richherrera Jan 3, 2025
6f0daad
Add Encodable protocol to BTPayPalRecurringBillingPlanType enum
richherrera Jan 3, 2025
428b0a4
Add PayPalVaultPOSTBody file
richherrera Jan 3, 2025
2b072da
Add encodable properties
richherrera Jan 3, 2025
09d964d
Add Encodable protocol to BTPayPalLineItem class
richherrera Jan 6, 2025
c7e226e
Merge branch 'paypal-checkout-encodable' into paypal-vault-encodable
richherrera Jan 6, 2025
9543469
Use encodable for BTLineItems
richherrera Jan 6, 2025
27c0a44
Add error to catch encodable exception
richherrera Jan 6, 2025
4a6e7d8
Use encoded objects
richherrera Jan 6, 2025
42af3f7
Use Configuration.isPayPalEnabled instead of json format
richherrera Jan 6, 2025
2200e5c
Add PayPalExperienceProfile as a shared object to be use for Checkout…
richherrera Jan 6, 2025
1553b22
Add PayPalRequest protocol, BTPayPalRequest conforms PayPalRequest
richherrera Jan 9, 2025
f9c90ec
BTPayPalCheckoutRequest conforms PayPalRequest
richherrera Jan 9, 2025
abe2c7e
Move lineItems parameters on init
richherrera Jan 9, 2025
b0cea93
BTPayPalVaultRequest conforms PayPalRequest
richherrera Jan 9, 2025
4a3b49c
Update BTPayPalRequest UTs
richherrera Jan 9, 2025
49886c7
Update BTPayPalClient to use an interface instead of concrete class
richherrera Jan 9, 2025
47727f4
Merge branch 'v7' into paypal-checkout-encodable
richherrera Jan 9, 2025
3c1701e
Disable cyclomatic_complexity lint
richherrera Jan 9, 2025
b6ce34b
Disable function_body_length lint
richherrera Jan 9, 2025
50c23ac
Merge branch 'paypal-checkout-encodable' into paypal-vault-encodable
richherrera Jan 9, 2025
8e12bf8
Address PR comments
richherrera Jan 9, 2025
8b18aeb
Remove parameters method
richherrera Jan 9, 2025
b903ba2
Remove BTPayPalRequest class
richherrera Jan 9, 2025
44d61f4
Add PayPalConstanst enum
richherrera Jan 9, 2025
7f0a207
Remove unnecessary error
richherrera Jan 9, 2025
39ca19f
Move encoded method
richherrera Jan 9, 2025
169ff3a
Update UTs
richherrera Jan 9, 2025
d6284ec
Move BTPayPalRequest UTs to BTPayPalCheckout and BTPayPalVault requests
richherrera Jan 10, 2025
7601a15
Delete BTPayPalRequest UTs
richherrera Jan 10, 2025
e446f03
Use if let syntax
richherrera Jan 10, 2025
ac6f13e
Address PR comments
richherrera Jan 10, 2025
e478437
Remove BTLineItems custom encode method
richherrera Jan 13, 2025
6dfb488
Revert unnecessary changes
richherrera Jan 13, 2025
5b86155
Merge branch 'paypal-checkout-encodable' into paypal-vault-encodable
richherrera Jan 13, 2025
f90356b
Rename PayPalRequest protocol to BTPayPalRequest
richherrera Jan 13, 2025
df8eba1
Remove unnecessary parameters methods
richherrera Jan 13, 2025
3fa9a0d
Remove unnecessary parameters methods
richherrera Jan 13, 2025
f3ccfe4
Add quotation marks
richherrera Jan 21, 2025
876599d
Add docstrings and move the enums to their own file.
richherrera Jan 21, 2025
e56a718
Merge branch 'paypal-checkout-encodable' into paypal-vault-encodable
richherrera Jan 21, 2025
09357ff
Address PR comments
richherrera Jan 21, 2025
5cf34f5
Merge branch 'v7' into paypal-vault-encodable
richherrera Jan 21, 2025
362f9bb
Update paypalrequest property
richherrera Jan 21, 2025
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
Prev Previous commit
Next Next commit
Add docstrings and move the enums to their own file.
richherrera committed Jan 21, 2025
commit 876599dc2b2ea9a8095389d900a1864e98a1d409
10 changes: 9 additions & 1 deletion Braintree.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@
428F976626727333001042E1 /* BTMockOpenURLContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 428F976526727333001042E1 /* BTMockOpenURLContext.m */; };
42FC218B25CDE0290047C49A /* BTPayPalRequest_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42FC218A25CDE0290047C49A /* BTPayPalRequest_Tests.swift */; };
42FC237125CE0E110047C49A /* BTPayPalCheckoutRequest_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42FC237025CE0E110047C49A /* BTPayPalCheckoutRequest_Tests.swift */; };
451508362D400C050071E385 /* BTPayPalPaymentType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451508352D400C050071E385 /* BTPayPalPaymentType.swift */; };
451508382D400C400071E385 /* BTPayPalRequestLandingPageType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451508372D400C400071E385 /* BTPayPalRequestLandingPageType.swift */; };
45227FC52C330FDE00A15018 /* MockURLSessionTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45227FC32C330FDE00A15018 /* MockURLSessionTask.swift */; };
45227FC72C33104100A15018 /* MockBTHTTPNetworkTiming.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45227FC62C33104100A15018 /* MockBTHTTPNetworkTiming.swift */; };
454722B02CF0DA34000DCF4E /* LocalPaymentPOSTBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 454722AF2CF0DA27000DCF4E /* LocalPaymentPOSTBody.swift */; };
@@ -719,6 +721,8 @@
42F75E5A24D48138007DC5E7 /* BTThreeDSecureClient_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTThreeDSecureClient_Tests.swift; sourceTree = "<group>"; };
42FC218A25CDE0290047C49A /* BTPayPalRequest_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTPayPalRequest_Tests.swift; sourceTree = "<group>"; };
42FC237025CE0E110047C49A /* BTPayPalCheckoutRequest_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTPayPalCheckoutRequest_Tests.swift; sourceTree = "<group>"; };
451508352D400C050071E385 /* BTPayPalPaymentType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTPayPalPaymentType.swift; sourceTree = "<group>"; };
451508372D400C400071E385 /* BTPayPalRequestLandingPageType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTPayPalRequestLandingPageType.swift; sourceTree = "<group>"; };
45227FC32C330FDE00A15018 /* MockURLSessionTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockURLSessionTask.swift; sourceTree = "<group>"; };
45227FC62C33104100A15018 /* MockBTHTTPNetworkTiming.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockBTHTTPNetworkTiming.swift; sourceTree = "<group>"; };
454722AF2CF0DA27000DCF4E /* LocalPaymentPOSTBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalPaymentPOSTBody.swift; sourceTree = "<group>"; };
@@ -1299,13 +1303,15 @@
57544F5D295258AC00DEB7B0 /* BTPayPalError.swift */,
BEF5D2E5294A18B300FFD56D /* BTPayPalLineItem.swift */,
57D9436D2968A8080079EAB1 /* BTPayPalLocaleCode.swift */,
451508352D400C050071E385 /* BTPayPalPaymentType.swift */,
62B811872CC002470024A688 /* BTPayPalPhoneNumber.swift */,
BE349112294B798300D2CF68 /* BTPayPalRequest.swift */,
451508372D400C400071E385 /* BTPayPalRequestLandingPageType.swift */,
BE6BC22D2BA9CFFC00C3E321 /* BTPayPalReturnURL.swift */,
BE349110294B77E100D2CF68 /* BTPayPalVaultRequest.swift */,
45E8CE4A2D1F291400D7A2DC /* Models */,
62A659A32B98CB23008DFD67 /* PrivacyInfo.xcprivacy */,
807D22F32C29ADA8009FFEA4 /* RecurringBillingMetadata */,
62B811872CC002470024A688 /* BTPayPalPhoneNumber.swift */,
);
path = BraintreePayPal;
sourceTree = "<group>";
@@ -3119,12 +3125,14 @@
BE549F112BF5445F00B6F441 /* BTPayPalReturnURL.swift in Sources */,
57544F5C295254A500DEB7B0 /* BTJSON+PayPal.swift in Sources */,
3B7A261129C0CAA40087059D /* BTPayPalAnalytics.swift in Sources */,
451508382D400C400071E385 /* BTPayPalRequestLandingPageType.swift in Sources */,
BE8E5CEF294B6937001BF017 /* BTPayPalCheckoutRequest.swift in Sources */,
807D22F02C29A93A009FFEA4 /* BTPayPalBillingCycle.swift in Sources */,
5754481E294A2A1D00DEB7B0 /* BTPayPalCreditFinancingAmount.swift in Sources */,
57D9436E2968A8080079EAB1 /* BTPayPalLocaleCode.swift in Sources */,
45E8CE4C2D1F29BA00D7A2DC /* PayPalCheckoutPOSTBody.swift in Sources */,
57544F582952298900DEB7B0 /* BTPayPalAccountNonce.swift in Sources */,
451508362D400C050071E385 /* BTPayPalPaymentType.swift in Sources */,
8014221C2BAE935B009F9999 /* BTPayPalApprovalURLParser.swift in Sources */,
BE349111294B77E100D2CF68 /* BTPayPalVaultRequest.swift in Sources */,
62B811882CC002470024A688 /* BTPayPalPhoneNumber.swift in Sources */,
19 changes: 19 additions & 0 deletions Sources/BraintreePayPal/BTPayPalPaymentType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation

@objc public enum BTPayPalPaymentType: Int {

/// Checkout
case checkout

/// Vault
case vault

var stringValue: String {
switch self {
case .vault:
return "paypal-ba"
case .checkout:
return "paypal-single-payment"
}
}
}
45 changes: 1 addition & 44 deletions Sources/BraintreePayPal/BTPayPalRequest.swift
Original file line number Diff line number Diff line change
@@ -4,50 +4,7 @@ import UIKit
import BraintreeCore
#endif

@objc public enum BTPayPalPaymentType: Int {

/// Checkout
case checkout

/// Vault
case vault

var stringValue: String {
switch self {
case .vault:
return "paypal-ba"
case .checkout:
return "paypal-single-payment"
}
}
}

/// Use this option to specify the PayPal page to display when a user lands on the PayPal site to complete the payment.
@objc public enum BTPayPalRequestLandingPageType: Int {

/// Default
case none // Obj-C enums cannot be nil; this default option is used to make `landingPageType` optional for merchants

/// Login
case login

/// Billing
case billing

var stringValue: String? {
switch self {
case .login:
return "login"

case .billing:
return "billing"

default:
return nil
}
}
}

/// Defines the structure and requirements for PayPal Checkout and PayPal Vault flows.
protocol PayPalRequest {
var hermesPath: String { get }
var paymentType: BTPayPalPaymentType { get }
27 changes: 27 additions & 0 deletions Sources/BraintreePayPal/BTPayPalRequestLandingPageType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Foundation

/// Use this option to specify the PayPal page to display when a user lands on the PayPal site to complete the payment.
@objc public enum BTPayPalRequestLandingPageType: Int {

/// Default
case none // Obj-C enums cannot be nil; this default option is used to make `landingPageType` optional for merchants

/// Login
case login

/// Billing
case billing

var stringValue: String? {
switch self {
case .login:
return "login"

case .billing:
return "billing"

default:
return nil
}
}
}