PayPal DoReferenceTransaction

时间:2013-04-25 12:38:31

标签: c# paypal paypal-sandbox

我用C#调用进程DoReferenceTransaction (SOAP)。它运行正常,数据到达,DoReferenceTransactionResponseType的结果没有错误。 但是细节DoReferenceTransactionResponseDetails永远是空的。

启用的变量是否可以填充响应中的详细信息? 我在DoReferenceTransactionResponseDetails.Any中找到了一个XML-String,但为什么我要将数据从xml中排除,如果它在DoReferenceTransactionResponseDetails中?

我必须拥有的是来自PayPal的TransactionID

由于

请求示例:

  request = new DoReferenceTransactionReq();
  request.DoReferenceTransactionRequest = new DoReferenceTransactionRequestType();
  request.DoReferenceTransactionRequest.Version = "98.0";
  request.DoReferenceTransactionRequest.DoReferenceTransactionRequestDetails = new DoReferenceTransactionRequestDetailsType();
  request.DoReferenceTransactionRequest.DoReferenceTransactionRequestDetails.PaymentAction = PaymentActionCodeType.Sale;
  request.DoReferenceTransactionRequest.DoReferenceTransactionRequestDetails.PaymentType = MerchantPullPaymentCodeType.Any;
  request.DoReferenceTransactionRequest.DoReferenceTransactionRequestDetails.PaymentDetails = new PaymentDetailsType();
  request.DoReferenceTransactionRequest.DoReferenceTransactionRequestDetails.PaymentDetails.OrderTotal = new BasicAmountType();
  request.DoReferenceTransactionRequest.DoReferenceTransactionRequestDetails.PaymentDetails.OrderTotal.Value = "100";
  request.DoReferenceTransactionRequest.DoReferenceTransactionRequestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.CHF;
  request.DoReferenceTransactionRequest.DoReferenceTransactionRequestDetails.ReferenceID = "XXXX";

  DoReferenceTransactionResponseType response = service.DoReferenceTransaction(request);

response from the upper request

交易已成功处理,我可以在paypal沙盒的页面概述中看到它。

1 个答案:

答案 0 :(得分:1)

你应该回复价值观。它不应该为空。例如,我正在通过以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:ebay:apis:eBLBaseComponents" xmlns:ns2="urn:ebay:api:PayPalAPI">
  <SOAP-ENV:Header>
    <ns2:RequesterCredentials>
      <ns1:Credentials>
        <ns1:Username>%Username%</ns1:Username>
        <ns1:Password>%Password%</ns1:Password>
        <ns1:Signature>%Signature%</ns1:Signature>  
      </ns1:Credentials>
    </ns2:RequesterCredentials>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns2:DoReferenceTransactionReq>
      <ns2:DoReferenceTransactionRequest>
        <ns1:Version>84.0</ns1:Version>
        <ns1:DoReferenceTransactionRequestDetails>  
          <ns1:ReferenceID>1A381834JN903220E</ns1:ReferenceID>  
          <ns1:PaymentAction>Sale</ns1:PaymentAction>
          <ns1:PaymentType>Any</ns1:PaymentType>
          <ns1:PaymentDetails>
            <ns1:OrderTotal currencyID="USD">10.00</ns1:OrderTotal>
            <ns1:PaymentAction>Sale</ns1:PaymentAction>
          </ns1:PaymentDetails>
          <ns1:IPAddress>10.243.180.150</ns1:IPAddress>
        </ns1:DoReferenceTransactionRequestDetails>
      </ns2:DoReferenceTransactionRequest>
    </ns2:DoReferenceTransactionReq>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我在API响应中回复了以下内容:

Array
(
    [name] => DoReferenceTransactionResponse
    [elements] => Array
        (
            [0] => Array
                (
                    [name] => Timestamp
                    [text] => 2013-04-25T13:22:14Z
                )

            [1] => Array
                (
                    [name] => Ack
                    [text] => Success
                )

            [2] => Array
                (
                    [name] => CorrelationID
                    [text] => 748fcba0bc2e7
                )

            [3] => Array
                (
                    [name] => Version
                    [text] => 84.0
                )

            [4] => Array
                (
                    [name] => Build
                    [text] => 5650305
                )

            [5] => Array
                (
                    [name] => DoReferenceTransactionResponseDetails
                    [elements] => Array
                        (
                            [0] => Array
                                (
                                    [name] => Amount
                                    [text] => 10.00
                                )

                            [1] => Array
                                (
                                    [name] => AVSCode
                                    [text] => X
                                )

                            [2] => Array
                                (
                                    [name] => CVV2Code
                                    [text] => M
                                )

                            [3] => Array
                                (
                                    [name] => TransactionID
                                    [text] => 2PR97363S20425407
                                )

                        )

                )

        )

)