The earliest transaction date at which to start the search. No wildcards are allowed. Required
Наследование: AbstractRequestType
        protected void Search_Submit(object sender, EventArgs e)
        {
            // Create request object
            TransactionSearchRequestType request = new TransactionSearchRequestType();
            if (transactionID.Value != "")
            {
                request.TransactionID = transactionID.Value;
            }
            if (startDate != null && startDate.Text != null)
            {
                request.StartDate = startDate.Text;
            }
            if (endDate != null && endDate.Text != null)
            {
                request.EndDate = endDate.Text;
            }
            if (payer.Value != "")
            {
                request.Payer = payer.Value;
            }
            if (receiver.Value != "")
            {
                request.Receiver = receiver.Value;
            }
            if (receiptId.Value != "")
            {
                request.ReceiptID = receiptId.Value;
            }
            if (profileId.Value != "")
            {
                request.ProfileID = profileId.Value;
            }
            if (auctionItemNumber.Value != "")
            {
                request.AuctionItemNumber = auctionItemNumber.Value;
            }
            if (invoiceID.Value != "")
            {
                request.InvoiceID = invoiceID.Value;
            }
            if (cardNumber.Value != "")
            {
                request.CardNumber = cardNumber.Value;
            }
            if (transactionClass.SelectedIndex != 0)
            {
                request.TransactionClass = (PaymentTransactionClassCodeType)
                    Enum.Parse(typeof(PaymentTransactionClassCodeType), transactionClass.SelectedValue);
            }
            if (amount.Value != "" && currencyCode.SelectedIndex != 0)
            {
                request.CurrencyCode = (CurrencyCodeType)
                    Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
                BasicAmountType searchAmount = new BasicAmountType(request.CurrencyCode, amount.Value);
                request.Amount = searchAmount;

            }
            if (transactionStatus.SelectedIndex != 0)
            {
                request.Status = (PaymentTransactionStatusCodeType)
                    Enum.Parse(typeof(PaymentTransactionStatusCodeType), transactionStatus.SelectedValue);
            }

            // Invoke the API
            TransactionSearchReq wrapper = new TransactionSearchReq();
            wrapper.TransactionSearchRequest = request;
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
            TransactionSearchResponseType transactionDetails = service.TransactionSearch(wrapper);

            // Check for API return status
            processResponse(service, transactionDetails);
        }
    // # TransactionSearch API Operation
    // The TransactionSearch API searches transaction history for transactions that meet the specified criteria
    public TransactionSearchResponseType TransactionSearchAPIOperation()
    {
        // Create the TransactionSearchResponseType object
        TransactionSearchResponseType responseTransactionSearchResponseType = new TransactionSearchResponseType();

        try
        {
            // # Create the TransactionSearchReq object
            TransactionSearchReq requestTransactionSearch = new TransactionSearchReq();

            // `TransactionSearchRequestType` which takes mandatory argument:
            // 
            // * `Start Date` - The earliest transaction date at which to start the
            // search.
            TransactionSearchRequestType transactionSearchRequest = new TransactionSearchRequestType("2012-12-25T00:00:00+0530");
            requestTransactionSearch.TransactionSearchRequest = transactionSearchRequest;

            // Create the service wrapper object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

            // # API call
            // Invoke the TransactionSearch method in service wrapper object
            responseTransactionSearchResponseType = service.TransactionSearch(requestTransactionSearch);

            if (responseTransactionSearchResponseType != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "TransactionSearch API Operation - ";
                acknowledgement += responseTransactionSearchResponseType.Ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseTransactionSearchResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    // Search Results
                    IEnumerator<PaymentTransactionSearchResultType> iterator = responseTransactionSearchResponseType.PaymentTransactions.GetEnumerator();

                    while (iterator.MoveNext())
                    {
                        PaymentTransactionSearchResultType searchResult = iterator.Current;

                        // Merchant's transaction ID.
                        logger.Info("Transaction ID : " + searchResult.TransactionID + "\n");
                        Console.WriteLine("Transaction ID : " + searchResult.TransactionID + "\n");
                    }
                }
                // # Error Values
                else
                {
                    List<ErrorType> errorMessages = responseTransactionSearchResponseType.Errors;
                    foreach (ErrorType error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.LongMessage);
                        Console.WriteLine("API Error Message : " + error.LongMessage + "\n");
                    }
                }
            }
        }
        // # Exception log    
        catch (System.Exception ex)
        {
            // Log the exception message       
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }
        return responseTransactionSearchResponseType;
    }
