2014-02-25 84 views
0

即時通訊新的調用第三方的API,我面臨的問題時,請求貝寶獲取安全令牌。貝寶付款整合與銷售隊伍

我使用構造這樣做..

公衆共享類payPalCallouts { 公共字符串reqBody {獲得;設置;}

public payPalCallouts(){ 

    http h = new http(); 
    httpRequest req = new httpRequest(); 
    req.setEndpoint('https://api.sandbox.paypal.com/v1/oauth2/token'); 
    reqBody = 'client_id={client-Id}&secret={secret}'; 
    req.setHeader('grant_type','client_credentials'); 
    req.setHeader('content-type','application/x-www-form-urlencoded'); 
    req.setMethod('POST'); 
    req.setBody(reqBody); 
    HttpResponse res = h.send(req); 

} 

}

我響應了日誌...

錯誤消息:System.HttpResponse [Status = Not Acceptable,StatusCode = 406]

在此先感謝我期待您的迴應:)

回答

0

可能調用您用於API調用的樣式是錯誤的嘗試使用此。

request.setHeader('X-PAYPAL-SECURITY-USERID','info_api1.yourapp.sg');//'ro.sg-facilitator_api1.plaza-network.com' 
     request.setHeader('X-PAYPAL-SECURITY-PASSWORD','FKZT3ASU54XGZZHB');//'1374056915' 
     request.setHeader('X-PAYPAL-SECURITY-SIGNATURE','A-FBfoAzZvCeJAyGObzzMXxWPyE7AWs3-cvEtjqXbLqK-EDfiq6liVLM');//'A6kjwB4yqgRkmh5yc.H4nIzJloRAApX0jYrFl6POnnezGBZS9BoLdGir' 
     request.setHeader('X-PAYPAL-APPLICATION-ID','APP-3XF78704HU642522W');//'APP-80W284485P519543T' 
     request.setHeader('X-PAYPAL-REQUEST-DATA-FORMAT','NV'); 
     request.setHeader('X-PAYPAL-RESPONSE-DATA-FORMAT','JSON'); 
     request.setHeader('X-PAYPAL-DEVICE-IPADDRESS','127.0.0.1');//'127.0.0.1' 
     request.setHeader('X-PAYPAL-REQUEST-SOURCE','merchant-php-sdk-2.0.96');//'merchant-php-sdk-2.0.96' 
     request.setHeader('X-PAYPAL-SANDBOX-EMAIL-ADDRESS','[email protected]');//'[email protected]' 
     request.setEndpoint('https://svcs.paypal.com/AdaptivePayments/Refund'); 
     request.setbody('transactionId='+Transaction_Id__c+'&requestEnvelope.errorLanguage=en_US&refundDetail.note=Accound ID'+objpayment.nric_no__c+'&refundDetail.date='+System.today()+'&currencyCode=SGD'); 
     system.debug('Request ______----'+request.getBody()); 
     if(!Test.isRunningTest()){ 
     HttpResponse response = h.send(request); 
     system.debug('Response '+response.getBody()); 

這可能會幫助你解決你的問題