Skip to content

Commit

Permalink
Reverted back to SOAP
Browse files Browse the repository at this point in the history
SOAP returns better formatted results for use with JSON.  Added
environment variable and added 30 second timeout to REST call for
transaction search.
  • Loading branch information
Sidney Maestre committed Apr 24, 2012
1 parent c82d436 commit aaf2d62
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 143 deletions.
27 changes: 13 additions & 14 deletions paypal/paypal.transaction.details.xml
@@ -1,35 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd" https="true">
<meta>
<sampleQuery> select * from {table} WHERE APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature" AND TransactionID="-transaction-id-from-transaction-search-result-or-IPN-" AND Endpoint="sandbox"</sampleQuery>
<sampleQuery>select * from {table} WHERE APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature" AND TransactionID="-transaction-id-from-transaction-search-result-or-IPN-" AND Environment="sandbox"</sampleQuery>
<description>The PayPal Transaction Details API allows you to obtain details about a specific transaction. The details include information from Payer, shipping address to the amount charged. Please note that inorder to be able to use the API to obtain the details of a transaction, you must either be the owner of the business account that's marked as the receiver of the payment or have obtained API access from the corresponding receiver account owner. Please refer to the GetTransactionDetails API documentation on x.com to understand the data returned by the API.</description>
<documentationURL>www.x.com/developers/paypal/products/transactional-information</documentationURL>
<documentationURL>https://www.x.com/community/ppx/transaction_information</documentationURL>

</meta>
<bindings>
<select produces="JSON">
<select itemPath="Envelope.Body.GetTransactionDetailsResponse" produces="XML">
<inputs>
<key id='APIUsername' type='xs:string' paramType='variable' required="true" />
<key id='APIPassword' type='xs:string' paramType='variable' required="true" />
<key id='Signature' type='xs:string' paramType='variable' required="true" />
<key id='TransactionID' type='xs:string' paramType='variable' required="true" />
<key id='Endpoint' type='xs:string' paramType='variable' required="true" />
<key id='Environment' type='xs:string' paramType='variable' default="sandbox" />
</inputs>
<execute><![CDATA[
var txn_details_req = "METHOD=gettransactionDetails&VERSION=88&TRANSACTIONID=" + inputs['TransactionID'] + "&PWD=" + inputs['APIPassword'] + "&USER=" + inputs['APIUsername'] + "&SIGNATURE=" + inputs['Signature'];
var txn_details_req = <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header><RequesterCredentials soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="1" xmlns="urn:ebay:api:PayPalAPI"><ebl:Credentials xmlns:ebl="urn:ebay:apis:eBLBaseComponents"><ebl:Username>{APIUsername}</ebl:Username><ebl:Password>{APIPassword}</ebl:Password><ebl:Signature>{Signature}</ebl:Signature><ebl:Subject></ebl:Subject></ebl:Credentials></RequesterCredentials></soapenv:Header><soapenv:Body><GetTransactionDetailsReq xmlns="urn:ebay:api:PayPalAPI"><GetTransactionDetailsRequest><ns1:Version xmlns:ns1="urn:ebay:apis:eBLBaseComponents">58.0</ns1:Version><TransactionID>{TransactionID}</TransactionID></GetTransactionDetailsRequest></GetTransactionDetailsReq></soapenv:Body></soapenv:Envelope>
if(inputs['Environment'] == 'live') {
response.object = y.rest("https://api..paypal.com/2.0/").contentType("text/xml").header("SOAPAction", '""').post(txn_details_req).response;
var responseObj = {};
var temp;
if(inputs['Endpoint'] == 'sandbox') {
temp = y.rest("https://api-3t.sandbox.paypal.com/nvp?" + txn_details_req).get().response;
} else {
temp = y.rest("https://api-3t.paypal.com/nvp?" + txn_details_req).get().response;
response.object = y.rest("https://api.sandbox.paypal.com/2.0/").contentType("text/xml").header("SOAPAction", '""').post(txn_details_req).response;
}
responseObj = temp.split("&");
response.object = {'details': responseObj};
]]></execute>
</select>
</bindings>
Expand Down
287 changes: 158 additions & 129 deletions paypal/paypal.transactions.xml
@@ -1,134 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd" https="true">
<meta>
<sampleQuery> select * from {table} WHERE APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature AND StartDate="YYYY-MM-DDThh:MM:ss.mmmZ" AND Endpoint="sandbox"</sampleQuery>
<sampleQuery> select * from {table} WHERE APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature AND StartDate="YYYY-MM-DDThh:MM:ss.mmmZ" AND Payer="your-payer-email-that-youwant-to-narrow-down-results" AND Endpoint="sandbox"</sampleQuery>
<sampleQuery>SELECT * FROM paypal.transaction.details WHERE APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature" AND Endpoint="sandbox" AND TransactionID in (SELECT PaymentTransactions.TransactionID FROM {table} WHERE StartDate="YYYY-MM-DDThh:MM:ss.mmmZ" AND Payer="your-payer-email-that-youwant-to-narrow-down-results" AND APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature")</sampleQuery>

