user2581076
user2581076

Reputation:

Error in sending money in paypal sandbox account in android

Following this paypal android examplehere created business account and personal account in sandbox trying make a transaction but amount is not detected from personal account and not adding in business account.here is my code.

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

    Intent intent = new Intent(this, PayPalService.class);

    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

    startService(intent);
}

public void onBuyPressed(View pressed) {
    PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal("1.75"), "USD", "hipster jeans");
    Intent intent = new Intent(this, PaymentActivity.class);

    intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
    intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);

    // It's important to repeat the clientId here so that the SDK has it if Android restarts your 
    // app midway through the payment UI flow.
    intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "credential-from-developer.paypal.com");
    intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "your-customer-id-in-your-system");
    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

    startActivityForResult(intent, 0);
}

@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
        if (confirm != null) {
            try {
                Log.i("paymentExample", confirm.toJSONObject().toString(4));

                // TODO: send 'confirm' to your server for verification.
                // see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                // for more details.

            } catch (JSONException e) {
                Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
            }
        }
    }
    else if (resultCode == Activity.RESULT_CANCELED) {
        Log.i("paymentExample", "The user canceled.");
    }
    else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
        Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
    }
}

Logs:

  10-23 01:06:05.979: I/paymentExample(10959): {
10-23 01:06:05.979: I/paymentExample(10959):     "payment": {
10-23 01:06:05.979: I/paymentExample(10959):         "short_description": "hipster jeans",
10-23 01:06:05.979: I/paymentExample(10959):         "amount": "1.75",
10-23 01:06:05.979: I/paymentExample(10959):         "currency_code": "USD"
10-23 01:06:05.979: I/paymentExample(10959):     },
10-23 01:06:05.979: I/paymentExample(10959):     "client": {
10-23 01:06:05.979: I/paymentExample(10959):         "platform": "Android",
10-23 01:06:05.979: I/paymentExample(10959):         "paypal_sdk_version": "1.2.1",
10-23 01:06:05.979: I/paymentExample(10959):         "product_name": "PayPal Android SDK; ",
10-23 01:06:05.979: I/paymentExample(10959):         "environment": "mock"
10-23 01:06:05.979: I/paymentExample(10959):     },
10-23 01:06:05.979: I/paymentExample(10959):     "proof_of_payment": {
10-23 01:06:05.979: I/paymentExample(10959):         "rest_api": {
10-23 01:06:05.979: I/paymentExample(10959):             "state": "approved",
10-23 01:06:05.979: I/paymentExample(10959):             "payment_id": "API-PAYMENT-ID-1843"
10-23 01:06:05.979: I/paymentExample(10959):         }
10-23 01:06:05.979: I/paymentExample(10959):     }
10-23 01:06:05.979: I/paymentExample(10959): }

it is says state approved but in sandbox console amount is not deducted and for business account amount is not added,not getting what problem is help me.

Upvotes: 0

Views: 2312

Answers (2)

YuDroid
YuDroid

Reputation: 1639

In your onBuyPressed Method, you have used

intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);

And then again in the same method, you are using like this:

intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "credential-from-developer.paypal.com");

Replace this with the actual CLIENT_ID. It will solve your problem.

Upvotes: 1

PX Developer
PX Developer

Reputation: 8145

Your EXTRA_PAYPAL_ENVIRONMENT is set to ENVIRONMENT_NO_NETWORK. Try to use ENVIRONMENT_SANDBOX if you want to use your test accounts or ENVIRONMENT_PRODUCTION to use real money (remember to use the right IDs and mails).

And by the way, I think you should hide your CONFIG_CLIENT_ID and CONFIG_RECEIVER_EMAIL from the post since it's your private information.

Upvotes: 1

Related Questions