我想为我的春季网络应用程序实现paypal自适应支付。我参考以下链接并实施流程https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/gs_AdaptivePayments/
我已按照以下步骤操作 步骤1: 使用沙盒API凭据获取Paykey
public class AdaptiveinstantPay {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
Document doc = Jsoup.connect("https://svcs.sandbox.paypal.com/AdaptivePayments/Pay")
.header("X-PAYPAL-SECURITY-USERID", "xxxxxx_api1.comforters-it.com")
.header("X-PAYPAL-SECURITY-PASSWORD", "xxxxxxxxxx")
.header("X-PAYPAL-SECURITY-SIGNATURE", "AiPC9BjkCyDFQXbSkoZcgqH3hpacATgu-TD5fG94GO04KCRlPl1d4hW4")
.header("X-PAYPAL-REQUEST-DATA-FORMAT", "NV")
.header("X-PAYPAL-RESPONSE-DATA-FORMAT", "NV")
.header("X-PAYPAL-APPLICATION-ID", "APP-80W284485P519543T")
.data("actionType", "PAY")
.data("currencyCode", "EUR")
.data("receiverList.receiver(0).amount", "55")
.data("receiverList.receiver(0).email", "xxxxxx@comforters-it.com")
.data("returnUrl", "http://www.mytestapp.com/getPaypalResponse")
.data("cancelUrl", "http://www.mytestapp.com/cancelPaypalPayment")
.data("requestEnvelope", "{errorLanguage:en_US, detailLevel:ReturnAll }")
.timeout(10 * 1000).post();
System.out.println(doc);
}
第2步: 我已经解析了Jsoup响应并获得了PayKey,之后我发送了https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=My-payKey
付款成功后,paypal将控件重定向到http://www.mytestapp.com/getPaypalResponse。但问题是我无法获得响应参数。我无法获得像paykey,receiveremail,ack等的响应参数......我不知道我的错误是什么。如果我错了,请纠正我
由于 SENTHIL B
答案 0 :(得分:0)
您可以使用PayPal提供的自适应支付服务类。它被称为自适应支付SDK。
最后你会做这样的事情:
Properties properties = getProperties(); // see below
PayRequest payRequest = new PayRequest();
// <initialize payRequest> - see below
AdaptivePaymentsService adaptivePaymentsService = new AdaptivePaymentsService(properties);
PayResponse payResponse = adaptivePaymentsService.pay(payRequest);
String payKey = payResponse.getPayKey();
您要设置的属性是:
PayRequest有一个请求信封,操作类型(例如PAY),取消网址,返回网址,货币代码,ReceiverList
和预先批准密钥。
答案 1 :(得分:0)
this paypal link列出了您需要用于获取付款详细信息的参数。一旦客户在付款后返回网站,您就可以发送请求。交易ID,paykey或trackingid中的任何一个就足够了。由于付款密钥已经可以使用,您可以使用它。 github中提供了此示例代码.servlet的确切链接为this,sdk。