<description>The PayPal Transaction Details API allows you to obtain details about a specific transaction. The details include information from Payer, shipping address to the amount charged. Please note that inorder to be able to use the API to obtain the details of a transaction, you must either be the owner of the business account that's marked as the receiver of the payment or have obtained API access from the corresponding receiver account owner. Please refer to the GetTransactionDetails API documentation on x.com to understand the data returned by the API.</description>
<documentationURL>www.x.com/developers/paypal/products/transactional-information</documentationURL>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"
https="true">
<meta>
<sampleQuery> select * from {table} WHERE APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature AND StartDate="YYYY-MM-DDThh:MM:ss.mmmZ" AND Environment="sandbox"</sampleQuery>
<sampleQuery> select * from {table} WHERE APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature AND StartDate="YYYY-MM-DDThh:MM:ss.mmmZ" AND Payer="your-payer-email-that-youwant-to-narrow-down-results" AND Environment="sandbox"</sampleQuery>
<sampleQuery>SELECT * FROM paypal.transaction.details WHERE APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature" AND TransactionID in (SELECT PaymentTransactions.TransactionID FROM {table} WHERE StartDate="YYYY-MM-DDThh:MM:ss.mmmZ" AND Payer="your-payer-email-that-youwant-to-narrow-down-results" AND APIUsername="your_api_username" AND APIPassword="your_api_password" AND Signature="your_api_aignature") AND Environment="sandbox"</sampleQuery>
<description>The PayPal Transaction Search API allows you to search through a PayPal business account's transaction history to create compelling reporting apps. Please note that inorder to be able to use the API to search a PayPal business account's transaction history, you must either be the owner of the account or have obtained API access from the corresponding account owner. Please refer to the TransactionSearch API documentation on x.com to understand how each of the input parameters help in navigating through the transaction history. You can as well combine results from this table with PayPal Transaction Details table to obtain information specific to each transaction (Eg. Address, Payer, etc.) and use that information with other tables (Geo, Maps, etc.) to produce useful data for building cool reporting tools. </description>
<documentationURL>https://www.x.com/community/ppx/transaction_information</documentationURL>
</meta>
<bindings>
<select itemPath="Envelope.Body.TransactionSearchResponse"
produces="XML">

