PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 4, 2022

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

 July 04, 2022     android, paypal, paypal-android-sdk     No comments   

Issue

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.


Answered By - Hassan Boutannoura
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing