Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class DisplayNonceFragment extends Fragment {
private TextView nonceString;
private TextView nonceDetails;
private TextView deviceData;

private TextView isPayLaterSelectedText;
private Button createTransactionButton;

public DisplayNonceFragment() { }
Expand All @@ -42,22 +42,22 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
nonceDetails = view.findViewById(R.id.nonce_details);
deviceData = view.findViewById(R.id.device_data);
createTransactionButton = view.findViewById(R.id.create_transaction);

isPayLaterSelectedText = view.findViewById(R.id.is_pay_later_selected);
createTransactionButton.setOnClickListener(this::createTransaction);

DisplayNonceFragmentArgs args = DisplayNonceFragmentArgs.fromBundle(getArguments());
displayNonce(args.getPaymentMethodNonce(), args.getDeviceData(), args.getTransactionAmount());
displayNonce(args.getPaymentMethodNonce(), args.getDeviceData(), args.getTransactionAmount(), args.getIsPayLaterSelected());
return view;
}

private void displayNonce(PaymentMethodNonce paymentMethodNonce, String deviceData, String amount) {
private void displayNonce(PaymentMethodNonce paymentMethodNonce, String deviceData, String amount, Boolean isPayLaterSelected) {
this.amount = amount;
nonce = paymentMethodNonce;
nonceString.setText(getString(R.string.nonce_placeholder, nonce.getString()));

String details = PaymentMethodNonceFormatter.convertToString(nonce);
nonceDetails.setText(details);

isPayLaterSelectedText.setText(getString(R.string.is_pay_later_enabled_placeholder, String.valueOf(isPayLaterSelected)));
this.deviceData.setText(getString(R.string.device_data_placeholder, deviceData));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class PayPalFragment extends BaseFragment {

private PayPalClient payPalClient;
private PayPalLauncher payPalLauncher;
private Boolean isPayLaterEnabled = false;

private DataCollector dataCollector;

Expand All @@ -49,7 +50,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
TextInputEditText buyerPhoneNationalNumberEditText = view.findViewById(R.id.buyer_phone_national_number_edit_text);
Button billingAgreementButton = view.findViewById(R.id.paypal_billing_agreement_button);
Button singlePaymentButton = view.findViewById(R.id.paypal_single_payment_button);
Switch offerPayLater = view.findViewById(R.id.offer_pay_later_switch);
Button singlePaymentPayLaterButton = view.findViewById(R.id.paypal_single_payment_pay_later_button);
Switch contactInformationSwitch = view.findViewById(R.id.contact_info_switch);
Switch amountBreakdownSwitch = view.findViewById(R.id.amount_breakdown_switch);

Expand All @@ -60,9 +61,10 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
buyerPhoneCountryCodeEditText.getText().toString(),
buyerPhoneNationalNumberEditText.getText().toString(),
contactInformationSwitch.isChecked(),
offerPayLater.isChecked(),
false,
amountBreakdownSwitch.isChecked()
);
isPayLaterEnabled = false;
});
billingAgreementButton.setOnClickListener(v -> {
launchPayPal(
Expand All @@ -71,9 +73,23 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
buyerPhoneCountryCodeEditText.getText().toString(),
buyerPhoneNationalNumberEditText.getText().toString(),
false,
offerPayLater.isChecked(),
false,
amountBreakdownSwitch.isChecked()
);
isPayLaterEnabled = false;
});

singlePaymentPayLaterButton.setOnClickListener(v -> {
launchPayPal(
false,
buyerEmailEditText.getText().toString(),
buyerPhoneCountryCodeEditText.getText().toString(),
buyerPhoneNationalNumberEditText.getText().toString(),
contactInformationSwitch.isChecked(),
true,
amountBreakdownSwitch.isChecked()
);
isPayLaterEnabled = true;
});

