コード例 #1
0
        /// <summary>
        /// Deletes the Webhook identified by webhook_id for the application associated with access token.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="webhookId">Identifier of the webhook</param>
        public static void Delete(APIContext apiContext, string webhookId)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(webhookId, "webhookId");

            // Configure and send the request
            apiContext.MaskRequestId = true;
            var pattern      = "v1/notifications/webhooks/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { webhookId });

            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.DELETE, resourcePath);
        }
コード例 #2
0
        /// <summary>
        /// Delete an existing web experience profile by passing the profile ID to the request URI.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="profileId">ID of the profile to delete.</param>
        public static void Delete(APIContext apiContext, string profileId)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(profileId, "profileId");

            // Configure and send the request
            apiContext.MaskRequestId = true;
            var pattern      = "v1/payment-experience/web-profiles/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { profileId });

            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.DELETE, resourcePath);
        }
コード例 #3
0
ファイル: Invoice.cs プロジェクト: jhoerr/PayPal-NET-SDK
        /// <summary>
        /// Cancels an invoice.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="invoiceId">ID of the invoice to cancel.</param>
        /// <param name="cancelNotification">CancelNotification</param>
        public static void Cancel(APIContext apiContext, string invoiceId, CancelNotification cancelNotification)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(invoiceId, "invoiceId");
            ArgumentValidator.Validate(cancelNotification, "cancelNotification");

            // Configure and send the request
            var pattern      = "v1/invoicing/invoices/{0}/cancel";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { invoiceId });

            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.POST, resourcePath, cancelNotification.ConvertToJson());
        }
コード例 #4
0
ファイル: Invoice.cs プロジェクト: jhoerr/PayPal-NET-SDK
        /// <summary>
        /// Mark the status of the invoice as refunded.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="invoiceId">ID fo the invoice to mark as refunded.</param>
        /// <param name="refundDetail">RefundDetail</param>
        public static void RecordRefund(APIContext apiContext, string invoiceId, RefundDetail refundDetail)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(invoiceId, "invoiceId");
            ArgumentValidator.Validate(refundDetail, "refundDetail");

            // Configure and send the request
            var pattern      = "v1/invoicing/invoices/{0}/record-refund";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { invoiceId });

            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.POST, resourcePath, refundDetail.ConvertToJson());
        }
コード例 #5
0
ファイル: BankAccount.cs プロジェクト: riyaships/PharmixDMD
        /// <summary>
        /// Update information in a previously saved bank account. Only the modified fields need to be passed in the request.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="bankAccountId">ID of the bank account to update.</param>
        /// <param name="patchRequest">PatchRequest</param>
        /// <returns>BankAccount</returns>
        public static BankAccount Update(APIContext apiContext, string bankAccountId, PatchRequest patchRequest)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(bankAccountId, "bankAccountId");
            ArgumentValidator.Validate(patchRequest, "patchRequest");

            // Configure and send the request
            var pattern      = "v1/vault/bank-accounts/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { bankAccountId });

            return(PayPalResource.ConfigureAndExecute <BankAccount>(apiContext, HttpMethod.PATCH, resourcePath, patchRequest.ConvertToJson()));
        }
コード例 #6
0
        /// <summary>
        /// Creates (and processes) a new Capture Transaction added as a related resource.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="orderId">ID of the order to capture.</param>
        /// <param name="capture">Capture</param>
        /// <returns>Capture</returns>
        public static Capture Capture(APIContext apiContext, string orderId, Capture capture)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(orderId, "orderId");
            ArgumentValidator.Validate(capture, "capture");

            // Configure and send the request
            var pattern      = "v1/payments/orders/{0}/capture";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { orderId });

            return(PayPalResource.ConfigureAndExecute <Capture>(apiContext, HttpMethod.POST, resourcePath, capture.ConvertToJson()));
        }
コード例 #7
0
        /// <summary>
        /// Set the balance for an agreement by passing the ID of the agreement to the request URI. In addition, pass a Currency object in the request JSON that specifies the currency type and value of the balance.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="agreementId">ID of the billing agreement to perform the operation against.</param>
        /// <param name="currency">Currency</param>
        public static void SetBalance(APIContext apiContext, string agreementId, Currency currency)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(agreementId, "agreementId");
            ArgumentValidator.Validate(currency, "currency");

            // Configure and send the request
            var pattern      = "v1/payments/billing-agreements/{0}/set-balance";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { agreementId });

            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.POST, resourcePath, currency.ConvertToJson());
        }
コード例 #8
0
        /// <summary>
        /// Creates (and processes) a new Refund Transaction added as a related resource.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="saleId">ID of the sale to refund.</param>
        /// <param name="refund">Refund</param>
        /// <returns>Refund</returns>
        public static Refund Refund(APIContext apiContext, string saleId, Refund refund)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(saleId, "saleId");
            ArgumentValidator.Validate(refund, "refund");

            // Configure and send the request
            var pattern      = "v1/payments/sale/{0}/refund";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { saleId });

            return(PayPalResource.ConfigureAndExecute <Refund>(apiContext, HttpMethod.POST, resourcePath, refund.ConvertToJson()));
        }
