Error with EXTRA_PAYPAL_CONFIGURATION on android

3

I am trying to integrate the payment gateway to my service in android but at the moment of entering EXTRA_PAYPAL_CONFIGURATION in my code it appears to me as if it did not exist:

intent.putExtra(PaymentActivity.EXTRA_PAYPAL_CONFIGURATION,m_configuration);

Does anyone know how I can fix it or can I replace it?

    
asked by cesg.dav 11.08.2017 в 20:54
source

1 answer

3

You are accessing a Field that you do not have in Activity ( PaymentActivity ), which I do not think extends from PayPalService .

intent.putExtra(PaymentActivity.EXTRA_PAYPAL_CONFIGURATION,m_configuration);

EXTRA_PAYPAL_CONFIGURATION is a field of the Service.

intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, m_configuration);

For the implementation I suggest you see this example :

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_paypal);

        DisplayMetrics metrics = new DisplayMetrics();
         getWindowManager().getDefaultDisplay().getMetrics(metrics);

        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffffff")));
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        Intent intent = new Intent(this, PayPalService.class);
        intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
        startService(intent);

        Log.e(TAG, "Alert Dialog");

        new AlertDialog.Builder(this)
        .setTitle("Notice")
        .setMessage(this.getString(R.string.disclaimer))
        .setCancelable(false)
        .setIcon(android.R.drawable.ic_dialog_alert)
        .setPositiveButton("Ok, I understand", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();

                PayPalPayment thingToBuy = getThingToBuy(PayPalPayment.PAYMENT_INTENT_SALE);
                Intent intent = new Intent(PaypalActivity.this, PaymentActivity.class);

                intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

                startActivityForResult(intent, REQUEST_CODE_PAYMENT);

            }

        })
       .setNegativeButton("Nevermind", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                PaypalActivity.this.finish();
            }
        })
        .show();
    }
    
answered by 11.08.2017 / 21:27
source