-
Notifications
You must be signed in to change notification settings - Fork 235
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
Move Shipping Callback URL to PayPalCheckoutRequest
#1200
Changes from all commits
f09c1e6
1abc019
b627b7c
ca3ae4e
ea2045c
388c2d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -7,7 +7,6 @@ | |||
import static org.junit.Assert.assertSame; | ||||
import static org.mockito.Mockito.mock; | ||||
|
||||
import android.net.Uri; | ||||
import android.os.Build; | ||||
import android.os.Parcel; | ||||
|
||||
|
@@ -17,7 +16,6 @@ | |||
import com.braintreepayments.api.testutils.Fixtures; | ||||
|
||||
import org.json.JSONException; | ||||
import org.json.JSONObject; | ||||
import org.junit.Test; | ||||
import org.junit.runner.RunWith; | ||||
import org.robolectric.RobolectricTestRunner; | ||||
|
@@ -301,57 +299,4 @@ 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_shippingCallbackUri_when_not_null() throws JSONException { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we able to add these tests to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there are already 3 unit tests that cover this in Line 162 in 388c2d6
|
||||
String urlString = "https://www.example.com/path"; | ||||
Uri uri = Uri.parse(urlString); | ||||
|
||||
PayPalVaultRequest request = new PayPalVaultRequest(true); | ||||
request.setShippingCallbackUrl(uri); | ||||
|
||||
String requestBody = request.createRequestBody( | ||||
mock(Configuration.class), | ||||
mock(Authorization.class), | ||||
"success_url", | ||||
"cancel_url", | ||||
null | ||||
); | ||||
|
||||
JSONObject jsonObject = new JSONObject(requestBody); | ||||
assertEquals(urlString, jsonObject.getString("shipping_callback_url")); | ||||
} | ||||
|
||||
@Test | ||||
public void createRequestBody_does_not_set_shippingCallbackUri_when_null() throws JSONException { | ||||
PayPalVaultRequest request = new PayPalVaultRequest(true); | ||||
|
||||
String requestBody = request.createRequestBody( | ||||
mock(Configuration.class), | ||||
mock(Authorization.class), | ||||
"success_url", | ||||
"cancel_url", | ||||
null | ||||
); | ||||
|
||||
JSONObject jsonObject = new JSONObject(requestBody); | ||||
assertFalse(jsonObject.has("shipping_callback_url")); | ||||
} | ||||
|
||||
@Test | ||||
public void createRequestBody_does_not_set_shippingCallbackUri_when_empty() throws JSONException { | ||||
PayPalVaultRequest request = new PayPalVaultRequest(true); | ||||
request.setShippingCallbackUrl(Uri.parse("")); | ||||
|
||||
String requestBody = request.createRequestBody( | ||||
mock(Configuration.class), | ||||
mock(Authorization.class), | ||||
"success_url", | ||||
"cancel_url", | ||||
null | ||||
); | ||||
|
||||
JSONObject jsonObject = new JSONObject(requestBody); | ||||
assertFalse(jsonObject.has("shipping_callback_url")); | ||||
} | ||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this logic move into
PayPalCheckoutRequest
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic is already there
braintree_android/PayPal/src/main/java/com/braintreepayments/api/paypal/PayPalCheckoutRequest.kt
Line 113 in 388c2d6
My mistake was approaching this change differently in iOS. In iOS, I created the feature branch from scratch, while here, I only removed
shippingCallbackUrl
from the Vault flow, keeping the changes from the PR previously merged into this feature branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah gotcha, no worries! Thanks for pointing out where it was since the approach was slightly different.