Monday, April 16, 2012

Paypal SetExpressCheckout Soap

when i try to setExpressCheckout, i get ack = success but not token return.



the version of paypal api is 87.0
Here the wsdl link : https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl



here to command i use in axis2-1.6.1 to generate java code



-uri PayPalSvc.wsdl -p com.paypal.soap.PayPalAPIAA - pn PayPalAPIAA -s


here the code for SetExpressCheckout



String setExpressCheckout(PayPalBuyer buyer, PayPalSeller seller) throws AxisFault, RemoteException {

PaymentDetailsType paymentDetails = new PaymentDetailsType();
BasicAmountType orderTotal = new BasicAmountType();
orderTotal.setCurrencyID(CurrencyCodeType.USD);
orderTotal.setString("10.00");
paymentDetails.setOrderTotal(orderTotal);
paymentDetails.setPaymentAction(PaymentActionCodeType.Sale);


SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType();
details.setPaymentDetails(new PaymentDetailsType[]{paymentDetails});
details.setReturnURL(buyer.getReturnUrl());
details.setCancelURL(buyer.getCancelUrl());

SetExpressCheckoutRequestType pprequest = new SetExpressCheckoutRequestType();
pprequest.setVersion("87.0");
pprequest.setSetExpressCheckoutRequestDetails(details);

RequesterCredentials requesterCredentials = new RequesterCredentials();
CustomSecurityHeaderType customSecurityHeaderType = new CustomSecurityHeaderType();

UserIdPasswordType userIdPasswordType = new UserIdPasswordType();
userIdPasswordType.setUsername(seller.getUser());
userIdPasswordType.setPassword(seller.getPass());
userIdPasswordType.setSignature(seller.getSignature());
customSecurityHeaderType.setCredentials(userIdPasswordType);

requesterCredentials.setRequesterCredentials(customSecurityHeaderType);
String endPoint = null;
endPoint = "https://api-3t.sandbox.paypal.com/2.0/"; //sandbox API Signature

PayPalAPIInterfaceServiceStub stub = new PayPalAPIInterfaceServiceStub(endPoint);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);
SetExpressCheckoutReq checkoutReq = new SetExpressCheckoutReq();
checkoutReq.setSetExpressCheckoutRequest(pprequest);

SetExpressCheckoutResponse expressCheckout = stub.setExpressCheckout(checkoutReq, requesterCredentials);
SetExpressCheckoutResponseType setExpressCheckoutResponse = expressCheckout.getSetExpressCheckoutResponse();

System.out.println(setExpressCheckoutResponse.getAck());
System.out.println(setExpressCheckoutResponse.isTokenSpecified());
System.out.println(setExpressCheckoutResponse.getToken());


here the result that i get



Success
false
null


how i get ack success but token is null?



thanks in advance.





No comments:

Post a Comment