-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create PayPalNativeCheckout Module (#551) * Create module Signed-off-by: Matt Wylder <[email protected]> * Add PayPalNativeCheckout to Rakefile Signed-off-by: Steven Shropshire <[email protected]> * Remove unecessary gitignore Signed-off-by: Sarah Koop <[email protected]> * Add empty files for folder structure Signed-off-by: Matt Wylder <[email protected]> Co-authored-by: Matt Wylder <[email protected]> Co-authored-by: Steven Shropshire <[email protected]> * Add PayPalNativeCheckoutNonce and PayPalNativeCheckoutRequest. (#553) Signed-off-by: Sarah Koop <[email protected]> Co-authored-by: Steven Shropshire <[email protected]> * Add PayPalNativeFragment to Demo App (#556) * Added navigation to new fragment Signed-off-by: Jax DesMarais-Leder <[email protected]> * Adding button to PayPalNativeFragment Signed-off-by: Jax DesMarais-Leder <[email protected]> * added functionality to button Signed-off-by: Jax DesMarais-Leder <[email protected]> * conforming names of PayPal Native Checkout classes and variables into conformance with iOS Signed-off-by: Jax DesMarais-Leder <[email protected]> * conform naming of PayPal Native Checkout strings Signed-off-by: Jax DesMarais-Leder <[email protected]> * renamed pay_pal to paypal Signed-off-by: Jax DesMarais-Leder <[email protected]> * Reorganizing Native Checkout button on main fragment Signed-off-by: Jax DesMarais-Leder <[email protected]> * Checkout feature (#560) * Add PayPalNative Module and support through the Braintree SDK Co-authored-by: Tim Chow <[email protected]> Co-authored-by: Kelay <[email protected]> * -Removing returnUrl and adding onShippingChange callback * -Updating native version * -Fixing tests * update changelog nesting * -Reverting room update * -Updating java * -Removing shipping callback * -Updating java version * -Upgrading java 11 git actions * -Reverting java 11 update * -Updating to java 11 * -Testing * -Testing * -Updating native version * -Fixing buttons * -Adding returnUrl to account object -Adding in java 11 to changelog * -New tests for account * -Adding source compatability * -Renaming java version Co-authored-by: Sarah Koop <[email protected]> Co-authored-by: Matt Wylder <[email protected]> Co-authored-by: Steven Shropshire <[email protected]> Co-authored-by: sshropshire <[email protected]> Co-authored-by: Matthew Wylder <[email protected]> Co-authored-by: Tim Chow <[email protected]> Co-authored-by: Kelay <[email protected]> Co-authored-by: Jax DesMarais-Leder <[email protected]>
- Loading branch information
1 parent
73ebe94
commit bf990e0
Showing
63 changed files
with
3,944 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name: Setup Java 8 | ||
description: 'Sets up Java 8' | ||
name: Setup Java 11 | ||
description: 'Sets up Java 11' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up Java 8 | ||
uses: actions/setup-java@v2 | ||
- name: Set up Java 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
java-version: '11' | ||
distribution: 'zulu' |
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
104 changes: 104 additions & 0 deletions
104
Demo/src/main/java/com/braintreepayments/demo/PayPalNativeCheckoutFragment.java
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,104 @@ | ||
package com.braintreepayments.demo; | ||
|
||
import static com.braintreepayments.demo.PayPalNativeCheckoutRequestFactory.createPayPalCheckoutRequest; | ||
import static com.braintreepayments.demo.PayPalNativeCheckoutRequestFactory.createPayPalVaultRequest; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.fragment.app.FragmentActivity; | ||
import androidx.navigation.fragment.NavHostFragment; | ||
|
||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.Button; | ||
|
||
import com.braintreepayments.api.BraintreeClient; | ||
import com.braintreepayments.api.DataCollector; | ||
import com.braintreepayments.api.PayPalNativeCheckoutAccountNonce; | ||
import com.braintreepayments.api.PayPalNativeCheckoutListener; | ||
import com.braintreepayments.api.PayPalNativeCheckoutClient; | ||
import com.braintreepayments.api.PaymentMethodNonce; | ||
|
||
public class PayPalNativeCheckoutFragment extends BaseFragment implements PayPalNativeCheckoutListener { | ||
|
||
private final String TAG = PayPalNativeCheckoutFragment.class.getName(); | ||
private String deviceData; | ||
private BraintreeClient braintreeClient; | ||
private PayPalNativeCheckoutClient payPalClient; | ||
private DataCollector dataCollector; | ||
|
||
public Button launchPayPalNativeCheckoutButton; | ||
|
||
public PayPalNativeCheckoutFragment() { | ||
} | ||
|
||
@Override | ||
public View onCreateView( | ||
LayoutInflater inflater, | ||
ViewGroup container, | ||
Bundle savedInstanceState | ||
) { | ||
View view = inflater.inflate(R.layout.fragment_paypal_native_checkout, container, false); | ||
|
||
launchPayPalNativeCheckoutButton = view.findViewById(R.id.paypal_native_checkout_launch); | ||
launchPayPalNativeCheckoutButton.setOnClickListener(v -> launchPayPalNativeCheckout(false)); | ||
braintreeClient = getBraintreeClient(); | ||
payPalClient = new PayPalNativeCheckoutClient(this, braintreeClient); | ||
payPalClient.setListener(this); | ||
return view; | ||
} | ||
|
||
private void launchPayPalNativeCheckout(boolean isBillingAgreement) { | ||
FragmentActivity activity = getActivity(); | ||
activity.setProgressBarIndeterminateVisibility(true); | ||
|
||
dataCollector = new DataCollector(braintreeClient); | ||
|
||
braintreeClient.getConfiguration((configuration, configError) -> { | ||
if (Settings.shouldCollectDeviceData(requireActivity())) { | ||
dataCollector.collectDeviceData(requireActivity(), (deviceDataResult, error) -> { | ||
if (deviceDataResult != null) { | ||
deviceData = deviceDataResult; | ||
} | ||
try { | ||
payPalClient.tokenizePayPalAccount(activity, createPayPalCheckoutRequest(activity, "1.00")); | ||
} catch (Exception e) { | ||
Log.i(TAG, "Unsupported type"); | ||
} | ||
}); | ||
} else { | ||
try { | ||
payPalClient.tokenizePayPalAccount(activity, createPayPalCheckoutRequest(activity, "1.00")); | ||
} catch (Exception e) { | ||
Log.i(TAG, "Unsupported type"); | ||
} | ||
|
||
} | ||
}); | ||
} | ||
|
||
private void handlePayPalResult(PaymentMethodNonce paymentMethodNonce) { | ||
if (paymentMethodNonce != null) { | ||
super.onPaymentMethodNonceCreated(paymentMethodNonce); | ||
|
||
PayPalNativeCheckoutFragmentDirections.ActionPayPalNativeCheckoutFragmentToDisplayNonceFragment action = | ||
PayPalNativeCheckoutFragmentDirections.actionPayPalNativeCheckoutFragmentToDisplayNonceFragment(paymentMethodNonce); | ||
action.setDeviceData(deviceData); | ||
|
||
NavHostFragment.findNavController(this).navigate(action); | ||
} | ||
} | ||
|
||
@Override | ||
public void onPayPalSuccess(@NonNull PayPalNativeCheckoutAccountNonce payPalAccountNonce) { | ||
handlePayPalResult(payPalAccountNonce); | ||
} | ||
|
||
@Override | ||
public void onPayPalFailure(@NonNull Exception error) { | ||
handleError(error); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
Demo/src/main/java/com/braintreepayments/demo/PayPalNativeCheckoutRequestFactory.java
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,69 @@ | ||
package com.braintreepayments.demo; | ||
|
||
import android.content.Context; | ||
|
||
import com.braintreepayments.api.PayPalNativeCheckoutRequest; | ||
import com.braintreepayments.api.PayPalNativeCheckoutPaymentIntent; | ||
import com.braintreepayments.api.PayPalNativeRequest; | ||
import com.braintreepayments.api.PayPalNativeCheckoutVaultRequest; | ||
import com.braintreepayments.api.PostalAddress; | ||
|
||
public class PayPalNativeCheckoutRequestFactory { | ||
|
||
public static PayPalNativeCheckoutVaultRequest createPayPalVaultRequest(Context context) { | ||
PayPalNativeCheckoutVaultRequest request = new PayPalNativeCheckoutVaultRequest(); | ||
|
||
request.setDisplayName(Settings.getPayPalDisplayName(context)); | ||
|
||
if (Settings.isPayPalCreditOffered(context)) { | ||
request.setShouldOfferCredit(true); | ||
} | ||
|
||
if (Settings.usePayPalAddressOverride(context)) { | ||
PostalAddress postalAddress = new PostalAddress(); | ||
postalAddress.setRecipientName("Brian Tree"); | ||
postalAddress.setStreetAddress("123 Fake Street"); | ||
postalAddress.setExtendedAddress("Floor A"); | ||
postalAddress.setLocality("San Francisco"); | ||
postalAddress.setRegion("CA"); | ||
postalAddress.setCountryCodeAlpha2("US"); | ||
|
||
request.setShippingAddressOverride(postalAddress); | ||
} | ||
request.setReturnUrl("com.braintreepayments.demo://paypalpay"); | ||
return request; | ||
} | ||
|
||
public static PayPalNativeCheckoutRequest createPayPalCheckoutRequest(Context context, String amount) { | ||
PayPalNativeCheckoutRequest request = new PayPalNativeCheckoutRequest(amount); | ||
|
||
request.setDisplayName(Settings.getPayPalDisplayName(context)); | ||
|
||
String intentType = Settings.getPayPalIntentType(context); | ||
if (intentType.equals(context.getString(R.string.paypal_intent_authorize))) { | ||
request.setIntent(PayPalNativeCheckoutPaymentIntent.AUTHORIZE); | ||
} else if (intentType.equals(context.getString(R.string.paypal_intent_order))) { | ||
request.setIntent(PayPalNativeCheckoutPaymentIntent.ORDER); | ||
} else if (intentType.equals(context.getString(R.string.paypal_intent_sale))) { | ||
request.setIntent(PayPalNativeCheckoutPaymentIntent.SALE); | ||
} | ||
|
||
if (Settings.isPayPalUseractionCommitEnabled(context)) { | ||
request.setUserAction(PayPalNativeCheckoutRequest.USER_ACTION_COMMIT); | ||
} | ||
|
||
if (Settings.usePayPalAddressOverride(context)) { | ||
PostalAddress shippingAddress = new PostalAddress(); | ||
shippingAddress.setRecipientName("Brian Tree"); | ||
shippingAddress.setStreetAddress("123 Fake Street"); | ||
shippingAddress.setExtendedAddress("Floor A"); | ||
shippingAddress.setLocality("San Francisco"); | ||
shippingAddress.setRegion("CA"); | ||
shippingAddress.setCountryCodeAlpha2("US"); | ||
|
||
request.setShippingAddressOverride(shippingAddress); | ||
} | ||
request.setReturnUrl("com.braintreepayments.demo://paypalpay"); | ||
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
Oops, something went wrong.