在经典ASP中使用Paypal REST API [英] Using Paypal REST API with Classic ASP

查看:122
本文介绍了在经典ASP中使用Paypal REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码对Paypal API进行简单调用:

I am trying to make a simple call to Paypal API with the follow code:

On error resume next

Set objHTTP = CreateObject("Microsoft.XMLHTTP")
objHTTP.open "POST", "https://api.sandbox.paypal.com/v1/oauth2/token", False

objHTTP.setRequestHeader "Accept", "application/json"
objHTTP.setRequestHeader "Accept-Language", "en_US"
objHTTP.setRequestHeader "Authorization", "Basic " & Base64Encode("client-id:secret")
objHTTP.send "grant_type=client_credentials"

Response.Write err.description & " | " & err.number

但是它返回错误:

The download of the specified resource has failed

我可以与de Postman毫无问题地进行此通话.我在本地主机中,我不在自己的网站上使用SSL(不知道它是否会受到影响).

I can do this call with de Postman without problem. I am in localhost and Im not using a SSL on my site (dont know if its affect).

推荐答案

要解决我的问题,我正在使用NVP API,现在我正在做类似的事情

To solve my problem I am using the NVP API and now I am doing something like this

Set objHTTP = CreateObject("Msxml2.ServerXMLHTTP.6.0")
objHTTP.open "POST", "https://api-3t.sandbox.paypal.com/nvp", False

Dim data
data = "USER=" & paypal_user_name &_
"&PWD=" & paypal_psw &_
"&SIGNATURE=" & paypal_signature &_
"&VERSION=204.0" &_
"&RETURNURL=" & return &_
"&CANCELURL=" & cancel &_
"&PAYMENTREQUEST_0_PAYMENTACTION=Sale" &_
"&PAYMENTREQUEST_0_AMT=" & Request.QueryString("val") &_
"&PAYMENTREQUEST_0_CURRENCYCODE=BRL" &_
"&L_PAYMENTREQUEST_0_NAME0=" & Request.QueryString("pac") &_
"&L_PAYMENTREQUEST_0_AMT0=" & Request.QueryString("val") &_
"&NOSHIPPING=1" &_
"&METHOD=SetExpressCheckout"

objHTTP.send data

它的工作非常好

这篇关于在经典ASP中使用Paypal REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