payPalClient = new PayPalClient(
Expand Down Expand Up @@ -207,6 +223,7 @@ private void handlePayPalResult(PaymentMethodNonce paymentMethodNonce) {
PayPalFragmentDirections.actionPayPalFragmentToDisplayNonceFragment(paymentMethodNonce);
action.setTransactionAmount(amount);
action.setDeviceData(deviceData);
action.setIsPayLaterSelected(isPayLaterEnabled);

NavHostFragment.findNavController(this).navigate(action);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/gold" />
<corners android:radius="12dp" />
</shape>

15 changes: 15 additions & 0 deletions Demo/src/main/res/drawable/button_paypal_pay_later.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="135"
android:startColor="@color/right_blue"
android:centerColor="@color/left_blue"
android:endColor="@color/middle_blue"
android:type="linear" />
<corners android:radius="12dp" />
<stroke
android:width="1dp"
android:color="@color/gold" />
</shape>

7 changes: 7 additions & 0 deletions Demo/src/main/res/drawable/button_paypal_single_payment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/right_blue" />
<corners android:radius="12dp" />
</shape>

71 changes: 59 additions & 12 deletions Demo/src/main/res/layout/fragment_display_nonce.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:padding="@dimen/margin_16"
android:background="@color/off_white"
tools:context=".DisplayNonceFragment">

<ScrollView
android:layout_width="match_parent"
android:id="@+id/scroll_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_weight="1">
android:layout_marginBottom="@dimen/margin_16"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/create_transaction"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -22,29 +27,71 @@
android:id="@+id/nonce"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_16"
android:padding="@dimen/margin_12"
android:background="@color/white"
android:textIsSelectable="true"
tools:text="Nonce" />
android:textSize="@dimen/text_size_body"
android:textColor="@color/slate"
android:fontFamily="monospace"
android:elevation="@dimen/card_elevation"
tools:text="Nonce: tok_abc123xyz" />

<TextView
android:id="@+id/nonce_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_16"
android:padding="@dimen/margin_12"
android:background="@color/white"
android:textIsSelectable="true"
tools:text="Nonce Details" />
android:textSize="@dimen/text_size_body"
android:textColor="@color/slate"
android:lineSpacingExtra="4dp"
android:elevation="@dimen/card_elevation"
tools:text="Nonce Details:\nType: PayPal\nEmail: [email protected]" />

<TextView
android:id="@+id/is_pay_later_selected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_16"
android:padding="@dimen/margin_12"
android:background="@color/white"
android:textIsSelectable="true"
android:textSize="@dimen/text_size_body"
android:textColor="@color/slate"
android:elevation="@dimen/card_elevation"
tools:text="Is Pay Later Selected: true" />

<TextView
android:id="@+id/device_data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_12"
android:background="@color/white"
android:textIsSelectable="true"
tools:text="Device Data" />
android:textSize="@dimen/text_size_body"
android:textColor="@color/slate"
android:fontFamily="monospace"
android:elevation="@dimen/card_elevation"
tools:text="Device Data: {correlation_id: xyz}" />
</LinearLayout>
</ScrollView>

<Button
android:id="@+id/create_transaction"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/create_transaction" />
android:paddingTop="@dimen/margin_16"
android:paddingBottom="@dimen/margin_16"
android:background="@drawable/button_paypal_single_payment"
android:textColor="@color/white"
android:textSize="@dimen/text_size_title"
android:textStyle="bold"
android:text="@string/create_transaction"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
30 changes: 21 additions & 9 deletions Demo/src/main/res/layout/fragment_paypal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:padding="@dimen/margin_10"
tools:context=".PayPalFragment">

<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginBottom="@dimen/margin_20"
android:hint="@string/paypal_buyer_email_address">

<com.google.android.material.textfield.TextInputEditText
Expand Down Expand Up @@ -38,7 +38,7 @@
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginBottom="@dimen/margin_20"
android:hint="@string/paypal_phone_national_number">

<com.google.android.material.textfield.TextInputEditText
Expand All @@ -55,12 +55,6 @@
android:layout_height="@dimen/margin_40"
android:text="Add Contact Information" />

<Switch
android:id="@+id/offer_pay_later_switch"
android:layout_width="match_parent"
android:layout_height="@dimen/margin_40"
android:text="@string/paypal_offer_pay_later" />

<Switch
android:id="@+id/amount_breakdown_switch"
android:layout_width="match_parent"
Expand All @@ -71,12 +65,30 @@
android:id="@+id/paypal_single_payment_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10"
android:layout_marginBottom="@dimen/margin_10"
android:background="@drawable/button_paypal_single_payment"
android:textColor="@color/white"
android:text="@string/paypal_single_payment" />

<Button
android:id="@+id/paypal_billing_agreement_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10"
android:layout_marginBottom="@dimen/margin_10"
android:background="@drawable/button_paypal_billing_agreement"
android:textColor="@color/white"
android:text="@string/paypal_billing_agreement" />

<Button
android:id="@+id/paypal_single_payment_pay_later_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10"
android:layout_marginBottom="@dimen/margin_10"
android:background="@drawable/button_paypal_pay_later"
android:textColor="@color/white"
android:text="@string/paypal_single_time_pay_later" />

</LinearLayout>
4 changes: 4 additions & 0 deletions Demo/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<argument
android:name="isPayLaterSelected"
android:defaultValue="false"
app:argType="boolean" />
<action
android:id="@+id/action_displayNonceFragment_to_createTransactionFragment"
app:destination="@id/createTransactionFragment"
Expand Down
12 changes: 12 additions & 0 deletions Demo/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="left_blue">#FF003087</color>
<color name="middle_blue">#FF001C64</color>
<color name="right_blue">#FF0070E0</color>
<color name="gold">#FFFFD140</color>
<color name="slate">#FF001435</color>
<color name="off_white">#FFFAF8F5</color>
<color name="white">#FFFFFFFF</color>
<color name="green">#008C20</color>

</resources>
14 changes: 14 additions & 0 deletions Demo/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="margin_8">8dp</dimen>
<dimen name="margin_10">10dp</dimen>
<dimen name="margin_12">12dp</dimen>
<dimen name="margin_16">16dp</dimen>
<dimen name="margin_20">20dp</dimen>
<dimen name="margin_40">40dp</dimen>
<dimen name="card_corner_radius">8dp</dimen>
<dimen name="card_elevation">2dp</dimen>
<dimen name="text_size_title">16sp</dimen>
<dimen name="text_size_body">14sp</dimen>
</resources>

2 changes: 2 additions & 0 deletions Demo/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<string name="reset">Reset</string>
<string name="settings">Settings</string>
<string name="nonce_placeholder">Nonce: %s</string>
<string name="is_pay_later_enabled_placeholder">Is Pay Later Selected: %s</string>
<string name="device_data_placeholder">Device Data: %s</string>
<string name="google_pay">Google Pay</string>
<string name="paypal_button">PayPal</string>
Expand Down Expand Up @@ -82,6 +83,7 @@
<string name="paypal_phone_national_number">Buyer Phone National Number</string>
<string name="paypal_single_payment">Single Payment</string>
<string name="paypal_billing_agreement">Billing Agreement</string>
<string name="paypal_single_time_pay_later">Single Payment Pay Later</string>
<string name="paypal_intent_type">Intent Type</string>
<string name="paypal_landing_page_type">Landing Page Type</string>
<string name="paypal_intent_authorize">Authorize</string>
Expand Down
Loading