Salesforce Paypal Integration

This is my Second Post for the integration of Salesforce With 3rd party Softwares using the HTTP calls. We may find many ways to integrate 3rd party API’s but the best is to use HTTP class.As we may not find the free/open source APPS in APP EXCHANGE all the times. so below are the steps to integrate the Paypal With Salesforce.You can use this method for any service like fedex,Mobiletransact… and so on.
1.)In Develop | Security | Remote Site Settings
Add https://api-3t.sandbox.paypal.com (For Sandbox). You need to get the Endpoint URL where the request is to be sent.
2.) Get the Paypal Sandbox Credentials for account (http://developer.paypal.com)
You will need
a.)Seller Account
Username
Password
Api Signature
b.)Buyer Account
You need to get the credentials for the services you want to consume.
Now as you have all the ground work done lets move to the implementation of the Apex code for integration.
Now From The Api of the Service you want to integrate get the details of the Mandatory variables ie :Paypal(Do Direct Payment Api)
After you set the variables as per the Api now you need to send the http request to the paypal server.
Http httpObject = new Http();
HttpRequest req = new HttpRequest();
String url = ‘https://api-3t.sandbox.paypal.com/2.0/’;
string un = ‘Your Username’;
string pw = ‘Your Password’;
string sig = ‘Your Signature’;
string soapXML=’Here soapXMl is the request String in XML format’;
req.setBody(soapXML);
req.setEndpoint(url);
req.setMethod(‘POST’);
req.setHeader(‘Content-length’, ‘1753’ );
req.setHeader(‘Content-Type’, ‘text/xml;charset=UTF-8’);
req.setHeader(‘SOAPAction’,”);
Now Send The Request
HttpResponse res = httpObject.send(req);
String xml = res.getBody();
The result will be an xml which can be parsed using XmlStreamReader
Now read the XML response and get the Paypal result
XmlStreamReader reader = res.getXmlStreamReader();
result = readXMLResponse(reader,’Ack’);
And you are done. feel free to comment or suggest ….


Source : http://www.saasanalogy.com/salesforce-paypal-integration/

Comments

Popular posts from this blog

Salesforce.com: Expression Operators in Salesforce lightning Components

Custom Calendar on VisualForce Page

Salesforce.com: Scheduled Apex