-1

I am integrating Paypal's Checkout API into a legacy Classic ASP site.

When sending via this front end js:

        var postData = {paypal_order_check: 1, order_id: orderData.id};
        fetch('paypal_checkout_validate.asp', {
            method: 'POST',
            headers: {'Accept': 'application/json'},
            body: encodeFormData(postData)
        })

This is the payload that is being sent:

------WebKitFormBoundaryZrUIbyscgWBpTxX
Content-Disposition: form-data; name="paypal_order_check"

1
------WebKitFormBoundaryZrUIbyscgWBpTxX
Content-Disposition: form-data; name="order_id"

3JV215PS364212N
------WebKitFormBoundaryZrUIbyscgWBpTxX--

I am trying to 'request' these 2 variables paypal_order_check and order_id but cant figure out who do to that. A generic request or request.form does not work, but using this code (via https://github.com/rcdmk/aspJSON JSON class):

Set UTF8Enc = CreateObject("System.Text.UTF8Encoding") // .NET COMPONENT, required on the server app pool
Set JSON = new JSONobject

lngBytesCount = Request.TotalBytes
request_body = UTF8Enc.GetString(Request.BinaryRead(lngBytesCount))

Set request_json = JSON.parse(request_body)
   
Set JSON = nothing  

--> then I do get the entire payload into the request_json variable. But what next? I thought i could do paypal_order_check = request("paypal_order_check") - bit that is empty too.

Thanks

3
  • You will have to make a request / server roundtrip of your own to put the data and access it server-side. Commented Nov 26, 2023 at 10:30
  • Did you successfully received the payload data and put it in a javascript variable? Can you log the received data and see exactly the payload above? Commented Nov 27, 2023 at 5:59
  • This is the solution that worked for me in the end. I have ASPupload installed, so the 2nd option listed was easiest to implement. stackoverflow.com/questions/65158652/… Commented Nov 27, 2023 at 13:13

1 Answer 1

0

If the backend is expecting JSON, don't use encodeFormData(). That makes no sense.

Use JSON.stringify()

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.