paypal支付与salesforce的集成

时间:2014-02-25 16:53:34

标签: paypal

我在向第三方发出api电话时很新,在向paypal请求获取服务令牌时我遇到了问题。

我使用构造函数来做这个..

public with share class payPalCallouts {     public string reqBody {get; set;}

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]

提前感谢我期待您的回复:)

1 个答案:

答案 0 :(得分: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','info@seassociation.com');//'ro.sg-facilitator@plaza-network.com'
        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());

这可能有助于您解决问题