Error occur in Citrus Payment Integration

92 views Asked by At

I just want to use citrus payment integration and when i just click on buy now button than its getting error and my app has been crash and mainly the error comes in CheckUserLogin and checkuserlogin method. I don't understand how to resolve this problem?

Error

        java.lang.NullPointerException: Attempt to invoke virtual method 'void com.citrus.sdk.network.e.d()' on a null object reference
      at com.citrus.sdk.e.d(Unknown Source)
          at com.citrus.sdk.CitrusClient.signOut(Unknown Source)
        at com.citrus.sdk.CitrusClient$15.error(Unknown Source)
       at com.citrus.sdk.e.a(Unknown Source)
     at com.citrus.sdk.e.a(Unknown Source)
    at com.citrus.sdk.e$1.error(Unknown Source)
       at com.citrus.sdk.e.a(Unknown Source)
at com.citrus.sdk.e.a(Unknown Source)
 at com.citrus.sdk.e.b(Unknown Source)
  at com.citrus.sdk.CitrusClient.getPrepaidToken(Unknown Source)
  at com.citrus.sdk.CitrusClient.isUserSignedIn(Unknown Source)
  at com.codeexpertise.eshop.startup.PayPalCheckoutActivity.checkUserLogin(PayPalCheckoutActivity.java:85)
at com.codeexpertise.eshop.startup.PayPalCheckoutActivity.onResume(PayPalCheckoutActivity.java:81)

PayPal Checkout Activity. java (This is the java file where the checkuserlogin method is declared and in the error its show the error in checkuserlogin)

public class PayPalCheckoutActivity extends Fragment implements View.OnClickListener {

    private TextView textMessage = null;
    private CitrusClient citrusClient = null;
    private Button btnSignout = null;
    private Button btnUserManagement = null;
    private Button btnWalletPayment = null;
    public boolean isUserLoggedIn = false;

    public PayPalCheckoutActivity() {
    }

    public static PayPalCheckoutActivity newInstance() {
        return new PayPalCheckoutActivity();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_ui, container, false);
        textMessage = (TextView) rootView.findViewById(R.id.txt_message);

        btnUserManagement = (Button) rootView.findViewById(R.id.btn_user_management);
        btnWalletPayment = (Button) rootView.findViewById(R.id.btn_user_wallet);
        btnSignout = (Button) rootView.findViewById(R.id.btn_logout);
        btnSignout.setOnClickListener(this);

        return rootView;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        citrusClient = CitrusClient.getInstance(getActivity());

    }

    @Override
    public void onClick(View v) {
        citrusClient.signOut(new Callback<CitrusResponse>() {
            @Override
            public void success(CitrusResponse citrusResponse) {
                ((UIActivity) getActivity()).showSnackBar(citrusResponse.getMessage());

                textMessage.setText("Please Sign In or Sign Up the user.");
                btnSignout.setVisibility(View.GONE);
                btnUserManagement.setVisibility(View.VISIBLE);
                btnWalletPayment.setVisibility(View.GONE);
            }

            @Override
            public void error(CitrusError error) {
                ((UIActivity) getActivity()).showSnackBar(error.getMessage());
            }
        });
    }

    @Override
    public void onResume() {
        super.onResume();
        checkUserLogin();
    }

    void checkUserLogin() {
        citrusClient.isUserSignedIn(new Callback<Boolean>() {
            @Override
            public void success(Boolean isUserLoggedIn) {
                PayPalCheckoutActivity.this.isUserLoggedIn = isUserLoggedIn;
                if (isUserLoggedIn) {
                    citrusClient.getProfileInfo(new Callback<CitrusUser>() {
                        @Override
                        public void success(CitrusUser citrusUser) {
                            textMessage.setText("Welcome " + citrusUser.getEmailId());
                            btnWalletPayment.setVisibility(View.VISIBLE);
                            btnUserManagement.setVisibility(View.GONE);
                            btnSignout.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void error(CitrusError error) {
                            textMessage.setText("Welcome Back");
                            btnWalletPayment.setVisibility(View.VISIBLE);
                            btnUserManagement.setVisibility(View.GONE);
                            btnSignout.setVisibility(View.VISIBLE);
                        }
                    });
                } else {
                    textMessage.setText("Please Sign In or Sign Up the user.");
                    btnWalletPayment.setVisibility(View.GONE);
                    btnUserManagement.setVisibility(View.VISIBLE);
                    btnSignout.setVisibility(View.GONE);
                }
            }

            @Override
            public void error(CitrusError error) {
                textMessage.setText(error.getMessage());
            }
        });
    }
}
0

There are 0 answers