-
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.
Merge branch 'main' into contact-information-feature
- Loading branch information
Showing
1,195 changed files
with
2,676 additions
and
2,440 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
package com.braintreepayments.api.paypal; | ||
|
||
import android.net.Uri; | ||
import android.os.Parcel; | ||
|
||
import com.braintreepayments.api.core.Authorization; | ||
import com.braintreepayments.api.core.Configuration; | ||
import com.braintreepayments.api.core.PostalAddress; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
|
@@ -157,6 +159,58 @@ public void createRequestBody_does_not_set_userAuthenticationEmail_when_email_is | |
} | ||
|
||
@Test | ||
public void createRequestBody_sets_shippingCallbackUri_when_not_null() throws JSONException { | ||
String urlString = "https://www.example.com/path"; | ||
Uri uri = Uri.parse(urlString); | ||
|
||
PayPalCheckoutRequest request = new PayPalCheckoutRequest("1.00", 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 { | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest("1.00", 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 { | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest("1.00", 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")); | ||
} | ||
|
||
public void createRequestBody_sets_userPhoneNumber_when_not_null() throws JSONException { | ||
PayPalCheckoutRequest request = new PayPalCheckoutRequest("1.00", true); | ||
|
||
|
@@ -204,4 +258,4 @@ public void createRequestBody_does_not_set_contactInformation_when_contactInform | |
assertFalse(requestBody.contains("\"recipient_email\":\"[email protected]\"")); | ||
assertFalse(requestBody.contains("\"international_phone\":{\"country_code\":\"1\",\"national_number\":\"1234567890\"}")); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.