Skip to content

Commit

Permalink
NPE Check
Browse files Browse the repository at this point in the history
  • Loading branch information
AhlaamK-tap committed Oct 16, 2022
1 parent 5c18469 commit 60b7fbd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ protected void onCreate(Bundle savedInstanceState) {
overridePendingTransition(R.anim.slide_in_top, android.R.anim.fade_out);
if(PaymentDataSource.getInstance().getTransactionMode() == TransactionMode.PURCHASE){
paymentsClient = PaymentsUtil.createPaymentsClient(this);
possiblyShowGooglePayButton();
if(PaymentDataSource.getInstance().getGooglePaymentOptions().size()!=0){
possiblyShowGooglePayButton();
}


}
apperanceMode = ThemeObject.getInstance().getAppearanceMode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public class PaymentsUtil {
* @throws JSONException
*/
private static JSONObject getBaseRequest() throws JSONException {
if(PaymentDataSource.getInstance().getGooglePaymentOptions().size() != 0){
return new JSONObject().put("apiVersion", PaymentDataSource.getInstance().getGooglePaymentOptions().get(0).getApiVersion()).put("apiVersionMinor", PaymentDataSource.getInstance().getGooglePaymentOptions().get(0).getApiVersionMinor());
}else return null;
}

/**
Expand Down Expand Up @@ -186,6 +188,7 @@ private static JSONObject getBaseCardPaymentMethod() throws JSONException {
cardPaymentMethod.put("type", "CARD");
// System.out.println("Payment data"+PaymentDataSource.getInstance().getGooglePaymentOptions().get(0).getSupportedCardBrands());
JSONObject parameters = new JSONObject();
if(PaymentDataSource.getInstance().getGooglePaymentOptions().size() != 0)
parameters.put("allowedAuthMethods", new JSONArray(PaymentDataSource.getInstance().getGooglePaymentOptions().get(0).getAllowed_auth_methods()));
// parameters.put("allowedAuthMethods", getAllowedCardAuthMethods());
// parameters.put("allowedCardNetworks", getAllowedCardNetworks());
Expand Down Expand Up @@ -235,6 +238,7 @@ public static Optional<JSONObject> getIsReadyToPayRequest() {
isReadyToPayRequest.put(
"allowedPaymentMethods", new JSONArray().put(getBaseCardPaymentMethod()));


return Optional.of(isReadyToPayRequest);

} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ public class GooglePaymentViewHolder extends PaymentOptionsBaseViewHolder<Google
googlePayButton = view.findViewById(R.id.googlePayButton);

activity = (Activity) view.getContext();
possiblyShowGooglePayButton();
googlePayButton.setOnClickListener(
view1 -> requestPayment(view1)
if(PaymentDataSource.getInstance().getGooglePaymentOptions().size()!=0){
possiblyShowGooglePayButton();
googlePayButton.setOnClickListener(
view1 -> requestPayment(view1)

);
}

);

}

Expand Down Expand Up @@ -131,7 +134,7 @@ private void requestPayment(View view) {
}
PaymentDataRequest request =
PaymentDataRequest.fromJson(paymentDataRequestJson.get().toString());
// System.out.println("request value is>>>"+request.toJson());
System.out.println("request value is>>>"+request.toJson());

// Since loadPaymentData may show the UI asking the user to select a payment method, we use
// AutoResolveHelper to wait for the user interacting with it. Once completed,
Expand Down

0 comments on commit 60b7fbd

Please sign in to comment.