-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1250 from braintree/contact-information-feature
[DO NOT REVIEW] Merge Contact Information Feature Branch
- Loading branch information
Showing
8 changed files
with
90 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import com.braintreepayments.api.paypal.PayPalBillingInterval; | ||
import com.braintreepayments.api.paypal.PayPalBillingPricing; | ||
import com.braintreepayments.api.paypal.PayPalCheckoutRequest; | ||
import com.braintreepayments.api.paypal.PayPalContactInformation; | ||
import com.braintreepayments.api.paypal.PayPalLandingPageType; | ||
import com.braintreepayments.api.paypal.PayPalPaymentIntent; | ||
import com.braintreepayments.api.paypal.PayPalPaymentUserAction; | ||
|
@@ -112,7 +113,8 @@ public static PayPalCheckoutRequest createPayPalCheckoutRequest( | |
String amount, | ||
String buyerEmailAddress, | ||
String buyerPhoneCountryCode, | ||
String buyerPhoneNationalNumber | ||
String buyerPhoneNationalNumber, | ||
Boolean isContactInformationEnabled | ||
) { | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest(amount, true); | ||
|
||
|
@@ -159,6 +161,10 @@ public static PayPalCheckoutRequest createPayPalCheckoutRequest( | |
request.setShippingAddressOverride(shippingAddress); | ||
} | ||
|
||
if (isContactInformationEnabled) { | ||
request.setContactInformation(new PayPalContactInformation("[email protected]", new PayPalPhoneNumber("1", "1234567890"))); | ||
} | ||
|
||
return request; | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalContactInformation.kt
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,16 @@ | ||
package com.braintreepayments.api.paypal | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* Representation of a recipient Contact Information for the order. | ||
* | ||
* @property recipientEmail Email address of the recipient. | ||
* @property recipentPhoneNumber Phone number of the recipient. | ||
*/ | ||
@Parcelize | ||
data class PayPalContactInformation( | ||
val recipientEmail: String? = null, | ||
val recipentPhoneNumber: PayPalPhoneNumber? = null | ||
) : Parcelable |
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 |
---|---|---|
|
@@ -225,5 +225,37 @@ public void createRequestBody_sets_userPhoneNumber_when_not_null() throws JSONEx | |
|
||
assertTrue(requestBody.contains("\"phone_number\":{\"country_code\":\"1\",\"national_number\":\"1231231234\"}")); | ||
} | ||
} | ||
|
||
@Test | ||
public void createRequestBody_sets_contactInformation_when_not_null() throws JSONException { | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest("1.00", true); | ||
|
||
request.setContactInformation(new PayPalContactInformation("[email protected]", new PayPalPhoneNumber("1", "1234567890"))); | ||
String requestBody = request.createRequestBody( | ||
mock(Configuration.class), | ||
mock(Authorization.class), | ||
"success_url", | ||
"cancel_url", | ||
null | ||
); | ||
|
||
assertTrue(requestBody.contains("\"recipient_email\":\"[email protected]\"")); | ||
assertTrue(requestBody.contains("\"international_phone\":{\"country_code\":\"1\",\"national_number\":\"1234567890\"}")); | ||
} | ||
|
||
@Test | ||
public void createRequestBody_does_not_set_contactInformation_when_contactInformation_is_null() throws JSONException { | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest("1.00", true); | ||
|
||
String requestBody = request.createRequestBody( | ||
mock(Configuration.class), | ||
mock(Authorization.class), | ||
"success_url", | ||
"cancel_url", | ||
null | ||
); | ||
|
||
assertFalse(requestBody.contains("\"recipient_email\":\"[email protected]\"")); | ||
assertFalse(requestBody.contains("\"international_phone\":{\"country_code\":\"1\",\"national_number\":\"1234567890\"}")); | ||
} | ||
} |