Ejemplo n.º 1
0
        /// <summary>
        /// Get call for Payment.
        /// GET /v1/payments/payment?count=:count&start_id=:start_id&start_index=:start_index&start_time=:start_time&end_time=:end_time&payee_id=:payee_id&sort_by=:sort_by&sort_order=:sort_order
        /// <param name="apiContext">APIContext required for the call</param>
        /// <param name="parameters">Container for query strings</param>
        /// <returns>Returns PaymentHistory object</returns>
        /// </summary>
        public static PaymentHistory Get(APIContext apiContext, QueryParameters parameters)
        {
            if (string.IsNullOrEmpty(apiContext.AccessToken))
            {
                throw new ArgumentNullException("AccessToken cannot be null");
            }
            string pattern = "v1/payments/payment?count={0}&start_id={1}&start_index={2}&start_time={3}&end_time={4}&payee_id={5}&sort_by={6}&sort_order={7}";

            object[] container    = new object[] { parameters };
            string   resourcePath = SDKUtil.FormatURIPath(pattern, container);
            string   payLoad      = string.Empty;

            return(PayPalResource.ConfigureAndExecute <PaymentHistory>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Voids (cancels) an Order.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <returns>Order</returns>
        public Order Void(APIContext apiContext)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/orders/{0}/do-void";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <Order>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Obtain the Refund transaction resource for the given identifier.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="refundId">string</param>
        /// <returns>Refund</returns>
        public static Refund Get(APIContext apiContext, string refundId)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(refundId, "refundId");

            // Configure and send the request
            object[] parameters   = new object[] { refundId };
            string   pattern      = "v1/payments/refund/{0}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <Refund>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Search for invoice resources.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="search">Search</param>
        /// <returns>Invoices</returns>
        public Invoices Search(APIContext apiContext, Search search)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(search, "search");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/invoicing/search";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = search.ConvertToJson();

            return(PayPalResource.ConfigureAndExecute <Invoices>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
Ejemplo n.º 5
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>
        /// <returns>CreditCard</returns>
        public CreditCard Update(APIContext apiContext)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");

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

            return(PayPalResource.ConfigureAndExecute <CreditCard>(apiContext, HttpMethod.PATCH, resourcePath, payLoad));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get call for Refund.
        /// GET /v1/payments/refund/:refundId
        /// <param name="accessToken">Access Token</param>
        /// <param name="refundId">RefundId</param>
        /// <returns>Returns Refund object</returns>
        /// </summary>
        public static Refund Get(string accessToken, string refundId)
        {
            if (String.IsNullOrEmpty(refundId))
            {
                throw new System.ArgumentNullException("refundId cannot be null or empty");
            }
            string pattern = "v1/payments/refund/{0}";

            object[] container    = new Object[] { refundId };
            string   resourcePath = SDKUtil.FormatURIPath(pattern, container);
            string   payLoad      = string.Empty;

            return(PayPalResource.ConfigureAndExecute <Refund>(accessToken, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Retrieves a list of Credit Card resources.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="containerDictionary">Dictionary<String, String></param>
        /// <returns>CreditCardHistory</returns>
        public static CreditCardHistory List(APIContext apiContext, Dictionary <String, String> containerDictionary)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(containerDictionary, "containerDictionary");

            // Configure and send the request
            object[] parameters   = new object[] { containerDictionary };
            string   pattern      = "v1/vault/credit-card?count={0}&start_id={1}&start_index={2}&start_time={3}&end_time={4}&payer_id={5}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <CreditCardHistory>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Retrieve the details of a particular web experience profile by passing the ID of the profile to the request URI.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="profileId">string</param>
        /// <returns>WebProfile</returns>
        public static WebProfile Get(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
            object[] parameters   = new object[] { profileId };
            string   pattern      = "v1/payment-experience/web-profiles/{0}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <WebProfile>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Obtain the Bank Account resource for the given identifier.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="bankAccountId">string</param>
        /// <returns>BankAccount</returns>
        public static BankAccount Get(APIContext apiContext, string bankAccountId)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(bankAccountId, "bankAccountId");

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

            return(PayPalResource.ConfigureAndExecute <BankAccount>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
        /// <summary>
        /// Reauthorizes an expired Authorization.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <returns>Authorization</returns>
        public Authorization Reauthorize(APIContext apiContext)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/authorization/{0}/reauthorize";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = this.ConvertToJson();

            return(PayPalResource.ConfigureAndExecute <Authorization>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Execute a billing agreement after buyer approval by passing the payment token to the request URI.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <returns>Agreement</returns>
        public Agreement Execute(APIContext apiContext)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.token, "token");

            // Configure and send the request
            object[] parameters   = new object[] { this.token };
            string   pattern      = "v1/payments/billing-agreements/{0}/agreement-execute";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <Agreement>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Returns user details
        /// <param name="apiContext">APIContext to be used for the call.</param>
        /// <param name="userinfoParameters">Query parameters used for API call</param>
        /// </summary>
        public static Userinfo GetUserinfo(APIContext apiContext, UserinfoParameters userinfoParameters)
        {
            string pattern = "v1/identity/openidconnect/userinfo?schema={0}&access_token={1}";

            object[] parameters   = new object[] { userinfoParameters };
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);

            if (apiContext == null)
            {
                apiContext = new APIContext();
            }
            apiContext.MaskRequestId = true;
            return(PayPalResource.ConfigureAndExecute <Userinfo>(apiContext, HttpMethod.GET, resourcePath));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Update a web experience profile by passing the ID of the profile to the request URI. In addition, pass the profile details in the request JSON. If your request does not include values for all profile detail fields, the previously set values for the omitted fields are removed by this operation.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <returns></returns>
        public void Update(APIContext apiContext)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payment-experience/web-profiles/{0}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = this.ConvertToJson();

            PayPalResource.ConfigureAndExecute <object>(apiContext, HttpMethod.PUT, resourcePath, payLoad);
            return;
        }
Ejemplo n.º 14
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="refund">Refund</param>
        /// <returns>Refund</returns>
        public Refund Refund(APIContext apiContext, Refund refund)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");
            ArgumentValidator.Validate(refund, "refund");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/order/{0}/refund";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = refund.ConvertToJson();

            return(PayPalResource.ConfigureAndExecute <Refund>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
Ejemplo n.º 15
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="paymentExecution">PaymentExecution</param>
        /// <returns>Payment</returns>
        public Payment Execute(APIContext apiContext, PaymentExecution paymentExecution)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");
            ArgumentValidator.Validate(paymentExecution, "paymentExecution");

            // Configure and send the request
            object[]     parameters   = { this.id };
            const string pattern      = "v1/payments/payment/{0}/execute";
            string       resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string       payLoad      = paymentExecution.ConvertToJson();

            return(PayPalResource.ConfigureAndExecute <Payment>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
Ejemplo n.º 16
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="patchRequest">PatchRequest</param>
        public void 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
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/billing-agreements/{0}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = patchRequest.ConvertToJson();

            PayPalResource.ConfigureAndExecute <Agreement>(apiContext, HttpMethod.PATCH, resourcePath, payLoad);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Set the balance for an agreement by passing the ID of the agreement to the request URI. In addition, pass a common_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="currency">Currency</param>
        /// <returns></returns>
        public void SetBalance(APIContext apiContext, Currency currency)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");
            ArgumentValidator.Validate(currency, "currency");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/billing-agreements/{0}/set-balance";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = currency.ConvertToJson();

            PayPalResource.ConfigureAndExecute <object>(apiContext, HttpMethod.POST, resourcePath, payLoad);
            return;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Cancel a billing agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor 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="agreementStateDescriptor">AgreementStateDescriptor</param>
        /// <returns></returns>
        public void Cancel(APIContext apiContext, AgreementStateDescriptor agreementStateDescriptor)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");
            ArgumentValidator.Validate(agreementStateDescriptor, "agreementStateDescriptor");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/billing-agreements/{0}/cancel";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = agreementStateDescriptor.ConvertToJson();

            PayPalResource.ConfigureAndExecute <object>(apiContext, HttpMethod.POST, resourcePath, payLoad);
            return;
        }
Ejemplo n.º 19
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)
        {
            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));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Cancels an invoice.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="cancelNotification">CancelNotification</param>
        /// <returns></returns>
        public void Cancel(APIContext apiContext, CancelNotification cancelNotification)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");
            ArgumentValidator.Validate(cancelNotification, "cancelNotification");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/invoicing/invoices/{0}/cancel";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = cancelNotification.ConvertToJson();

            PayPalResource.ConfigureAndExecute <object>(apiContext, HttpMethod.POST, resourcePath, payLoad);
            return;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Delete the Credit Card resource for the given identifier.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <returns></returns>
        public void Delete(APIContext apiContext)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");

            // Configure and send the request
            apiContext.MaskRequestId = true;
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/vault/credit-card/{0}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            PayPalResource.ConfigureAndExecute <object>(apiContext, HttpMethod.DELETE, resourcePath, payLoad);
            return;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Mark the status of the invoice as refunded.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="refundDetail">RefundDetail</param>
        /// <returns></returns>
        public void RecordRefund(APIContext apiContext, RefundDetail refundDetail)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(this.id, "Id");
            ArgumentValidator.Validate(refundDetail, "refundDetail");

            // Configure and send the request
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/invoicing/invoices/{0}/record-refund";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = refundDetail.ConvertToJson();

            PayPalResource.ConfigureAndExecute <object>(apiContext, HttpMethod.POST, resourcePath, payLoad);
            return;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Voids (cancels) an Authorization.
        /// </summary>
        public Authorization Void(APIContext apiContext)
        {
            if (string.IsNullOrEmpty(apiContext.AccessToken))
            {
                throw new ArgumentNullException("AccessToken cannot be null or empty");
            }
            if (this.id == null)
            {
                throw new ArgumentNullException("Id cannot be null");
            }
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/payments/authorization/{0}/void";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <Authorization>(apiContext, HttpMethod.POST, resourcePath, payLoad));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Obtain the Credit Card resource for the given identifier.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="creditCardId">string</param>
        /// <returns>CreditCard</returns>
        public static CreditCard Get(APIContext apiContext, string creditCardId)
        {
            if (string.IsNullOrEmpty(apiContext.AccessToken))
            {
                throw new ArgumentNullException("AccessToken cannot be null or empty");
            }
            if (creditCardId == null)
            {
                throw new ArgumentNullException("creditCardId cannot be null");
            }
            object[] parameters   = new object[] { creditCardId };
            string   pattern      = "v1/vault/credit-card/{0}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <CreditCard>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Retrieves a list of Payment resources.
        /// </summary>
        public static PaymentHistory List(APIContext apiContext, Dictionary <String, String> containerDictionary)
        {
            if (string.IsNullOrEmpty(apiContext.AccessToken))
            {
                throw new ArgumentNullException("AccessToken cannot be null or empty");
            }
            if (containerDictionary == null)
            {
                throw new ArgumentNullException("containerDictionary cannot be null");
            }
            object[] parameters   = new object[] { containerDictionary };
            string   pattern      = "v1/payments/payment?count={0}&start_id={1}&start_index={2}&start_time={3}&end_time={4}&payee_id={5}&sort_by={6}&sort_order={7}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <PaymentHistory>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Get call for Payment.
        /// GET /v1/payments/payment/:paymentId
        /// <param name="apiContext">APIContext required for the call</param>
        /// <param name="paymentId">PaymentId</param>
        /// <returns>Returns Payment object</returns>
        /// </summary>
        public static Payment Get(APIContext apiContext, string paymentId)
        {
            if (string.IsNullOrEmpty(apiContext.AccessToken))
            {
                throw new ArgumentNullException("AccessToken cannot be null");
            }
            if (String.IsNullOrEmpty(paymentId))
            {
                throw new System.ArgumentNullException("paymentId cannot be null or empty");
            }
            string pattern = "v1/payments/payment/{0}";

            object[] container    = new Object[] { paymentId };
            string   resourcePath = SDKUtil.FormatURIPath(pattern, container);
            string   payLoad      = string.Empty;

            return(PayPalResource.ConfigureAndExecute <Payment>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 27
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">string</param>
        /// <returns>AgreementTransactions</returns>
        public static AgreementTransactions ListTransactions(APIContext apiContext, string agreementId, DateTime startDate, DateTime 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");

            // Configure and send the request
            var dateFormat = "yyyy-MM-dd";

            object[] parameters   = new object[] { agreementId, startDate.ToString(dateFormat), endDate.ToString(dateFormat) };
            string   pattern      = "v1/payments/billing-agreements/{0}/transactions?start_date={1}&end_date={2}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            return(PayPalResource.ConfigureAndExecute <AgreementTransactions>(apiContext, HttpMethod.GET, resourcePath, payLoad));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Delete the Credit Card resource for the given identifier. Returns 204 No Content when the card is deleted successfully.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <returns></returns>
        public void Delete(APIContext apiContext)
        {
            if (string.IsNullOrEmpty(apiContext.AccessToken))
            {
                throw new ArgumentNullException("AccessToken cannot be null or empty");
            }
            if (this.id == null)
            {
                throw new ArgumentNullException("Id cannot be null");
            }
            apiContext.MaskRequestId = true;
            object[] parameters   = new object[] { this.id };
            string   pattern      = "v1/vault/credit-card/{0}";
            string   resourcePath = SDKUtil.FormatURIPath(pattern, parameters);
            string   payLoad      = "";

            PayPalResource.ConfigureAndExecute <object>(apiContext, HttpMethod.DELETE, resourcePath, payLoad);
            return;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Creates an Access Token from an Authorization Code.
        /// <param name="apiContext">APIContext to be used for the call.</param>
        /// <param name="createFromAuthorizationCodeParameters">Query parameters used for API call</param>
        /// </summary>
        public static Tokeninfo CreateFromAuthorizationCode(APIContext apiContext, CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters)
        {
            string pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&code={1}&redirect_uri={2}";

            object[] parameters   = new object[] { createFromAuthorizationCodeParameters };
            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));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Creates an Access Token from an Authorization Code.
        /// <param name="apiContext">APIContext to be used for the call.</param>
        /// <param name="createFromAuthorizationCodeParameters">Query parameters used for API call</param>
        /// </summary>
        public static Tokeninfo CreateFromAuthorizationCode(APIContext apiContext, CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters)
        {
            string pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&code={1}&redirect_uri={2}";

            object[] parameters   = new object[] { createFromAuthorizationCodeParameters };
            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>();

            if (createFromAuthorizationCodeParameters.getClientId() != null && createFromAuthorizationCodeParameters.getClientSecret() != null)
            {
                OAuthTokenCredential oauthTokenCredential = new OAuthTokenCredential(createFromAuthorizationCodeParameters.getClientId(), createFromAuthorizationCodeParameters.getClientSecret());
                headersMap.Add("Authorization", oauthTokenCredential.GenerateBasicAuthHeader());
            }
            headersMap.Add("Content-Type", "application/x-www-form-urlencoded");
            return(PayPalResource.ConfigureAndExecute <Tokeninfo>(apiContext, HttpMethod.POST,
                                                                  resourcePath, headersMap, payLoad));
        }