Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • PayPal's library - onActivityResult -ANDROID

    • 0
    • 0
    • 0
    • 6
    • 0
    • 0
    • 0
    • 402
    Answer it

    Hello, I am an Italian developer, I was trying to implement my PayPal's library within my e-commerce App.
    I created two test accounts, and it seems to work, but there is a problem.

    If during the phase of sending money, I deactivate the Internet connection, you get a alert that read: "problems with the server. - CANCEL - TRY AGAIN -." If I click CANCEL and go back, the user may believe that you have not bought anything, instead the money has been transferred, and the "RESULT_OK" code doesn't return in onActivityResult.
    Similarly, when it comes out the alert, if I active connection again and I click on TRY AGAIN, two payments are sent.
    Moreover , do you have any advices about other payment methods.

    Can you help me ?

    Thanks ! ! !

 6 Answer(s)

  • I implemented this, but there is that problem:

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CODE_PAYMENT) {
            if (resultCode == Activity.RESULT_OK) {
                PaymentConfirmation confirm = data
                        .getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
                if (confirm != null) {
                    try {
                        Log.e("Show", "PAYPAL : "
                                + confirm.toJSONObject().toString(4));
                        Log.e("Show",
                                "PAYPAL : "
                                        + confirm.getPayment().toJSONObject()
                                                .toString(4));
                        /**
                         * TODO: send 'confirm' (and possibly
                         * confirm.getPayment() to your server for verification
                         */
                        //totos.setText("Conferma di pagamento ricevuta da PayPal");
                        Toast.makeText(getApplicationContext(),
                                "Conferma di pagamento ricevuta da PayPal",
                                Toast.LENGTH_LONG).show();
    
                        String fromEmail = "xxxxx@gmail.com";
                        String fromPassword = "xxxxx";
                        String toEmails = "xxxxxxxx@hotmail.it";
    
                        String emailSubject = "ORDINE";
    
                        String emailBody = "testo di prova dell'ordine";
    
                        new SendMailTask(MainActivity.this).execute(fromEmail,
                                fromPassword, toEmails, emailSubject, ordine);
    
                    } catch (JSONException e) {
                        Toast.makeText(getApplicationContext(),
                                "Errore nel server di PayPal : ",
                                Toast.LENGTH_LONG).show();
                    }
                }
            } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
                Toast.makeText(getApplicationContext(),
                        "Pagamento non valido.", Toast.LENGTH_LONG).show();
            }
        }
    }
    
  • the problem is that if I send money and I disconnect internet before it gets the RESULT_OK , I cannot intercept the answer because I'm not connected, so I did not realize whether the payment succeded or not.

  • The problem is that if I unplug the connection during the transfer, an alert blocks the progress dialog that says "Transfer in progress", and does not return the RESULT_OK (even if the payment succeeded!).

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: