I'm trying to get transaction details from PayPal's SOAP API but I'm running into into error from PayPal. It returns the error:
The transaction id is not valid
I know it's a valid transaction ID since I'm I'm able to get transaction details using the PayPal NVP API but maybe I have the SOAP request formatted incorrectly. I followed the PayPal SOAP API examples I can find across the web to construct the SOAP XML but they are slim. I'm using mac's PAW program to send a SOAP request to PayPal's API but this problem should be reproducible using an HTTP client.
I tried to use PayPal's REST API but there's no method to get transaction details (e.g. name, email, amount paid, custom fields) . I also tried to use the NVP (Name-Value-Pair) API and I do get back the transaction details but it doesn't give me all of the stored custom fields for a transaction. When I log in to PayPal, and view a single transaction, I can see all of the custom fields for that transaction, so I know they're being stored.
The SOAP API is my last hope.
Here's the SOAP envelope request I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:ebay:api:PayPalAPI" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:ed="urn:ebay:apis:EnhancedDataTypes">
<soapenv:Header>
<ns:RequesterCredentials>
<ebl:Credentials>
<ebl:Username>soap_api_username_here</ebl:Username>
<ebl:Password>soap_api_password_here</ebl:Password>
<ebl:Signature>soap_api_signature_here</ebl:Signature>
</ebl:Credentials>
</ns:RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
<ns:GetTransactionDetailsReq>
<ns:GetTransactionDetailsRequest>
<ebl:Version>93.0</ebl:Version>
<ebl:TransactionID>8FX18476NR449891W</ebl:TransactionID>
</ns:GetTransactionDetailsRequest>
</ns:GetTransactionDetailsReq>
</soapenv:Body>
</soapenv:Envelope>
Here's the response I receive from the PayPal SOAP API:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ed="urn:ebay:apis:EnhancedDataTypes" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
<SOAP-ENV:Header>
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
<Username xsi:type="xs:string"/>
<Password xsi:type="xs:string"/>
<Signature xsi:type="xs:string"/>
<Subject xsi:type="xs:string"/>
</Credentials>
</RequesterCredentials>
</SOAP-ENV:Header>
<SOAP-ENV:Body id="_0">
<GetTransactionDetailsResponse xmlns="urn:ebay:api:PayPalAPI">
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2016-08-02T16:43:02Z</Timestamp>
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">a464c181339f4</CorrelationID>
<Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
<ShortMessage xsi:type="xs:string">Transaction refused because of an invalid argument. See additional error messages for details.</ShortMessage>
<LongMessage xsi:type="xs:string">The transaction id is not valid</LongMessage>
<ErrorCode xsi:type="xs:token">10004</ErrorCode>
<SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
</Errors>
<Version xmlns="urn:ebay:apis:eBLBaseComponents">93.0</Version>
<Build xmlns="urn:ebay:apis:eBLBaseComponents">000000</Build>
<PaymentTransactionDetails xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:PaymentTransactionType">
<ReceiverInfo xsi:type="ebl:ReceiverInfoType"/>
<PayerInfo xsi:type="ebl:PayerInfoType">
<PayerStatus xsi:type="ebl:PayPalUserStatusCodeType">verified</PayerStatus>
<PayerName xsi:type="ebl:PersonNameType"/>
<Address xsi:type="ebl:AddressType">
<AddressOwner xsi:type="ebl:AddressOwnerCodeType">PayPal</AddressOwner>
<AddressStatus xsi:type="ebl:AddressStatusCodeType">None</AddressStatus>
</Address>
</PayerInfo>
<PaymentInfo xsi:type="ebl:PaymentInfoType">
<TransactionType xsi:type="ebl:PaymentTransactionCodeType">none</TransactionType>
<PaymentType xsi:type="ebl:PaymentCodeType">none</PaymentType>
<PaymentStatus xsi:type="ebl:PaymentStatusCodeType">None</PaymentStatus>
<PendingReason xsi:type="ebl:PendingStatusCodeType">none</PendingReason>
<ReasonCode xsi:type="ebl:ReversalReasonCodeType">none</ReasonCode>
</PaymentInfo>
<PaymentItemInfo xsi:type="ebl:PaymentItemInfoType">
<Subscription xsi:type="ebl:SubscriptionInfoType"/>
<Auction xsi:type="ebl:AuctionInfoType"/>
</PaymentItemInfo>
</PaymentTransactionDetails>
</GetTransactionDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I'm not sure what I'm doing wrong but maybe someone with more experience can spot the error easier than I can. I responded to another user's question about the PayPal REST API and getting transaction details from that but as far as I know, there's no way to do that Get customer details after transaction . If you have found a way to accomplish this with the REST API, let me know cause I would much rather use REST than SOAP.
Thanks.
The error message is a red herring. PayPal can't find any TransactionId, reporting the empty TransactionId as invalid.
The TransactionId element belongs to the urn:ebay:api:PayPalAPI
namespace. Your XML attaches it to the urn:ebay:apis:eBLBaseComponents
namespace. All you need to do is change the ebl:TransactionId
to ns:TransactionId
.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:ebay:api:PayPalAPI" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:ed="urn:ebay:apis:EnhancedDataTypes">
<soapenv:Header>
<ns:RequesterCredentials>
<ebl:Credentials>
<ebl:Username>soap_api_username_here</ebl:Username>
<ebl:Password>soap_api_password_here</ebl:Password>
<ebl:Signature>soap_api_signature_here</ebl:Signature>
</ebl:Credentials>
</ns:RequesterCredentials>
</soapenv:Header>
<soapenv:Body>
<ns:GetTransactionDetailsReq>
<ns:GetTransactionDetailsRequest>
<ebl:Version>204.0</ebl:Version>
<ns:TransactionID>8FX18476NR449891W</ns:TransactionID>
</ns:GetTransactionDetailsRequest>
</ns:GetTransactionDetailsReq>
</soapenv:Body>
Check this example at the PayPal KB.