1
votes

i want to implement paypal adaptive payment for my spring web application. i refer the following link and implement flow https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/gs_AdaptivePayments/

i have followed following steps, Step 1: Get Paykey by using sandbox API credentials

public class 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);

}

Step 2: i have parsed the Jsoup response and get the PayKey, After i have send https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=My-payKey

After payment success paypal redirect control to http://www.mytestapp.com/getPaypalResponse. But problem is i can't get response parameters. I unable get response parameters like paykey, receiveremail, ack ect... i dont know what is my mistake. Please correct me if i'm wrong

Thanks SENTHIL B

2

2 Answers

0
votes

You could just use the adaptive payment service classes provided by PayPal. It's called the adaptive payment SDK.

In the end you do something like this:

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

The properties you want to set are:

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

The PayRequest has a request envelope, action type (e.g. PAY), a cancel URL, a return URL, a currency code, a ReceiverList and a preapproval key.

0
votes

this paypal link lists the parameters you need to use for obtaining the payment details.Once the customer returns to site after payment you can send request.Any one of transaction id,paykey or trackingid is enough. Since the paykey is already available with you you can use that. The sample codes for this is available in github .The exact link for the servlet is this, and for the sdk.