gpt4 book ai didi

java - Paypal SetExpressCheckout Soap

转载 作者:太空宇宙 更新时间:2023-11-03 16:03:50 29 4
gpt4 key购买 nike

当我尝试设置 ExpressCheckout 时,我得到 ack = success 但没有返回 token 。

paypal api的版本是87.0这里是 wsdl 链接:https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl

这里是我在axis2-1.6.1中用来生成java代码的命令

-uri https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsd -p com.paypal.soap 

这里是使用 axis2 https://docs.google.com/open?id=0B97cB4uxjmztbGgxRER6VjBWcWc 生成的 java 代码的链接

这里是 SetExpressCheckout 的代码

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

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

SetExpressCheckoutRequestType requestType = new SetExpressCheckoutRequestType();
requestType.setVersion("87.0");
requestType.setSetExpressCheckoutRequestDetails(requestDetailsType);

SetExpressCheckoutReq req = new SetExpressCheckoutReq();
req.setSetExpressCheckoutRequest(requestType);

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

UserIdPasswordType userIdPasswordType = new UserIdPasswordType();
userIdPasswordType.setUsername("<username>");
userIdPasswordType.setPassword("<pass>");
userIdPasswordType.setSignature("<signature>");
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);
SetExpressCheckoutResponse setExpressCheckout = stub.setExpressCheckout(req, requesterCredentials);

SetExpressCheckoutResponseType checkoutResponse = setExpressCheckout.getSetExpressCheckoutResponse();
Calendar timestamp = checkoutResponse.getTimestamp();
String strdate = null;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
if (timestamp != null) {
strdate = sdf.format(timestamp.getTime());
}
System.out.println("Date:" + strdate);
System.out.println("CorrelationID:" + checkoutResponse.getCorrelationID());
System.out.println("ack :" + checkoutResponse.getAck());
if (checkoutResponse.getErrors() != null && checkoutResponse.getErrors().length > 0) {
PayPalAPIInterfaceServiceStub.ErrorType[] errors = checkoutResponse.getErrors();
for (int i = 0; i < errors.length; i++) {
System.out.println(errors[i].getErrorCode());
System.out.println(errors[i].getLongMessage());

}
}
System.out.println("token:" + checkoutResponse.getToken());

这是我得到的结果

Date:17/04/2012 12:33:38
CorrelationID:a7c9fe7283bd
ack :Success
token:null

我如何获得确认成功但 token 为空?paypal 的联系人说已经为 CorrelationID:a7c9fe7283bd 生成了一个 EC token 。

提前致谢。

最佳答案

我必须使用 setExpressCheckoutResponse.getExtraElement().getText() 来获取 token 。为什么 setExpressCheckoutResponse.getToken() 返回 null?

关于java - Paypal SetExpressCheckout Soap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10172197/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com