function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rajesh_yrajesh_y 

authorization error in paypal integration for payrequest

Hi All 

 

 

this is my code 

public class pay
 {
 public void transefer()
{
 Http h = new Http();
 HttpRequest req = new HttpRequest();
 //String url1 = 'https://api-3t.sandbox.paypal.com/2.0/';
 
 String url='https://svcs.sandbox.paypal.com/AdaptivePayments/Pay ';
 string un='radhik_1310032695_biz_api1.dskvap.com';
 //string un='radhik_1311331870_per@dskvap.com';
 //string pw='311331850';
 string pw='1310032746';
   string sig ='ALIeMNX23qxDxiFSuqGvrVD7fZmrAiLQwRfHOZzphVWLml57Bz8XsGA5';

 string body='<?xml version="1.0" encoding="utf-8" ?>';
body+='<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">';
 body+='<SOAP-ENV:Header><RequesterCredentials xmlns="urn:ebay:api:PayPalAPI">';
body+='<Credentials xmlns="urn:ebay:apis:eBLBaseComponents">';
body+='<Username>'+un+'</Username><Password>'+pw+'</Password><Signature>'+sig+'</Signature>';
body+='</Credentials></RequesterCredentials></SOAP-ENV:Header>';
body+='<SOAP-ENV:Body><PayRequest xmlns="http://svcs.paypal.com/types/ap">';
 body+='<actionType xmlns="">PAY</actionType>';
 body+='<requestEnvelope xmlns=""><errorLanguage>en_US</errorLanguage></requestEnvelope>';
 body+='<cancelUrl xmlns="">http://www.xchaos.co.uk</cancelUrl>';
body+='<currencyCode xmlns="">USD</currencyCode><feesPayer xmlns="">EACHRECEIVER</feesPayer>';
 body+='<receiverList xmlns=""> <receiver><amount>100</amount><email>radhik_1311331396_biz@dskvap.com</email></receiver></receiverList>';
 body+='<clientDetails><ipAddress>183.82.96.26</ipAddress><applicationId>APP-80W284485P519543T</applicationId></clientDetails>';
  body+=' <ipnNotificationUrl>http://www.xchaos.co.uk</ipnNotificationUrl>';
     // body+='<trackingId>1234</trackingId>';
 
      body+='<returnUrl xmlns="">http://www.xchaos.co.uk</returnUrl>';
    body+='</PayRequest>';
    
  body+='</SOAP-ENV:Body>';
  
body+='</SOAP-ENV:Envelope>';
 
   req.setBody(body);
  req.setEndpoint(url);
  //req.setEndpoint(url1);
  req.setMethod('POST');
  req.setHeader('Content-length', '1753' );
  req.setHeader('Content-Type', 'text/xml;charset=UTF-8'); 
  req.setHeader('SOAPAction','');
  req.setHeader('Host','api-aa.sandbox.paypal.com');
  HttpResponse res =h.send(req);
  String xml = res.getBody();
  system.debug('----------'+res.getbody());
   
}
 
}

 But am getting error authorization failed username and password invalid.

 

whats the problem in my code.

 

thank you in advance.

 

My OwnMy Own

 

 

Is your username and password correct? 

 

Can you please verify your credentials, seems problem with them(strike out).  "Authentication failed. API credentials are incorrect."

 

string un='radhik_1310032695_biz_api1.dskvap.com'; 

//string un='radhik_1311331870_per@dskvap.com';