コード例 #9
0
        /// <summary>
        /// Update details of a billing agreement, such as the description, shipping address, and start date, by passing the ID of the agreement to the request URI.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="agreementId">ID of the billing agreement that will be updated.</param>
        /// <param name="patchRequest">PatchRequest</param>
        public static void Update(APIContext apiContext, string agreementId, PatchRequest patchRequest)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(agreementId, "agreementId");
            ArgumentValidator.Validate(patchRequest, "patchRequest");

            // Configure and send the request
            var pattern      = "v1/payments/billing-agreements/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { agreementId });

            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, patchRequest.ConvertToJson());
        }
コード例 #10
0
        /// <summary>
        /// Cancel a billing agreement by passing the ID of the agreement to the request URI. In addition, pass an AgreementStateDescriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="agreementId">ID of the billing agreement that will be canceled.</param>
        /// <param name="agreementStateDescriptor">AgreementStateDescriptor</param>
        public static void Cancel(APIContext apiContext, string agreementId, AgreementStateDescriptor agreementStateDescriptor)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(agreementId, "agreementId");
            ArgumentValidator.Validate(agreementStateDescriptor, "agreementStateDescriptor");

            // Configure and send the request
            var pattern      = "v1/payments/billing-agreements/{0}/cancel";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { agreementId });

            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.POST, resourcePath, agreementStateDescriptor.ConvertToJson());
        }
コード例 #11
0
        /// <summary>
        /// Executes the payment (after approved by the Payer) associated with this resource when the payment method is PayPal.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="paymentId">ID of the payment to execute.</param>
        /// <param name="paymentExecution">PaymentExecution</param>
        /// <returns>Payment</returns>
        public static Payment Execute(APIContext apiContext, string paymentId, PaymentExecution paymentExecution)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(paymentId, "paymentId");
            ArgumentValidator.Validate(paymentExecution, "paymentExecution");

            // Configure and send the request
            var pattern      = "v1/payments/payment/{0}/execute";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { paymentId });

            return(PayPalResource.ConfigureAndExecute <Payment>(apiContext, HttpMethod.POST, resourcePath, paymentExecution.ConvertToJson()));
        }
コード例 #12
0
        /// <summary>
        /// Update information in a previously saved card. Only the modified fields need to be passed in the request.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="patchRequest">PatchRequest</param>
        /// <returns>CreditCard</returns>
        public CreditCard Update(APIContext apiContext, PatchRequest patchRequest)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");
            ArgumentValidator.Validate(patchRequest, "patchRequest");

            // Configure and send the request
            var pattern      = "v1/vault/credit-cards/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { this.id });

            return(PayPalResource.ConfigureAndExecute <CreditCard>(apiContext, HttpMethod.PATCH, resourcePath, patchRequest.ConvertToJson()));
        }
コード例 #13
0
        /// <summary>
        /// Updates the Webhook identified by webhook_id for the application associated with access token.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="patchRequest">PatchRequest</param>
        /// <returns>Webhook</returns>
        public static Webhook Update(APIContext apiContext, string webhookId, PatchRequest patchRequest)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(webhookId, "webhookId");
            ArgumentValidator.Validate(patchRequest, "patchRequest");

            // Configure and send the request
            var pattern      = "v1/notifications/webhooks/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { webhookId });

            return(PayPalResource.ConfigureAndExecute <Webhook>(apiContext, HttpMethod.PATCH, resourcePath, patchRequest.ConvertToJson()));
        }
コード例 #14
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));
        }
コード例 #15
0
        /// <summary>
        /// Deletes an external refund, by invoice ID and transaction ID.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="invoiceId">The ID of the invoice from which to delete the refund transaction.</param>
        /// <param name="transactionId">The ID of the refund transaction to delete.</param>
        public static void DeleteExternalRefund(APIContext apiContext, string invoiceId, string transactionId)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(invoiceId, "invoiceId");
            ArgumentValidator.Validate(transactionId, "transactionId");

            // Configure and send the request
            apiContext.MaskRequestId = true;
            var pattern      = "v1/invoicing/invoices/{0}/refund-records/{1}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { invoiceId, transactionId });

            PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.DELETE, resourcePath);
        }
コード例 #16
0
        /// <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()));
        }
コード例 #17
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));
        }
