Esempio n. 1
1
        /// <summary>
        /// Create a payout batch resource by passing a sender_batch_header and an items array to the request URI. The sender_batch_header contains payout parameters that describe the handling of a batch resource while the items array conatins payout items.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="payout">Payout object to be created as a PayPal resource.</param>
        /// <param name="syncMode">A value of true will provide an immediate, synchronous response. Without this query keyword or if the value is false, the response will be a background batch mode.</param>
        /// <returns>PayoutCreateResponse</returns>
        public static PayoutBatch Create(APIContext apiContext, Payout payout, bool syncMode = false)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(syncMode, "syncMode");

            var queryParameters = new QueryParameters();
            queryParameters["sync_mode"] = syncMode.ToString();

            // Configure and send the request
            var resourcePath = "v1/payments/payouts" + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<PayoutBatch>(apiContext, HttpMethod.POST, resourcePath, payout.ConvertToJson());
        }
Esempio n. 2
0
        /// <summary>
        /// Lists all webhooks for an app.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="anchorType">Filters the response by an entity type, `anchor_id`. Value is `APPLICATION` or `ACCOUNT`. Default is `APPLICATION`.</param>
        /// <returns>WebhookList</returns>
        public static WebhookList GetAll(APIContext apiContext, string anchorType = null)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            var queryParameters = new QueryParameters();

            if (anchorType != null)
            {
                ArgumentValidator.Validate(anchorType, "anchorType");
                queryParameters["anchor_type"] = anchorType;
            }

            // Configure and send the request
            var resourcePath = "v1/notifications/webhooks" + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<WebhookList>(apiContext, HttpMethod.GET, resourcePath);
        }
Esempio n. 3
0
        /// <summary>
        /// Full update of the invoice resource for the given identifier.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="invoice">Invoice object to update.</param>
        /// <param name="notifyMerchant">Specifies if the invoice update notification is needed for merchant</param>
        /// <returns>Invoice</returns>
        public static Invoice Update(APIContext apiContext, Invoice invoice, bool notifyMerchant = true)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(invoice, "invoice");

            var queryParameters = new QueryParameters();
            queryParameters["notify_merchant"] = notifyMerchant.ToString();

            // Configure and send the request
            var pattern = "v1/invoicing/invoices/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { invoice.id }) + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<Invoice>(apiContext, HttpMethod.PUT, resourcePath, invoice.ConvertToJson());
        }
Esempio n. 4
0
        /// <summary>
        /// Sends a legitimate invoice to the payer.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="invoiceId">ID of the invoice to send.</param>
        /// <param name="notifyMerchant">Specifies if the invoice send notification is needed for merchant</param>
        public static void Send(APIContext apiContext, string invoiceId, bool notifyMerchant = true)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(invoiceId, "invoiceId");

            var queryParameters = new QueryParameters();
            queryParameters["notify_merchant"] = notifyMerchant.ToString();

            // Configure and send the request
            var pattern = "v1/invoicing/invoices/{0}/send";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { invoiceId }) + queryParameters.ToUrlFormattedString();
            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.POST, resourcePath);
        }
Esempio n. 5
0
        /// <summary>
        /// Generates QR code for the Invoice URL identified by invoice_id.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="invoiceId">Identifier of the invoice resource for which QR code has to be generated.</param>
        /// <param name="width">Indicates the width of the QR code image in pixels. Range : 150-500. Default 500.</param>
        /// <param name="height">Indicates the height of the QR code image in pixels. Range : 150-500. Default 500.</param>
        /// <param name="action">Specifies the type of URL for which the QR code has the be generated.</param>
        /// <returns>Image</returns>
        public static Image QrCode(APIContext apiContext, string invoiceId, int width = 500, int height = 500, string action = "pay")
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(invoiceId, "invoiceId");

            var queryParameters = new QueryParameters();
            queryParameters["width"] = width.ToString();
            queryParameters["height"] = height.ToString();
            queryParameters["action"] = action;

            // Configure and send the request
            var pattern = "v1/invoicing/invoices/{0}/qr-code";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { invoiceId }) + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<Image>(apiContext, HttpMethod.GET, resourcePath);
        }
Esempio n. 6
0
        /// <summary>
        /// Get all invoices of a merchant.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="page">Start index.</param>
        /// <param name="pageSize">Number of invoices to be returned by the GET API.</param>
        /// <param name="totalCountRequired">A flag to depict that total_count should be returned in the response.</param>
        /// <returns>InvoiceSearchResponse</returns>
        public static InvoiceSearchResponse GetAll(APIContext apiContext, int page = 1, int pageSize = 20, bool totalCountRequired = false)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            var queryParameters = new QueryParameters();
            queryParameters["page"] = page.ToString();
            queryParameters["page_size"] = pageSize.ToString();
            queryParameters["total_count_required"] = totalCountRequired.ToString();

            // Configure and send the request
            var resourcePath = "v1/invoicing/invoices" + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<InvoiceSearchResponse>(apiContext, HttpMethod.GET, resourcePath);
        }
Esempio n. 7
0
        /// <summary>
        /// List payments that were made to the merchant who issues the request. Payments can be in any state.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="count">The number of items to list in the response.</param>
        /// <param name="startId">The ID of the starting resource in the response. When results are paged, you can use the `next_id` value as the `start_id` to continue with the next set of results.</param>
        /// <param name="startIndex">The start index of the resources to return. Typically used to jump to a specific position in the resource history based on its cart. Example for starting at the second item in a list of results: `?start_index=2`</param>
        /// <param name="startTime">The date and time when the resource was created. Indicates the start of a range of results. Example: `start_time=2013-03-06T11:00:00Z`</param>
        /// <param name="endTime">The date and time when the resource was created. Indicates the end of a range of results.</param>
        /// <param name="startDate">Resource creation date that indicates the start of results.</param>
        /// <param name="endDate">Resource creation date that indicates the end of a range of results.</param>
        /// <param name="payeeEmail">Payee identifier (email) to filter the search results in list operations.</param>
        /// <param name="payeeId">Payee identifier (merchant id) assigned by PayPal to filter the search results in list operations.</param>
        /// <param name="sortBy">Field name that determines sort order of results.</param>
        /// <param name="sortOrder">Specifies if order of results is ascending or descending.</param>
        /// <returns>PaymentHistory</returns>
        public static PaymentHistory List(APIContext apiContext, int? count = null, string startId = "", int? startIndex = null, string startTime = "", string endTime = "", string startDate = "", string endDate = "", string payeeEmail = "", string payeeId = "", string sortBy = "", string sortOrder = "")
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            var queryParameters = new QueryParameters();
            queryParameters["count"] = count.ToString();
            queryParameters["start_id"] = startId;
            queryParameters["start_index"] = startIndex.ToString();
            queryParameters["start_time"] = startTime;
            queryParameters["end_time"] = endTime;
            queryParameters["start_date"] = startDate;
            queryParameters["end_date"] = endDate;
            queryParameters["payee_email"] = payeeEmail;
            queryParameters["payee_id"] = payeeId;
            queryParameters["sort_by"] = sortBy;
            queryParameters["sort_order"] = sortOrder;

            // Configure and send the request
            var resourcePath = "v1/payments/payment" + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<PaymentHistory>(apiContext, HttpMethod.GET, resourcePath);
        }
Esempio n. 8
0
        /// <summary>
        /// Retrieves the list of Webhooks events resources for the application associated with token. The developers can use it to see list of past webhooks events.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="pageSize">Number of items to be returned by a GET operation</param>
        /// <param name="startTime">Resource creation time that indicates the start of a range of results.</param>
        /// <param name="endTime">Resource creation time that indicates the end of a range of results.</param>
        /// <returns>WebhookEventList</returns>
        public static WebhookEventList List(APIContext apiContext, int pageSize = 10, string startTime = "", string endTime = "")
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            var queryParameters = new QueryParameters();
            queryParameters["page_size"] = pageSize.ToString();
            queryParameters["start_time"] = startTime;
            queryParameters["end_time"] = endTime;

            // Configure and send the request
            var resourcePath = "v1/notifications/webhooks-events" + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<WebhookEventList>(apiContext, HttpMethod.GET, resourcePath);
        }
