ANNN CHOOOR
ANNN CHOOOR

Reputation: 115

Android Paypal SDK Error: Merchant does not Accept payments of this type

When i proceed to the last stage and want to pay the money to the Paypal using Android Paypal SDK in Android app i will get an error as

"Merchant does not Accept payments of this type"

I am using the live id credentials but at the last stage payment is not happening

And the code which i have used is below

package com.coded.sandeep;

import java.math.BigDecimal;
import java.util.StringTokenizer;

import org.json.JSONException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.paypal.android.sdk.payments.PayPalConfiguration;
import com.paypal.android.sdk.payments.PayPalPayment;
import com.paypal.android.sdk.payments.PayPalService;
import com.paypal.android.sdk.payments.PaymentActivity;
import com.paypal.android.sdk.payments.PaymentConfirmation;

public class PaypalActivity extends Activity {


    private static final String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_PRODUCTION;

    // note that these credentials will differ between live & sandbox environments.
    private static final String CONFIG_CLIENT_ID = "ASAHYxANvUGbBcXaLdhQWoDrO38JkUkYObXRaOF2FuOfa";



    private static PayPalConfiguration config = new PayPalConfiguration()
    .environment(CONFIG_ENVIRONMENT)
    .clientId(CONFIG_CLIENT_ID);

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

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

        intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);

        startService(intent);
    }

    public void onBuyPressed(View pressed) {

        PayPalPayment thingToBuy = getThingToBuy(PayPalPayment.PAYMENT_INTENT_SALE);

        Intent intent = new Intent(PaypalActivity.this, PaymentActivity.class);

        intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);

        startActivityForResult(intent, 0);

    }

     private PayPalPayment getThingToBuy(String paymentIntent) {

        Intent intent1 = getIntent();

        String message = "Freiends";
        String amount = "1.29";


        return new PayPalPayment(new BigDecimal(amount), "GBP", message,
                paymentIntent);

    }

    @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));

                } 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_EXTRAS_INVALID) {
            Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
        }
    }

    @Override
    public void onDestroy() {
        stopService(new Intent(this, PayPalService.class));
        super.onDestroy();
    }
}

How to correct the above error and make the payment successful to the merchant id . I am using business Merchant id

Logcat after payment using card:

06-20 01:10:22.402: W/DefaultRequestDirector(1295): Authentication error: Unable to respond to any of these challenges: {}
06-20 01:10:22.502: W/paypal.sdk(1295): U SN:14 PayPal Debug-ID: 406bd412549f4 [live, 2.2.2;release]
06-20 01:10:22.512: E/paypal.sdk(1295): request failure with http statusCode:401,exception:org.apache.http.client.HttpResponseException: Unauthorized
06-20 01:10:22.512: E/paypal.sdk(1295): request failed with server response:{"name":"UNAUTHORIZED_PAYMENT","message":"Unauthorized payment","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#UNAUTHORIZED_PAYMENT","debug_id":"406bd412549f4"}
06-20 01:10:22.732: I/Choreographer(1295): Skipped 61 frames!  The application may be doing too much work on its main thread.
06-20 01:10:22.842: E/PayPalService(1295): UNAUTHORIZED_PAYMENT

Upvotes: 3

Views: 3841

Answers (1)

Ind_KevinG
Ind_KevinG

Reputation: 1945

Be sure the merchant account has Pro permissions. Also, be sure the app has gone through the developer-approval process.

Upvotes: 2

Related Questions