Search code examples
androidpaypalpaypal-android-sdk

Why i can't get paymentId with PayPal Native-Checkout Android


Hi i have mobile application using paypal sdk ,

i have create configure my application with paypal , all proccess going well but when the payment done i get only PayerId and OrderId ,

for PaymentId i got null ,

the payment id very important for me because i'm sending it to my server to check if payment done proccess the server for client .

this is my app config

         config = new CheckoutConfig(
            getApplication(),
            "APP_PAYPAL_CLIENT_ID",
            Environment.SANDBOX,
            String.format("%s://paypalpay", "APPLICATION_ID"),
            CurrencyCode.USD,
            UserAction.PAY_NOW,
            new SettingsConfig(
                    true,
                    false
            )
    );
    PayPalCheckout.setConfig(config);


    payPalButton = findViewById(R.id.payPalButton);

    payPalButton.setup(
            new CreateOrder() {
                @Override
                public void create(@NotNull CreateOrderActions createOrderActions) {
                    ArrayList purchaseUnits = new ArrayList<>();
                    purchaseUnits.add(
                            new PurchaseUnit.Builder()
                                    .amount(
                                            new Amount.Builder()
                                                    .currencyCode(CurrencyCode.USD)
                                                    .value("10.00")
                                                    .build()
                                    )
                                    .build()
                    );
                    Order order = new Order(
                            OrderIntent.CAPTURE,
                            new AppContext.Builder()
                                    .userAction(UserAction.PAY_NOW)
                                    .build(),
                            purchaseUnits
                    );
                    createOrderActions.create(order, (CreateOrderActions.OnOrderCreated) null);
                }
            },
            new OnApprove() {
                @Override
                public void onApprove(@NotNull Approval approval) {
                    approval.getOrderActions().capture(new OnCaptureComplete() {
                        @Override
                        public void onCaptureComplete(@NotNull CaptureOrderResult result) {
                            Log.i("CaptureOrder", String.format("CaptureOrderResult: %s", result));
                            Log.i("CaptureOrder", String.format("CaptureOrderResult: %s", approval.getData().getOrderId()));
                            Log.i("CaptureOrder", String.format("CaptureOrderResult: %s", approval.getData().getPaymentId()));
                            Log.i("CaptureOrder", String.format("CaptureOrderResult: %s", approval.getData().getPayerId()));

                            

                        }


                    });



                }
            }

    );

Solution

  • Finally, I found the solution :

    1. In the new PayPal Native-Checkout Android SDK, they don't provide paymentId; you can only get PayerId and OrderId
    2. I use the OrderId; I send the OrderId to my server then. I use PayPal PHP SDK V2 to get the Order details response, which has PaymentId and all other payment information.