paypal订单捕获java,paypal获取交易订单信息api(python实现)

获取access_token,需要ClientId和ClientSecret

https://developer.paypal.com/docs/api/overview/#make-your-first-call

curl -v https://api.sandbox.paypal.com/v1/oauth2/token \

-H "Accept: application/json" \

-H "Accept-Language: en_US" \

-u "client_id:secret" \

-d "grant_type=client_credentials" /v1/oauth2/tokenThe get access token endpoint.

client_idYour client ID.

secretYour secret.

grant_typeThe grant type. Set to client_credentials.

返回: {

"scope": "https://uri.paypal.com/services/subscriptions https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card https://uri.paypal.com/services/applications/webhooks openid https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.*",

"nonce": "2017-06-08T18:30:28ZCl54Q_OlDqP6-4D03sDT8wRiHjKrYlb5EH7Di0gRrds",

"access_token": "Access-Token",

"token_type": "Bearer",

"app_id": "APP-80W284485P519543T",

"expires_in": 32398

} postman操作测试

1、Download the latest version of Postman for your environment, and open Postman.

2、Select the POST method.

3、Enter the https://api.sandbox.paypal.com/v1/oauth2/token request URL.

4、On the Authorization tab, select the Basic Auth type and enter this information:

UsernameYour client ID.

PasswordYour secret.

5、On the Body tab, select x-www-form-urlencoded and enter this information:

keygrant_type

valueclient_credentials

6、Click Send.

python sdk获取access_token方法: api = Api({

"mode": "live", # sandbox or live

"client_id": client_id,

"client_secret": client_secret})

access_token = api.get_access_token()

print('access_token:' + access_token)

-------------------------------------------------------------------------------------------

2、通过tocken获取账单数据,返回账单和账单里的商品

接口地址:https://developer.paypal.com/docs/api/sync/v1/#transactions_get

url = 'https://api.paypal.com/v1/reporting/transactions?start_date=2018-12-16T00:00:00%2B0800&end_date=2018-12-30T00:00:00%2B0800&page_size=500&page=1&fields=all'

headers = {"Authorization": "bearer " + access_token, 'Content-Type': 'application/json'}

# headers = {"Authorization": "bearer " + access_token['access_token'],'Content-Type': 'application/json'}

# params = {'key1': 'value1', 'key2': ['value2', 'value3']}

r = requests.get(url, headers=headers)

with open('text.txt', 'w') as f:

f.write(r.text)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值