-2

I am integrating affirm into my website built with ASP classic and JQuery. In the affirm documentation it is asking to use cUrl or php to send my API keys and i'm extremely confused as how to accomplish this with my tech stack. Any help would be great. Thanks in advance. The documentation that I am referring to is linked below.

https://docs.affirm.com/affirm-developers/docs/create-a-charge

curl https://sandbox.affirm.com/api/v2/charges
     -X POST
     -u "{public_api_key}:{private_api_key}"
     -H "Content-Type: application/json"
     -d '{"checkout_token": "{checkout_token}","order_id": "{order_id}"}'
user692942
  • 16,398
  • 7
  • 76
  • 175
  • 1
    You can't use Ajax for this. It would be a massive security hole. That's why they tell you to do it server side. – Quentin Jun 26 '20 at 22:42
  • @Quentin Correct. Im not too familiar with ASP, thats why Im trying to figure out how to accomplish this. – Joel Ferrales Jun 26 '20 at 22:45
  • 2
    Your question title is specifically about AJAX. If you want to do it from Classic ASP (and it doesn't seem like a good idea to do new development in that in 2020), then ask about that … and make some sort of effort. Pick a programming language (Classic ASP isn't one, its a framework that supports multiple languages). Figure out how to make an HTTP request. Ask a more specific question. – Quentin Jun 26 '20 at 22:48

1 Answers1

0

This is the ASP equivalent of the PHP in your link which obtains a JSON response

set objJson = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")
  objJson.open "POST", "https://sandbox.affirm.com/api/v2/charges", false
  objJson.SetRequestHeader "Content-Type", "application/json"
  objJson.SetRequestHeader "User-Agent", "ASP/3.0"
  objJson.send  "{""checkout_token"": " & Request.Form("checkout_token") & "}"

You can then use objJson.ResponseText to get the contents of your JSON response

John
  • 4,658
  • 2
  • 14
  • 23