1

ExpressCheckout を設定しようとすると、ack = success が返されますが、トークンが返されません。

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 を使用して生成された Java コードへのリンクhttps://docs.google.com/open?id=0B97cB4uxjmztbGgxRER6VjBWcWc

ここに 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

どのように ack の成功を取得しますが、トークンは null ですか? Paypal の連絡担当者は、CorrelationID:a7c9fe7283bd に対して既に EC トークンが生成されていると述べました。

前もって感謝します。

4

3 に答える 3

1

トークンを取得するには、setExpressCheckoutResponse.getExtraElement().getText() を使用する必要があります。setExpressCheckoutResponse.getToken() が null を返すのはなぜですか?

于 2012-04-19T04:23:23.863 に答える
0

上記の wsdl ファイルを調べると、最初に次のことがわかります。

<wsdl:definitions
     ns:version="89.0"
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns="http://schemas.xmlsoap.org/wsdl/" 
     ... >

使用する必要がある API のバージョンは89.0、PayPal API ドキュメントのどこで指定されているか覚えていませんが、確かに記載されています。

この問題が引き続き発生する場合はお知らせください。最近、Java で SOAP を使用して PayPal エクスプレス チェックアウトをセットアップすることができました。

于 2012-06-12T16:12:40.437 に答える
0

私はちょうどこの問題に遭遇し、答えを見つけました (これは C# 用です。Java に適用されるかどうかはわかりません):

https://www.x.com/developers/paypal/forums/soap/paypal-api-aa-and-net-wcf-undeserialized-fields

Web サービス用に生成されたコード (Reference.cs) を調べて、AbstractResponseType を見つけます。最後のプロパティは Any() です。これに一致するように属性を変更します (プロパティを無視します)。

    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public System.Xml.XmlElement Any {
        get {
            return this.anyField;
        }
        set {
            this.anyField = value;
        }
    }

これに続いて、再コンパイルして再度テストすると、正しく設定された Token プロパティを受け取るはずです。

Web サービス コードを再生成すると、もちろんこの変更は置き換えられ、PayPal がこれを修正しない限り、やり直す必要があります。ところで、私の WSDL バージョン番号は現時点で 98.0 です。

ゲイリー・デイビス

于 2013-02-05T17:28:04.290 に答える