Intent Order Giving Bad Request

varunjain2610
New Community Member

Hi All,

 

I am trying integrate Paypal with legacy Paypal and using intent as order.

 

But gettng 400 as response. I am looking to get a orderId which I can furthur use in authorization later in the checkout flow.

 

Below is the sample code:

 

 

 

 

 

<!DOCTYPE html>

<head>
    <!-- Add meta tags for mobile and IE -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

<body>
    <!-- Set up a container element for the button -->
    <div id="paypal-button-container"></div>

    <!-- Include the PayPal JavaScript SDK -->
    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD&intent=order"></script>

    <script>
        // Render the PayPal button into #paypal-button-container
        paypal.Buttons({

            // Set up the transaction
            createOrder: function(data, actions) {
                return actions.order.create({
                    purchase_units: [{
                        amount: {
                            value: '0.01'
                        }
                    }]
                });
            },

            // Finalize the transaction
            onApprove: function(data, actions) {
                return actions.order.capture().then(function(details) {
                    // Show a success message to the buyer
                    alert('Transaction completed by ' + details.payer.name.given_name + '!');
                });
            }


        }).render('#paypal-button-container');
    </script>
</body>
    

 

 

 

Response:

debug_id: "d0830bf49cbf3"details: [{field: "/intent", value: "ORDER", location: "body", issue: "INVALID_PARAMETER_VALUE",…}],links: [{href: "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_VALUE",…}],message: "Request is not well-formed, syntactically incorrect, or violates schema.",name: "INVALID_REQUEST"

 

I get error as order being incorrect parameter value, but below documentation states order as correct value.

https://developer.paypal.com/docs/checkout/reference/customize-sdk/#query-parameters

 

 

Will appreciate any help here.

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.