-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shopper insights rp1 feature include session (#1235)
* Add shopper insights session ID to paypalRequest * Update factory for paypal request * remove extra setting of email address * Remove optional null and check for null in PayPalRequestFactory * Use String type and fix check for null to prevent run time crashes * Remove DEMO UI updates * Update comment for shopperSessionId * Add experimentalAPI for shopper session Id * Remove unused shopperInsightsSessionIdNullSwitch * Check for null and empty string * Update to use putOpt method for shopperId * Update changelog * Check for null and empty strings for request properties. * Update unit tests * Update test * Update unit tests * Update changelog
- Loading branch information
1 parent
fb4455d
commit 8427bcd
Showing
9 changed files
with
93 additions
and
13 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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
import com.braintreepayments.api.testutils.Fixtures; | ||
|
||
import org.json.JSONException; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
|
@@ -32,6 +33,7 @@ public class PayPalVaultRequestUnitTest { | |
public void newPayPalVaultRequest_setsDefaultValues() { | ||
PayPalVaultRequest request = new PayPalVaultRequest(false); | ||
|
||
assertNull(request.getShopperSessionId()); | ||
assertNull(request.getLocaleCode()); | ||
assertFalse(request.isShippingAddressRequired()); | ||
assertNull(request.getShippingAddressOverride()); | ||
|
@@ -46,6 +48,7 @@ public void newPayPalVaultRequest_setsDefaultValues() { | |
public void setsValuesCorrectly() { | ||
PostalAddress postalAddress = new PostalAddress(); | ||
PayPalVaultRequest request = new PayPalVaultRequest(true); | ||
request.setShopperSessionId("shopper-insights-id"); | ||
request.setLocaleCode("US"); | ||
request.setBillingAgreementDescription("Billing Agreement Description"); | ||
request.setShippingAddressRequired(true); | ||
|
@@ -75,6 +78,7 @@ public void setsValuesCorrectly() { | |
request.setRecurringBillingDetails(billingDetails); | ||
request.setRecurringBillingPlanType(PayPalRecurringBillingPlanType.RECURRING); | ||
|
||
assertEquals("shopper-insights-id", request.getShopperSessionId()); | ||
assertEquals("US", request.getLocaleCode()); | ||
assertEquals("Billing Agreement Description", request.getBillingAgreementDescription()); | ||
assertTrue(request.isShippingAddressRequired()); | ||
|
@@ -212,11 +216,11 @@ public void createRequestBody_sets_userAuthenticationEmail_when_not_null() throw | |
assertTrue(requestBody.contains("\"payer_email\":" + "\"" + payerEmail + "\"")); | ||
} | ||
|
||
@Test | ||
public void createRequestBody_sets_enablePayPalSwitch_and_userAuthenticationEmail_not_null() throws JSONException { | ||
String versionSDK = String.valueOf(Build.VERSION.SDK_INT); | ||
String payerEmail = "[email protected]"; | ||
PayPalVaultRequest request = new PayPalVaultRequest(true); | ||
|
||
request.setEnablePayPalAppSwitch(true); | ||
request.setUserAuthenticationEmail(payerEmail); | ||
String requestBody = request.createRequestBody( | ||
|
@@ -233,6 +237,21 @@ public void createRequestBody_sets_enablePayPalSwitch_and_userAuthenticationEmai | |
assertTrue(requestBody.contains("\"merchant_app_return_url\":" + "\"universal_url\"")); | ||
} | ||
|
||
@Test | ||
public void createRequestBody_sets_shopper_insights_session_id() throws JSONException { | ||
PayPalVaultRequest request = new PayPalVaultRequest(true); | ||
request.setShopperSessionId("shopper-insights-id"); | ||
String requestBody = request.createRequestBody( | ||
mock(Configuration.class), | ||
mock(Authorization.class), | ||
"success_url", | ||
"cancel_url", | ||
"universal_url" | ||
); | ||
|
||
assertTrue(requestBody.contains("\"shopper_session_id\":" + "\"shopper-insights-id\"")); | ||
} | ||
|
||
@Test | ||
public void createRequestBody_correctlyFormatsJSON() throws JSONException { | ||
PayPalVaultRequest request = new PayPalVaultRequest(true); | ||
|