-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Buyer Phone Number Sent By Merchant to PayPalRequest (#1304)
* add phone number field to paypalrequest * add small unit sanity tests * update CHANGELOG.md * code cleanup * update param name * resolve conflicts and update changelog.md * cleanup * cleanup and address pr feedback * fix unit tests * address pr feedback
- Loading branch information
Showing
9 changed files
with
96 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Foundation | ||
|
||
public struct BTPayPalPhoneNumber: Encodable { | ||
|
||
private let countryCode: String | ||
private let nationalNumber: String | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case countryCode = "country_code" | ||
case nationalNumber = "national_number" | ||
} | ||
|
||
/// Intialize a `BTPayPalPhoneNumber` | ||
/// - Parameters: | ||
/// - countryCode: The international country code for the shopper's phone number i.e. "1" for US | ||
/// - nationalNumber: The national segment of the shopper's phone number | ||
public init(countryCode: String, nationalNumber: String) { | ||
self.countryCode = countryCode | ||
self.nationalNumber = nationalNumber | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,7 @@ class BTPayPalCheckoutRequest_Tests: XCTestCase { | |
request.billingAgreementDescription = "description" | ||
request.userAction = .payNow | ||
request.userAuthenticationEmail = "[email protected]" | ||
request.userPhoneNumber = BTPayPalPhoneNumber(countryCode: "1", nationalNumber: "4087463271") | ||
|
||
let shippingAddress = BTPostalAddress() | ||
shippingAddress.streetAddress = "123 Main" | ||
|
@@ -114,6 +115,13 @@ class BTPayPalCheckoutRequest_Tests: XCTestCase { | |
XCTAssertEqual(parameters["recipient_name"] as? String, "Recipient") | ||
XCTAssertEqual(parameters["payer_email"] as? String, "[email protected]") | ||
XCTAssertEqual(parameters["request_billing_agreement"] as? Bool, true) | ||
|
||
guard let userPhoneNumberDetails = parameters["phone_number"] as? [String: String] else { | ||
XCTFail() | ||
return | ||
} | ||
XCTAssertEqual(userPhoneNumberDetails["country_code"], "1") | ||
XCTAssertEqual(userPhoneNumberDetails["national_number"], "4087463271") | ||
|
||
guard let billingAgreementDetails = parameters["billing_agreement_details"] as? [String : String] else { | ||
XCTFail() | ||
|
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 |
---|---|---|
|
@@ -49,6 +49,7 @@ class BTPayPalVaultRequest_Tests: XCTestCase { | |
request.isShippingAddressEditable = true | ||
request.offerCredit = true | ||
request.userAuthenticationEmail = "[email protected]" | ||
request.userPhoneNumber = BTPayPalPhoneNumber(countryCode: "1", nationalNumber: "4087463271") | ||
|
||
let parameters = request.parameters(with: configuration) | ||
|
||
|
@@ -60,6 +61,13 @@ class BTPayPalVaultRequest_Tests: XCTestCase { | |
XCTAssertNil(parameters["os_type"]) | ||
XCTAssertNil(parameters["merchant_app_return_url"]) | ||
|
||
guard let userPhoneNumberDetails = parameters["phone_number"] as? [String: String] else { | ||
XCTFail() | ||
return | ||
} | ||
XCTAssertEqual(userPhoneNumberDetails["country_code"], "1") | ||
XCTAssertEqual(userPhoneNumberDetails["national_number"], "4087463271") | ||
|
||
guard let shippingParams = parameters["shipping_address"] as? [String:String] else { XCTFail(); return } | ||
|
||
XCTAssertEqual(shippingParams["line1"], "123 Main") | ||
|