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

Shopper insights rp1 feature sessionid analytics #1238

Merged
Changes from 1 commit
Commits
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
Add unit tests
warmkesselj committed Dec 10, 2024
commit b54c7ff79bca2cf96a52af66d1a5b3b45a9b7f26
Original file line number Diff line number Diff line change
@@ -618,4 +618,60 @@ public void tokenize_whenCancelUriReceived_sendsAppSwitchCanceledEvents()
verify(braintreeClient).sendAnalyticsEvent(PayPalAnalytics.BROWSER_LOGIN_CANCELED, params);
verify(braintreeClient).sendAnalyticsEvent(PayPalAnalytics.APP_SWITCH_CANCELED, params);
}

@Test
public void test_vaultRequest_shopperSessionId_sets_repository() throws JSONException {
PayPalVaultRequest payPalVaultRequest = new PayPalVaultRequest(true);

payPalVaultRequest.setShopperSessionId("test-shopper-id");

PayPalPaymentAuthRequestParams paymentAuthRequest = new PayPalPaymentAuthRequestParams(
payPalVaultRequest,
null,
"https://example.com/approval/url",
"sample-client-metadata-id",
null,
"https://example.com/success/url"
);

PayPalInternalClient payPalInternalClient =
new MockPayPalInternalClientBuilder().sendRequestSuccess(paymentAuthRequest)
.build();

BraintreeClient braintreeClient =
new MockBraintreeClientBuilder().configuration(payPalEnabledConfig).build();

PayPalClient sut = new PayPalClient(braintreeClient, payPalInternalClient, merchantRepository, analyticsParamRepository);
sut.createPaymentAuthRequest(activity, payPalVaultRequest, paymentAuthCallback);

verify(analyticsParamRepository).setSessionId("test-shopper-id");
}

@Test
public void test_checkoutRequest_shopperSessionId_sets_repository() throws JSONException {
PayPalCheckoutRequest request = new PayPalCheckoutRequest("2.00", true);

request.setShopperSessionId("test-shopper-id");

PayPalPaymentAuthRequestParams paymentAuthRequest = new PayPalPaymentAuthRequestParams(
request,
null,
"https://example.com/approval/url",
"sample-client-metadata-id",
null,
"https://example.com/success/url"
);

PayPalInternalClient payPalInternalClient =
new MockPayPalInternalClientBuilder().sendRequestSuccess(paymentAuthRequest)
.build();

BraintreeClient braintreeClient =
new MockBraintreeClientBuilder().configuration(payPalEnabledConfig).build();

PayPalClient sut = new PayPalClient(braintreeClient, payPalInternalClient, merchantRepository, analyticsParamRepository);
sut.createPaymentAuthRequest(activity, request, paymentAuthCallback);

verify(analyticsParamRepository).setSessionId("test-shopper-id");
}
}