Esempio n. 9
0
        /// <summary>
        /// List billing plans according to optional query string parameters specified.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="page">A non-zero integer representing the 'page' of the results.</param>
        /// <param name="status">Specifies the status (CREATED, ACTIVE, or INACTIVE) of the billing plans to return.</param>
        /// <param name="pageSize">A non-negative, non-zero integer indicating the maximum number of results to return at one time.</param>
        /// <param name="totalRequired">A boolean indicating total number of items (total_items) and pages (total_pages) are expected to be returned in the response</param>
        /// <returns>PlanList</returns>
        public static PlanList List(APIContext apiContext, string page = "0", string status = "CREATED", string pageSize = "10", string totalRequired = "yes")
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            var queryParameters = new QueryParameters();
            queryParameters["page"] = page;
            queryParameters["status"] = status;
            queryParameters["page_size"] = pageSize;
            queryParameters["total_required"] = totalRequired;

            // Configure and send the request
            var resourcePath = "v1/payments/billing-plans" + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<PlanList>(apiContext, HttpMethod.GET, resourcePath);
        }
Esempio n. 10
0
        /// <summary>
        /// Lists all merchant-created templates. The list shows the emails, addresses, and phone numbers from the merchant profile.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="fields">The fields to return in the response. Value is `all` or `none`. Specify `none` to return only the template name, ID, and default attributes.</param>
        /// <returns>Templates</returns>
        public static InvoiceTemplates GetAll(APIContext apiContext, string fields = "all")
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            var queryParameters = new QueryParameters();
            queryParameters["fields"] = fields;

            // Configure and send the request
            var resourcePath = "v1/invoicing/templates" + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<InvoiceTemplates>(apiContext, HttpMethod.GET, resourcePath);
        }
Esempio n. 11
0
        /// <summary>
        /// Retrieves a list of Credit Card resources.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="pageSize">Number of items to be returned in the current page size, by a GET operation.</param>
        /// <param name="page">The page number to be retrieved, for the list of items, by the current GET request.</param>
        /// <param name="startTime">Resource creation time  as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the start of a range of results.</param>
        /// <param name="endTime">Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the end of a range of results.</param>
        /// <param name="sortOrder">Sort based on order of results. Options include 'asc' for ascending order or 'desc' for descending order.</param>
        /// <param name="sortBy">Sort based on 'create_time' or 'update_time'.</param>
        /// <param name="merchantId">Merchant identifier to filter the search results in list operations.</param>
        /// <param name="externalCardId">Externally provided card identifier to filter the search results in list operations.</param>
        /// <param name="externalCustomerId">Externally provided customer identifier to filter the search results in list operations.</param>
        /// <param name="totalRequired">Identifies if total count is required or not. Defaults to true.</param>
        /// <returns>CreditCardList</returns>
        public static CreditCardList List(APIContext apiContext, int pageSize = 10, int page = 1, string startTime = "", string endTime = "", string sortOrder = "asc", string sortBy = "create_time", string merchantId = "", string externalCardId = "", string externalCustomerId = "", bool totalRequired = true)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            var queryParameters = new QueryParameters();
            queryParameters["page_size"] = pageSize.ToString();
            queryParameters["page"] = page.ToString();
            queryParameters["start_time"] = startTime;
            queryParameters["end_time"] = endTime;
            queryParameters["sort_order"] = sortOrder;
            queryParameters["sort_by"] = sortBy;
            queryParameters["merchant_id"] = merchantId;
            queryParameters["external_card_id"] = externalCardId;
            queryParameters["external_customer_id"] = externalCustomerId;
            queryParameters["total_required"] = totalRequired.ToString();

            // Configure and send the request
            var resourcePath = "v1/vault/credit-cards" + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<CreditCardList>(apiContext, HttpMethod.GET, resourcePath);
        }
Esempio n. 12
0
        /// <summary>
        /// List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="agreementId">Identifier of the agreement resource for which to list transactions.</param>
        /// <param name="startDate">The start date of the range of transactions to list. Date format must be yyyy-MM-dd.</param>
        /// <param name="endDate">The end date of the range of transactions to list. Date format must be yyyy-MM-dd.</param>
        /// <returns>AgreementTransactions</returns>
        public static AgreementTransactions ListTransactions(APIContext apiContext, string agreementId, string startDate, string endDate)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(agreementId, "agreementId");
            ArgumentValidator.Validate(startDate, "startDate");
            ArgumentValidator.Validate(endDate, "endDate");

            var queryParameters = new QueryParameters();
            queryParameters["start_date"] = startDate;
            queryParameters["end_date"] = endDate;

            // Configure and send the request
            var pattern = "v1/payments/billing-agreements/{0}/transactions";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { agreementId }) + queryParameters.ToUrlFormattedString();
            return PayPalResource.ConfigureAndExecute<AgreementTransactions>(apiContext, HttpMethod.GET, resourcePath);
        }