说回到sdk_config配置文件,下面是工程配置的例子。
配置在src/main/resources目录下面:
sdk_config.properties
1 # mode=sandbox 2 mode=live 3 # Account credentials (Add one or more API accounts here) 4 # Sandbox test account 5 # acct1.UserName = user1.gmail.com 6 # acct1.Password = XXXXXXXXXX 7 # acct1.Signature = XXXXXXXXXXXXXXXX 8 # acct1.AppId=APP-80W284485P519543T 9 10 # Live account (Need to fill in real user info) 11 12 acct1.UserName = user1.gmail.com 13 acct1.Password = XXXXXXXXXX 14 acct1.Signature = XXXXXXXXXXXXXXXX 15 # Optional if acct1 is used as third-party account. 16 # Subject user must grant permission to acct1 on Paypal website. 17 # Can support multiple subject users split by comma.(NOT PAYPAL STANDARD) 18 acct1.Subject = subjectUser1.gmail.com,subjectUser2.gmail.com 19 20 #Sandbox Email Address 21 sandbox.EmailAddress=platform.sdk.seller@gmail.com 22 23 # Connection Information 24 http.ConnectionTimeOut=30000 25 http.Retry=10 26 http.ReadTimeOut=30000 27 http.MaxConnection=100 28 http.IPAddress=127.0.0.1 29 30 # HTTP Proxy configuration 31 # If you are using proxy set http.UseProxy to true and replace the following values with your proxy parameters 32 http.UseProxy=false 33 http.ProxyPort=8080 34 http.ProxyHost=127.0.0.1 35 http.ProxyUserName=null 36 http.ProxyPassword=null 37 38 #Set this property to true if you are using the PayPal SDK within a Google App Engine java app 39 http.GoogleAppEngine = false 40 41 42 # Service Configuration 43 service.RedirectURL=https://www.sandbox.paypal.com/webscr&cmd= 44 service.DevCentralURL=https://developer.paypal.com 45 service.IPNEndpoint=https://ipnpb.sandbox.paypal.com/cgi-bin/webscr 46 47 # Multiple end-points configuration, while using multiple SDKs in combination, like Merchant and Permissions etc.. 48 # configure the end-points as shown below one for each service used, The existing service.EndPoint property is still 49 # supported for backward compatibility (using a single SDK) 50 # ------------------------------SANDBOX------------------------------ # 51 # Merchant Service (3 Token) 52 # service.EndPoint.PayPalAPI=https://api-3t.sandbox.paypal.com/2.0 53 # service.EndPoint.PayPalAPIAA=https://api-3t.sandbox.paypal.com/2.0 54 # Merchant Service (Certificate) 55 # service.EndPoint.PayPalAPI=https://api.sandbox.paypal.com/2.0 56 # service.EndPoint.PayPalAPIAA=https://api.sandbox.paypal.com/2.0 57 # Permissions Platform Service 58 # service.EndPoint.Permissions=https://svcs.sandbox.paypal.com/ 59 # AdaptivePayments Platform Service 60 # service.EndPoint.AdaptivePayments=https://svcs.sandbox.paypal.com/ 61 # AdaptiveAccounts Platform Service 62 # service.EndPoint.AdaptiveAccounts=https://svcs.sandbox.paypal.com/ 63 # Invoicing Platform Service 64 # service.EndPoint.Invoice=https://svcs.sandbox.paypal.com/ 65 66 # ------------------------------PRODUCTION------------------------------ # 67 # Merchant Service (3 Token) 68 service.EndPoint.PayPalAPI=https://api-3t.paypal.com/2.0 69 service.EndPoint.PayPalAPIAA=https://api-3t.paypal.com/2.0 70 71 # Merchant Service (Certificate) 72 # service.EndPoint.PayPalAPI=https://api.paypal.com/2.0 73 # service.EndPoint.PayPalAPIAA=https://api.paypal.com/2.0 74 # Permissions Platform Service 75 service.EndPoint.Permissions=https://svcs.paypal.com/ 76 service.EndPoint.AdaptiveAccounts=https://svcs.paypal.com/ 77 service.EndPoint.AdaptivePayments=https://svcs.paypal.com/ 78 service.EndPoint.Invoice=https://svcs.paypal.com/
说明:
1)Mode可以指定是Sandbox沙盒还是Live真实环境。实际上沙盒测试用来做少量测试还可以,大数据量又不支持真实交易数据导入,做数据太麻烦。
2)acct1是账户相关信息,username以及password还有signature需要在Paypal的卖家设置选项里获取,My Account > Profile > My Selling Tools > API Access。
3)在沙盒环境下AppId都是统一如下:
AppId=APP-80W284485P519543T
而生产环境下根据自己在Paypal developer注册的AppId填写,或者不填也能使用API。
4)配置中默认读取acc1的账户信息,如果配置有多个账户,则service对象仍然只使用acc1的账户权限。
这一点在官方的资料中也貌似没有明确说明。当需要读取多个账户的交易信息时,只有通过多个配置文件来实例化多个service,
或者在sdk_config.properties文件中单独设置自定义属性,将多个账户配置在同一个文件中,也是实例化多个service来实现。
5)acct1.subject是代理账户,假如acct1属于第三方账户,需要作为代理读取其他账户的交易信息,那么subject就是它所要代理读取的账户。
默认只能代理一个账户,如果要像例子中一样代理多个账户,仍然要在程序中将逗号分隔的多账户信息作处理,实例化多个service进行操作。
其他的一些配置项就不作说明,基本按照例子即可,需要哪部分API功能就去掉前面的注释符号。
Paypal获取Transaciton历史交易API初步研究(三)——配置文件
原文:http://www.cnblogs.com/kogen/p/4737600.html