Пример #3
0
 private void TransSearch(HttpContext context)
 {
     TransactionSearchReq req = new TransactionSearchReq();
     TransactionSearchRequestType reqType = new TransactionSearchRequestType();
     reqType.Version = "78.0";
     reqType.StartDate = context.Request.Params["startDate"] + "T00:00:00.000Z";
     reqType.TransactionID = context.Request.Params["transID"];;
     req.TransactionSearchRequest = reqType;
     try
     {
         PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
         TransactionSearchResponseType resp = service.TransactionSearch(req);
         context.Response.Write("<html><body><textarea rows=30 cols=80>");
         ObjectDumper.Write(resp, 5, context.Response.Output);
         context.Response.Write("</textarea></body></html>");
     }
     catch (System.Exception e)
     {
         context.Response.Write(e.Message);
     }
 }
        protected void Search_Submit(object sender, EventArgs e)
        {
            // Create request object
            TransactionSearchRequestType request = new TransactionSearchRequestType();
            if (transactionID.Value != string.Empty)
            {
                request.TransactionID = transactionID.Value;
            }
            // (Required) The earliest transaction date at which to start the search.
            if (startDate != null && startDate.Text != null)
            {
                request.StartDate = startDate.Text;
            }
            // (Optional) The latest transaction date to be included in the search.
            if (endDate != null && endDate.Text != null)
            {
                request.EndDate = endDate.Text;
            }
            // (Optional) Search by the buyer's email address.
            if (payer.Value != string.Empty)
            {
                request.Payer = payer.Value;
            }
            // (Optional) Search by the receiver's email address. If the merchant account has only one email address, this is the primary email. It can also be a non-primary email address.
            if (receiver.Value != string.Empty)
            {
                request.Receiver = receiver.Value;
            }
            // (Optional) Search by the PayPal Account Optional receipt ID. This field is not applicable to point-of-sale transactions.
            if (receiptId.Value != string.Empty)
            {
                request.ReceiptID = receiptId.Value;
            }
            // (Optional) An alphanumeric string (generated by PayPal) that uniquely identifies a recurring profile. You can specify the Profile ID in the TransactionSearch API operation to obtain all payments associated with the identified profile.
            if (profileId.Value != string.Empty)
            {
                request.ProfileID = profileId.Value;
            }
            // (Optional) Search by auction item number of the purchased goods. This field is not applicable to point-of-sale.
            if (auctionItemNumber.Value != string.Empty)
            {
                request.AuctionItemNumber = auctionItemNumber.Value;
            }
            // (Optional) Search by invoice identification key, as set by you for the original transaction. This field searches the records for items the merchant sells.
            if (invoiceID.Value != string.Empty)
            {
                request.InvoiceID = invoiceID.Value;
            }
            // (Optional) Search by credit card number, as set by you for the original transaction. This field searches the records for items the merchant sells. The field is not applicable to point-of-sale.
            // Note: No wildcards are allowed.
            if (cardNumber.Value != string.Empty)
            {
                request.CardNumber = cardNumber.Value;
            }
            // (Optional) Search by classification of transaction. Some kinds of possible classes of transactions are not searchable with this field. You cannot search for bank transfer withdrawals, for example. It is one of the following values:
            // * All – All transaction classifications
            // * Sent – Only payments sent
            // * Received – Only payments received
            // * MassPay – Only mass payments
            // * MoneyRequest – Only money requests
            // * FundsAdded – Only funds added to balance
            // * FundsWithdrawn – Only funds withdrawn from balance
            // * Referral – Only transactions involving referrals
            // * Fee – Only transactions involving fees
            // * Subscription – Only transactions involving subscriptions
            // * Dividend – Only transactions involving dividends
            // * Billpay – Only transactions involving BillPay Transactions
            // * Refund – Only transactions involving funds
            // * CurrencyConversions – Only transactions involving currency conversions
            // * BalanceTransfer – Only transactions involving balance transfers
            // * Reversal – Only transactions involving BillPay reversals
            // * Shipping – Only transactions involving UPS shipping fees
            // * BalanceAffecting – Only transactions that affect the account balance
            // * ECheck – Only transactions involving eCheck
            if (transactionClass.SelectedIndex != 0)
            {
                request.TransactionClass = (PaymentTransactionClassCodeType)
                    Enum.Parse(typeof(PaymentTransactionClassCodeType), transactionClass.SelectedValue);
            }
            // (Optional) Search by transaction amount.
            // Note: You must set the currencyID attribute to one of the 3-character currency codes for any of the supported PayPal currencies.
            if (amount.Value != string.Empty && currencyCode.SelectedIndex != 0)
            {
                request.CurrencyCode = (CurrencyCodeType)
                    Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
                BasicAmountType searchAmount = new BasicAmountType(request.CurrencyCode, amount.Value);
                request.Amount = searchAmount;

            }
            // (Optional) Search by transaction status. It is one of the following values:
            // * Pending – The payment is pending. The specific reason the payment is pending is returned by the GetTransactionDetails API PendingReason field.
            // * Processing – The payment is being processed.
            // * Success – The payment has been completed and the funds have been added successfully to your account balance.
            // * Denied – You denied the payment. This happens only if the payment was previously pending.
            // * Reversed – A payment was reversed due to a chargeback or other type of reversal. The funds have been removed from your account balance and returned to the buyer.
            if (transactionStatus.SelectedIndex != 0)
            {
                request.Status = (PaymentTransactionStatusCodeType)
                    Enum.Parse(typeof(PaymentTransactionStatusCodeType), transactionStatus.SelectedValue);
            }

            // Invoke the API
            TransactionSearchReq wrapper = new TransactionSearchReq();
            wrapper.TransactionSearchRequest = request;

            // Configuration map containing signature credentials and other required configuration.
            // For a full list of configuration parameters refer in wiki page
            // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters]
            Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig();

            // Create the PayPalAPIInterfaceServiceService service object to make the API call
            PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);

            // # API call
            // Invoke the TransactionSearch method in service wrapper object
            TransactionSearchResponseType transactionDetails = service.TransactionSearch(wrapper);

            // Check for API return status
            processResponse(service, transactionDetails);
        }