<inputs>
<key id='Environment' type='xs:string' paramType='variable' default="sandbox" />
<key id='APIUsername' type='xs:string' paramType='variable'
required="true" />
<key id='APIPassword' type='xs:string' paramType='variable'
required="true" />
<key id='Signature' type='xs:string' paramType='variable'
required="true" />
<key id='StartDate' type='xs:string' paramType='variable'
required="true" />
<key id='EndDate' type='xs:string' paramType='variable'
required="false" />
<key id='Payer' type='xs:string' paramType='variable' required="false" />
<key id='Receiver' type='xs:string' paramType='variable'
required="false" />
<key id='ReceiptID' type='xs:string' paramType='variable'
required="false" />
<key id='TransactionID' type='xs:string' paramType='variable'
required="false" />
<key id='InvoiceID' type='xs:string' paramType='variable'
required="false" />
<key id='CardNumber' type='xs:string' paramType='variable'
required="false" />
<key id='AuctionItemNumber' type='xs:string' paramType='variable'
required="false" />
<key id='Status' type='xs:string' paramType='variable' required="false" />
<key id='PayerFirstName' type='xs:string' paramType='variable'
required="false" />
<key id='PayerLastName' type='xs:string' paramType='variable'
required="false" />
<key id='PayerMiddleName' type='xs:string' paramType='variable'
required="false" />
<key id='PayerSalutation' type='xs:string' paramType='variable'
required="false" />
<key id='PayerSuffix' type='xs:string' paramType='variable'
required="false" />
<key id='Amount' type='xs:string' paramType='variable' required="false" />
<key id='CurrencyCode' type='xs:string' paramType='variable'
required="false" />
<key id='TransactionClass' type='xs:string' paramType='variable'
required="false" />
</inputs>
<execute><![CDATA[
var txn_req = '<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header><RequesterCredentials soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="1" xmlns="urn:ebay:api:PayPalAPI"><ebl:Credentials xmlns:ebl="urn:ebay:apis:eBLBaseComponents"><ebl:Username>'
+ APIUsername
+ '</ebl:Username><ebl:Password>'
+ APIPassword
+ '</ebl:Password><ebl:Signature>'
+ Signature
+ '</ebl:Signature><ebl:Subject></ebl:Subject></ebl:Credentials></RequesterCredentials></soapenv:Header><soapenv:Body><TransactionSearchReq xmlns="urn:ebay:api:PayPalAPI"><TransactionSearchRequest><ns1:Version xmlns:ns1="urn:ebay:apis:eBLBaseComponents">78.0</ns1:Version>';
</meta>
<bindings>
<select produces="JSON">
<inputs>
<key id='APIUsername' type='xs:string' paramType='variable' required="true" />
<key id='APIPassword' type='xs:string' paramType='variable' required="true" />
<key id='Signature' type='xs:string' paramType='variable' required="true" />
<key id='TransactionID' type='xs:string' paramType='variable' required="false" />
<key id='Endpoint' type='xs:string' paramType='variable' required="true" />
<key id='StartDate' type='xs:string' paramType='variable' required="true" />
<key id='EndDate' type='xs:string' paramType='variable' required="false" />
<key id='Payer' type='xs:string' paramType='variable' required="false" />
<key id='Receiver' type='xs:string' paramType='variable' required="false" />
<key id='ReceiptID' type='xs:string' paramType='variable' required="false" />
<key id='TransactionID' type='xs:string' paramType='variable' required="false" />
<key id='InvoiceID' type='xs:string' paramType='variable' required="false" />
<key id='CardNumber' type='xs:string' paramType='variable' required="false" />
<key id='AuctionItemNumber' type='xs:string' paramType='variable' required="false" />
<key id='Status' type='xs:string' paramType='variable' required="false" />
<key id='PayerFirstName' type='xs:string' paramType='variable' required="false" />
<key id='PayerLastName' type='xs:string' paramType='variable' required="false" />
<key id='PayerMiddleName' type='xs:string' paramType='variable' required="false" />
<key id='PayerSalutation' type='xs:string' paramType='variable' required="false" />
<key id='PayerSuffix' type='xs:string' paramType='variable' required="false" />
<key id='Amount' type='xs:string' paramType='variable' required="false" />
<key id='CurrencyCode' type='xs:string' paramType='variable' required="false" />
<key id='TransactionClass' type='xs:string' paramType='variable' required="false" />
</inputs>
<execute><![CDATA[
var txn_details_req = "METHOD=TransactionSearch&VERSION=88&PWD=" + inputs['APIPassword'] + "&USER=" + inputs['APIUsername'] + "&SIGNATURE=" + inputs['Signature'];
if(inputs['TransactionID']) {
txn_details_req += "&TRANSACTIONID=" + inputs['TransactionID'];
}
if(inputs['StartDate']) {
txn_details_req += "&StartDate=" + inputs['StartDate'];
}
if(inputs['EndDate']) {
txn_details_req += "&EndDate=" + inputs['EndDate'];
}
if(inputs['Payer']) {
txn_details_req += "&Payer=" + inputs['Payer'];
}
if(inputs['Receiver']) {
txn_details_req += "&Receiver=" + inputs['Receiver'];
}
if(inputs['ReceiptID']) {
txn_details_req += "&ReceiptID=" + inputs['ReceiptID'];
}
if(inputs['InvoiceID']) {
txn_details_req += "&InvoiceID=" + inputs['InvoiceID'];
}
if(inputs['CardNumber']) {
txn_details_req += "&CardNumber=" + inputs['CardNumber'];
}
if(inputs['AuctionItemNumber']) {
txn_details_req += "&AuctionItemNumber=" + inputs['AuctionItemNumber'];
}
if(inputs['Status']) {
txn_details_req += "&Status=" + inputs['Status'];
}
txn_details_req += "&PayerFirstName=" + inputs['PayerFirstName'];
if(inputs['PayerFirstName']) {
txn_details_req += "&PayerFirstName=" + inputs['PayerFirstName'];
}
if(inputs['PayerLastName']) {
txn_details_req += "&PayerLastName=" + inputs['PayerLastName'];
}
if(inputs['PayerMiddleName']) {
txn_details_req += "&PayerMiddleName=" + inputs['PayerMiddleName'];
}
if(inputs['PayerSalutation']) {
txn_details_req += "&PayerSalutation=" + inputs['PayerSalutation'];
}
if(inputs['PayerSuffix']) {
txn_details_req += "&PayerSuffix=" + inputs['PayerSuffix'];
}
if(inputs['Amount']) {
txn_details_req += "&Amount=" + inputs['Amount'];
}
if(inputs['CurrencyCode']) {
txn_details_req += "&CurrencyCode=" + inputs['CurrencyCode'];
}
if(inputs['TransactionClass']) {
txn_details_req += "&TransactionClass=" + inputs['TransactionClass'];
}
var responseObj = {};
var temp;
if(inputs['Endpoint'] == 'sandbox') {
temp = y.rest("https://api-3t.sandbox.paypal.com/nvp?" + txn_details_req).get().response;
txn_req += '<StartDate>' + StartDate + '</StartDate>';
if (EndDate) {
txn_req += '<EndDate>' + EndDate + '</EndDate>';
}
if (Payer) {
txn_req += '<Payer>' + Payer + '</Payer>';
}
if (Receiver) {
txn_req += '<Receiver>' + Receiver + '</Receiver>';
}
if (ReceiptID) {
txn_req += '<ReceiptID>' + ReceiptID + '</ReceiptID>';
}
if (TransactionID) {
txn_req += '<TransactionID>' + TransactionID + '</TransactionID>';
}
if (InvoiceID) {
txn_req += '<InvoiceID>' + InvoiceID + '</InvoiceID>';
}
if (CardNumber) {
txn_req += '<CardNumber>' + CardNumber + '</CardNumber>';
}
if (PayerFirstName || PayerLastName) {
txn_req += '<PayerName>';
if (PayerSalutation) {
txn_req += '<ns2:Salutation xmlns:ns2="urn:ebay:apis:eBLBaseComponents">' + PayerSalutation + '</ns2:Salutation>';
}
if (PayerFirstName) {
txn_req += '<ns3:FirstName xmlns:ns3="urn:ebay:apis:eBLBaseComponents">' + PayerFirstName + '</ns3:FirstName>';
}
if (PayerMiddleName) {
txn_req += '<ns3:MiddleName xmlns:ns3="urn:ebay:apis:eBLBaseComponents">' + PayerMiddleName + '</ns3:MiddleName>';
}
if (PayerLastName) {
txn_req += '<ns3:LastName xmlns:ns3="urn:ebay:apis:eBLBaseComponents">' + PayerLastName + '</ns3:LastName>';
}
if (PayerSuffix) {
txn_req += '<ns3:Suffix xmlns:ns3="urn:ebay:apis:eBLBaseComponents">' + PayerSuffix + '</ns3:Suffix>';
}
txn_req += '</PayerName>';
}
if (AuctionItemNumber) {
txn_req += '<AuctionItemNumber>' + AuctionItemNumber + '</AuctionItemNumber>';
}
if (TransactionClass) {
txn_req += '<TransactionClass>' + TransactionClass + '</TransactionClass>';
}
if (Amount) {
txn_req += '<Amount currencyID="';
if (CurrencyCode) {
txn_req += CurrencyCode;
} else {
txn_req += 'USD';
}
txn_req += '">' + Amount + '</Amount>';
}
if (CurrencyCode) {
txn_req += '<CurrencyCode>' + CurrencyCode + '</CurrencyCode>';
}
if (Status) {
txn_req += '<Status>' + Status + '</Status>';
}
txn_req += '</TransactionSearchRequest></TransactionSearchReq></soapenv:Body></soapenv:Envelope>';
if(inputs['Environment'] == 'live') {
try {
response.object = y.rest("https://api.paypal.com/2.0/").contentType("text/xml").header("SOAPAction", '""').timeout(30000).post(txn_req).response;
}
catch (e){
y.log(e);
}
} else {
temp = y.rest("https://api-3t.paypal.com/nvp?" + txn_details_req).get().response;
}
responseObj = temp.split("&");
response.object = {'details': responseObj};
]]></execute>
</select>
</bindings>
try {
response.object = y.rest("https://api.sandbox.paypal.com/2.0/").contentType("text/xml").header("SOAPAction", '""').timeout(30000).post(txn_req).response;
}
catch (e){
y.log(e);
}
}
]]></execute>
</select>
</bindings>

</table>

0 comments on commit aaf2d62

Please sign in to comment.