2013-10-24 44 views
1

我要實現我的春天web應用程序的貝寶自適應支付。我參考下面的鏈接和執行流https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/gs_AdaptivePayments/我如何獲得貝寶自適應支付報酬響應

我按照以下步驟, 第1步: 獲取Paykey通過使用沙箱API憑證

公共類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", "[email protected]") 
           .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

後付款成功後貝寶重定向控制到http://www.mytestapp.com/getPaypalResponse。但問題是我無法獲得響應參數。我無法獲得paykey,receiveremail,ack等答覆參數......我不知道我的錯誤是什麼。請糾正我,如果我錯了

感謝 塞特希乙

回答

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(); 

要設置的屬性是:

  • acct1.UserName
  • acct1.Password
  • service.RedirectURL
  • PrimaryPayPalAccount
  • ...

的PayRequest具有請求信封,動作類型(例如付款),取消網址,退貨網址,貨幣代碼,ReceiverList以及預批准密鑰。

0

this paypal link列出您需要用於獲取付款詳情的參數。一旦付款後客戶返回網站,您可以發送請求。交易ID,paykey或trackingid中的任何一個都足夠了。由於paykey已經可以與你一起使用,你可以使用它。這種情況的示例代碼是在github上可用.The確切鏈路爲servlet是this,併爲sdk