PayPal NVP Example
This is an example of the SetExpressCheckout request
/* set user - these are your credentials from paypal */ Profile user = new BaseProfile.Builder("user name", "password").signature("AfcWX...").build(); /* create new instance of paypal nvp */ PayPal pp = new PayPal(user, Environment.SANDBOX); /* create items (items from a shopping basket) */ PaymentItem item1 = new PaymentItem(); item1.setAmount("12.00"); PaymentItem item2 = new PaymentItem(); item2.setAmount("4.30"); item2.setDescription("Suya"); PaymentItem[] items = {item1, item2}; /* create payment (now you can create payment from the items) */ Payment payment = new Payment(items); payment.setCurrency(Currency.GBP); /* create set express checkout - the first paypal request */ SetExpressCheckout setEC = new SetExpressCheckout(payment, "https://www.return_url.com", "https://www.cancel_url.com"); /* send request and set response */ pp.setResponse(setEc); /* now you have set express checkout containting */ /* request and response as well */ Map<String, String> response = setEC.getNVPResponse();
This is an example of the GetBalance request
/* set user, create instance of paypal - same as above */ // ... /* create get balance */ GetBalance balance = new Balance(); /* send request and set response */ pp.setResponse(balance); /* get response */ Map<String, String> response = balance.getNVPResponse();
If you are interested in seeing more examples or need any help using this library please contact the Project Administrators (http://sourceforge.net/projects/paypal-nvp/support)