0
votes

I have started Paypal payment gateway integration in my android application. But the issue is - During Sandbox testing Paypal payment screen is showing but after fill the details(Paypal login credentials) to proceed further showing the
404 - RESOURCE_NOT_FOUND. The specified resource does not exist.

Steps I follows -

1- Set the PayPalConfiguration.ENVIRONMENT_SANDBOX mode.
2- Set the Client_ID
3- Set currency USD

Also I tried Production mode change all the required setting but in this case got the
429 - Multiple hitting issue.

I spend my whole day to resolve this issue with my friend as well but not find the success.

1- Is Paypal restrict Sandbox testing mode or Only restrict this services in India?
2- What is the solution to resolve this issues?

or Paypal remove Sandbox testing service or I need to implement the BrainTree SDK for paypal integration ?

Start of My Activity Class

public class MainActivity extends AppCompatActivity { private static final String TAG = "paymentExample"; private static final String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_SANDBOX; private static final String PAYMENT_TYPE = "USD"; private static final String CONFIG_CLIENT_ID = "HERE IS MY CLIENT ID CODE";

private static final int REQUEST_CODE_PAYMENT = 1;
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.activity_main);

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

public void onBuyPressed(View pressed) {
    PayPalPayment thingToBuy = getThingToBuy();
    Intent intent = new Intent(MainActivity.this, PaymentActivity.class);
    intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
    intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
    startActivityForResult(intent, REQUEST_CODE_PAYMENT);
}

private PayPalPayment getThingToBuy() {
    return new PayPalPayment(new BigDecimal("0.1"), PAYMENT_TYPE, "eSIM",
            PayPalPayment.PAYMENT_INTENT_SALE);
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.i(TAG, data.toString());
    if (requestCode == REQUEST_CODE_PAYMENT) {
        if (resultCode == Activity.RESULT_OK) {
            PaymentConfirmation confirm =
                    data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
            if (confirm != null) {
                try {
                    Log.i(TAG, confirm.toJSONObject().toString(4));
                    Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));
                } catch (JSONException e) {
                    Log.e(TAG, "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i(TAG, "The user canceled.");
        } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i(
                    TAG,
                    "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
        }
    } 
}

@Override
public void onDestroy() {
    // Stop service when done
    stopService(new Intent(this, PayPalService.class));
    super.onDestroy();
}

} End of Activity Class

ERROR Stack Log

E/paypal.sdk: request failure with http statusCode:404,exception:Not Found
2021-02-15 21:48:22.046 3106-3200/com.claytech.paypaldemoapplication E/paypal.sdk: Exception parsing server response
org.json.JSONException: End of input at character 0 of 
at org.json.JSONTokener.syntaxError(JSONTokener.java:460)
at org.json.JSONTokener.nextValue(JSONTokener.java:101)
at com.paypal.android.sdk.cw.m(Unknown Source:7)
at com.paypal.android.sdk.fm.d(Unknown Source:0)
at com.paypal.android.sdk.ci.a(Unknown Source:21)
at com.paypal.android.sdk.cm.a(Unknown Source:58)
at com.paypal.android.sdk.cq.onResponse(Unknown Source:45)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2021-02-15 21:48:22.057 3106-3200/com.claytech.paypaldemoapplication E/paypal.sdk: request failed with server response:
2021-02-15 21:48:22.075 3106-3106/com.claytech.paypaldemoapplication E/paypal.sdk: INTERNAL_SERVER_ERROR
1
There isn't enough information about your implementation here to be able to help, such as how you are communicating with PayPal, whether it is a client-side-only or API-based integration, your request and the full error response, etcPreston PHX
@PrestonPHX thanks for reply I have edited my question and add the stack log as well. For now I am using it client side payment in android.amardeep

1 Answers

1
votes

The PayPal Android SDK is deprecated, so it seems you're using a deprecated solution. If you need a native SDK, Express Checkout via Braintree is the only one available. However, you do need a server or webservice to use Braintree as there is a server-side portion to that integration.

Alternatively, you can integrate the v2 Create Order API on your server or webservice and use the rel:approve URL to open a browser from your native app, and have the return URL be a deeplink to your app which then triggers a Capture Order call from your server.

As you can see, all solutions need a server or webservice.