Skip to content

Commit

Permalink
address pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
agedd committed Nov 13, 2024
1 parent b1abbdb commit 38d6589
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Sources/BraintreePayPal/BTPayPalCheckoutRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import BraintreeCore

// MARK: - Internal Properties

var amount: String?
var intent: BTPayPalRequestIntent?
var amount: String
var intent: BTPayPalRequestIntent
var userAction: BTPayPalRequestUserAction
var offerPayLater: Bool
var currencyCode: String?
Expand All @@ -88,8 +88,8 @@ import BraintreeCore
/// identified with the same phone number.
/// - lineItems: Optional: The line items for this transaction. It can include up to 249 line items.
public init(
amount: String?,
intent: BTPayPalRequestIntent? = .authorize,
amount: String,
intent: BTPayPalRequestIntent = .authorize,
userAction: BTPayPalRequestUserAction = .none,
offerPayLater: Bool = false,
currencyCode: String? = nil,
Expand Down Expand Up @@ -119,7 +119,7 @@ import BraintreeCore
) -> [String: Any] {
var baseParameters = super.parameters(with: configuration)
var checkoutParameters: [String: Any] = [
"intent": intent?.stringValue,
"intent": intent.stringValue,
"amount": amount,
"offer_pay_later": offerPayLater
]
Expand Down
2 changes: 1 addition & 1 deletion Sources/BraintreePayPal/BTPayPalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ import BraintreeDataCollector
if paymentType == .checkout {
account["options"] = ["validate": false]
if let request = payPalRequest as? BTPayPalCheckoutRequest {
account["intent"] = request.intent?.stringValue
account["intent"] = request.intent.stringValue
}
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/BraintreePayPal/BTPayPalRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import BraintreeCore
/// - merchantAccountID: Optional: A non-default merchant account to use for tokenization.
/// - billingAgreementDescription: Optional: Display a custom description to the user for a billing agreement. For Checkout with Vault flows, you must also set
/// `requestBillingAgreement` to `true` on your `BTPayPalCheckoutRequest`.
/// - riskCorrelationId: Optional: A risk correlation ID created with Set Transaction Context on your server.
/// - riskCorrelationID: Optional: A risk correlation ID created with Set Transaction Context on your server.
init(
hermesPath: String,
paymentType: BTPayPalPaymentType,
Expand All @@ -100,7 +100,7 @@ import BraintreeCore
displayName: String? = nil,
merchantAccountID: String? = nil,
billingAgreementDescription: String? = nil,
riskCorrelationId: String? = nil
riskCorrelationID: String? = nil
) {
self.hermesPath = hermesPath
self.paymentType = paymentType
Expand All @@ -112,7 +112,7 @@ import BraintreeCore
self.displayName = displayName
self.merchantAccountID = merchantAccountID
self.billingAgreementDescription = billingAgreementDescription
self.riskCorrelationID = riskCorrelationId
self.riskCorrelationID = riskCorrelationID
}

// MARK: Internal Methods
Expand Down
14 changes: 5 additions & 9 deletions Sources/BraintreePayPal/BTPayPalVaultRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ import BraintreeCore

/// Options for the PayPal Vault flow.
@objcMembers public class BTPayPalVaultRequest: BTPayPalRequest {

// MARK: - Public Properties

/// Optional: Offers PayPal Credit if the customer qualifies. Defaults to `false`.
public var offerCredit: Bool


// MARK: - Internal Properties


var offerCredit: Bool
var userAuthenticationEmail: String?
var userPhoneNumber: BTPayPalPhoneNumber?
var enablePayPalAppSwitch: Bool = false
Expand Down Expand Up @@ -72,8 +68,8 @@ import BraintreeCore
baseParameters["payer_email"] = userAuthenticationEmail
}

if let userPhoneNumberDict = try? userPhoneNumber?.toDictionary() {
baseParameters["phone_number"] = userPhoneNumberDict
if let userPhoneNumberDictionary = try? userPhoneNumber?.toDictionary() {
baseParameters["phone_number"] = userPhoneNumberDictionary
}

if let universalLink, enablePayPalAppSwitch, isPayPalAppInstalled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ class BTPayPalCheckoutRequest_Tests: XCTestCase {

func testIntentAsString_whenIntentIsNotSpecified_returnsAuthorize() {
let request = BTPayPalCheckoutRequest(amount: "1")
XCTAssertEqual(request.intent?.stringValue, "authorize")
XCTAssertEqual(request.intent.stringValue, "authorize")
}

func testIntentAsString_whenIntentIsAuthorize_returnsAuthorize() {
let request = BTPayPalCheckoutRequest(amount: "1")
request.intent = .authorize
XCTAssertEqual(request.intent?.stringValue, "authorize")
XCTAssertEqual(request.intent.stringValue, "authorize")
}

func testIntentAsString_whenIntentIsSale_returnsSale() {
let request = BTPayPalCheckoutRequest(amount: "1")
request.intent = .sale
XCTAssertEqual(request.intent?.stringValue, "sale")
XCTAssertEqual(request.intent.stringValue, "sale")
}

func testIntentAsString_whenIntentIsOrder_returnsOrder() {
let request = BTPayPalCheckoutRequest(amount: "1")
request.intent = .order
XCTAssertEqual(request.intent?.stringValue, "order")
XCTAssertEqual(request.intent.stringValue, "order")
}

// MARK: - userActionAsString
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/BraintreePayPalTests/BTPayPalClient_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ class BTPayPalClient_Tests: XCTestCase {
XCTAssertEqual(account?["response_type"] as? String, "web")
XCTAssertEqual(account?["correlation_id"] as? String, "a-fake-cmid")
XCTAssertEqual(account?["options"] as? [String: Bool], ["validate": false])
XCTAssertEqual(account?["intent"] as? String, (payPalClient.payPalRequest as? BTPayPalCheckoutRequest)?.intent?.stringValue)
XCTAssertEqual(account?["intent"] as? String, (payPalClient.payPalRequest as? BTPayPalCheckoutRequest)?.intent.stringValue)

let client = account?["client"] as? [String: String]
XCTAssertEqual(client?["platform"], "iOS")
Expand Down

0 comments on commit 38d6589

Please sign in to comment.