コード例 #18
0
        /// <summary>
        /// Helper method for creating Access and Refresh Tokens from an Authorization Code.
        /// </summary>
        /// <param name="apiContext">APIContext to be used for the call.</param>
        /// <param name="createFromAuthorizationCodeParameters">Query parameters used for the API call.</param>
        /// <param name="resourcePath">The path to the REST API resource that will be requested.</param>
        /// <returns>A TokenInfo object containing the Access and Refresh Tokens.</returns>
        private static Tokeninfo CreateFromAuthorizationCodeParameters(APIContext apiContext, CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters, string resourcePath)
        {
            var payLoad = resourcePath.Substring(resourcePath.IndexOf('?') + 1);

            resourcePath = resourcePath.Substring(0, resourcePath.IndexOf("?"));
            var headersMap = new Dictionary <string, string>();

            headersMap.Add(BaseConstants.ContentTypeHeader, "application/x-www-form-urlencoded");
            if (apiContext == null)
            {
                apiContext = new APIContext();
            }
            apiContext.HTTPHeaders   = headersMap;
            apiContext.MaskRequestId = true;
            return(PayPalResource.ConfigureAndExecute <Tokeninfo>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
コード例 #19
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()));
        }
コード例 #20
0
        /// <summary>
        /// Lists merchant invoices. Optionally, you can specify one or more query parameters to filter the response.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="page">A *zero-relative* index of the list of merchant invoices.</param>
        /// <param name="pageSize">The number of invoices to list beginning with the specified `page`.</param>
        /// <param name="totalCountRequired">Indicates whether the total count appears in the response. Default is `false`.</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));
        }
コード例 #21
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);
        }
コード例 #22
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.</param>
        /// <param name="endDate">The end date of the range of transactions to list.</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");

            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));
        }
コード例 #23
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));
        }
コード例 #24
0
        /// <summary>
        /// Generates a QR code for an invoice, by ID.<br/><br/>The QR code is a PNG image in [Base64-encoded](https://www.base64encode.org/) format that corresponds to the invoice ID. You can generate a QR code for an invoice and add it to a paper or PDF invoice. When a customer uses their mobile device to scan the QR code, he or she is redirected to the PayPal mobile payment flow where he or she can pay online with PayPal or a credit card.<br/><br/>Before you get a QR code, you must:<ol><li><p>[Create an invoice](#invoices_create). Specify `[email protected]` as the recipient email address in the `billing_info` object. Use a customer email address only if you want to email the invoice.</p></li><li><p>[Send an invoice](#invoices_send) to move the invoice from a draft to payable state. If you specify `[email protected]` as the recipient email address, the invoice is not emailed.</p></li></ol>
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="invoiceId">The ID of the invoice for which to generate a QR code.</param>
        /// <param name="width">The width, in pixels, of the QR code image. Valid value is from 150 to 500. Default is 500.</param>
        /// <param name="height">The height, in pixels, of the QR code image. Valid value is from 150 to 500. Default is 500.</param>
        /// <param name="action">The type of URL for which to generate a QR code. Default is `pay` and is the only supported value.</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));
        }
コード例 #25
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));
        }
コード例 #26
0
        /// <summary>
        /// Creates an Access Token from an Refresh Token
        /// <param name="apiContext">APIContext to be used for the call</param>
        /// <param name="createFromRefreshTokenParameters">Query parameters used for API call</param>
        /// </summary>
        public Tokeninfo CreateFromRefreshToken(APIContext apiContext, CreateFromRefreshTokenParameters createFromRefreshTokenParameters)
        {
            string pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&refresh_token={1}&scope={2}&client_id={3}&client_secret={4}";

            createFromRefreshTokenParameters.SetRefreshToken(HttpUtility.UrlEncode(refresh_token));
            object[] parameters   = new object[] { createFromRefreshTokenParameters };
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = resourcePath.Substring(resourcePath.IndexOf('?') + 1);

            resourcePath = resourcePath.Substring(0, resourcePath.IndexOf("?"));
            Dictionary <string, string> headersMap = new Dictionary <string, string>();

            headersMap.Add(BaseConstants.ContentTypeHeader, "application/x-www-form-urlencoded");
            if (apiContext == null)
            {
                apiContext = new APIContext();
            }
            apiContext.HTTPHeaders   = headersMap;
            apiContext.MaskRequestId = true;
            return(PayPalResource.ConfigureAndExecute <Tokeninfo>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
コード例 #27
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>
        /// <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 = "")
        {
            // 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;

            // Configure and send the request
            var resourcePath = "v1/vault/credit-cards" + queryParameters.ToUrlFormattedString();

            return(PayPalResource.ConfigureAndExecute <CreditCardList>(apiContext, HttpMethod.GET, resourcePath));
        }
コード例 #28
0
        /// <summary>
        /// Retrieves a list of payments.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="count">Number of items to be returned by a GET operation.</param>
        /// <param name="startId">A resource ID that indicates the starting resource in the returned results.</param>
        /// <param name="startIndex">Start index of the resources to be returned. Typically used to jump to a specific position in the resource history based on it's cart.</param>
        /// <param name="startTime">Resource creation time in ISO-8601 format that indicates the start of a range of results. Example: start_time=2016-03-06T11:00:00Z.</param>
        /// <param name="endTime">Resource creation time in ISO-8601 format that indicates the end of a range of results. Example: end_time=2016-03-20T10:30:00Z.</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));
        }