当前位置: 首页>>代码示例>>C#>>正文


C# Api.APIContext类代码示例

本文整理汇总了C#中PayPal.Api.APIContext的典型用法代码示例。如果您正苦于以下问题:C# APIContext类的具体用法?C# APIContext怎么用?C# APIContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


APIContext类属于PayPal.Api命名空间,在下文中一共展示了APIContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        /// <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());
        }
开发者ID:santhign,项目名称:PayPal-NET-SDK,代码行数:20,代码来源:Payout.cs

示例2: CreateSingleSynchronousPayoutBatch

 public static PayoutBatch CreateSingleSynchronousPayoutBatch(APIContext apiContext)
 {
     return Payout.Create(apiContext, new Payout
     {
         sender_batch_header = new PayoutSenderBatchHeader
         {
             sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
             email_subject = "You have a Payout!"
         },
         items = new List<PayoutItem>
         {
             new PayoutItem
             {
                 recipient_type = PayoutRecipientType.EMAIL,
                 amount = new Currency
                 {
                     value = "1.0",
                     currency = "USD"
                 },
                 note = "Thanks for the payment!",
                 sender_item_id = "2014031400023",
                 receiver = "[email protected]"
             }
         }
     },
     true);
 }
开发者ID:ruanzx,项目名称:PayPal-NET-SDK,代码行数:27,代码来源:PayoutTest.cs

示例3: PaypalProcessor

 public PaypalProcessor()
 {
     // Authenticate with PayPal
     var config = ConfigManager.Instance.GetProperties();
     var accessToken = new OAuthTokenCredential(config).GetAccessToken();
     _apiContext = new APIContext(accessToken);
 }
开发者ID:Kokcuk,项目名称:socialforce,代码行数:7,代码来源:PaypalProcessor.cs

示例4: APIContextResetRequestIdTest

 public void APIContextResetRequestIdTest()
 {
     var apiContext = new APIContext();
     var originalRequestId = apiContext.RequestId;
     apiContext.ResetRequestId();
     Assert.AreNotEqual(originalRequestId, apiContext.RequestId);
 }
开发者ID:ruanzx,项目名称:PayPal-NET-SDK,代码行数:7,代码来源:APIContextTest.cs

示例5: GetAPIContext

 public static APIContext GetAPIContext()
 {
     // return apicontext object by invoking it with the accesstoken
     APIContext apiContext = new APIContext(GetAccessToken());
     apiContext.Config = GetConfig();
     return apiContext;
 }
开发者ID:CodePh4nt0m,项目名称:PaypalMVC,代码行数:7,代码来源:Configuration.cs

示例6: GetGetAPIContext

 public APIContext GetGetAPIContext()
 {
     var config = ConfigManager.Instance.GetProperties();
     string accessToken = new OAuthTokenCredential(config["clientId"], config["clientSecret"], config).GetAccessToken();
     APIContext apiContext = new APIContext(accessToken);
     apiContext.Config = config;
     return apiContext;
 }
开发者ID:vietplayfuri,项目名称:Asp_Master,代码行数:8,代码来源:PaypalHelper.cs

示例7: GetApiContext

        public APIContext GetApiContext(string accessToken = "")
        {
            var apiContext = new APIContext(string.IsNullOrEmpty(accessToken)
                ? GetAccessToken()
                : accessToken) { Config = GetConfig() };

            return apiContext;
        }
开发者ID:mfpalladino,项目名称:palla.labs.vdt,代码行数:8,代码来源:ConfiguradorPayPal.cs

示例8: CreatePaymentInternal

        private Payment CreatePaymentInternal(APIContext apiContext, string redirectUrl, double amountValue)
        {
            var amountStringValue = string.Format(CultureInfo.InvariantCulture, "{0:0.00}", amountValue);
            var invoiceNumber = Convert.ToString((new Random()).Next(100000));
            //similar to credit card create itemlist and add item objects to it
            var itemList = new ItemList { items = new List<Item>() };

            itemList.items.Add(new Item
            {
                name = "Socialforce credit amount",
                currency = "USD",
                price = amountStringValue,
                quantity = "1",
                sku = "sku"
            });

            var payer = new Payer { payment_method = "paypal" };

            // Configure Redirect Urls here with RedirectUrls object
            var redirUrls = new RedirectUrls
            {
                cancel_url = redirectUrl,
                return_url = redirectUrl
            };

            // similar as we did for credit card, do here and create details object
            //var details = new Details
            //{
            //    subtotal = amountValue.ToString(CultureInfo.InvariantCulture)
            //};

            // similar as we did for credit card, do here and create amount object
            var amount = new Amount
            {
                currency = "USD",
                total = amountStringValue, // Total must be equal to sum of shipping, tax and subtotal.
                //details = details
            };

            var transactionList = new List<Transaction>();

            transactionList.Add(new Transaction
            {
                description = "Gigbucket credit amount",
                invoice_number = invoiceNumber,
                amount = amount,
                item_list = itemList
            });

            var payment = new Payment
            {
                intent = "sale",
                payer = payer,
                transactions = transactionList,
                redirect_urls = redirUrls
            };
            return payment.Create(apiContext);
        }
开发者ID:Kokcuk,项目名称:socialforce,代码行数:58,代码来源:PaypalProcessor.cs

示例9: AvailableEventTypes

        /// <summary>
        /// Retrieves the master list of available Webhooks events-types resources for any webhook to subscribe to.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <returns>EventTypeList</returns>
        public static WebhookEventTypeList AvailableEventTypes(APIContext apiContext)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            // Configure and send the request
            var resourcePath = "v1/notifications/webhooks-event-types";
            return PayPalResource.ConfigureAndExecute<WebhookEventTypeList>(apiContext, HttpMethod.GET, resourcePath);
        }
开发者ID:GHLabs,项目名称:PayPal-NET-SDK,代码行数:14,代码来源:WebhookEventType.cs

示例10: Create

        /// <summary>
        /// Create a web experience profile by passing the name of the profile and other profile details in the request JSON to the request URI.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="webProfile">WebProfile object to be created as a PayPal resource.</param>
        /// <returns>CreateProfileResponse</returns>
        public static CreateProfileResponse Create(APIContext apiContext, WebProfile webProfile)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            // Configure and send the request
            var resourcePath = "v1/payment-experience/web-profiles";
            return PayPalResource.ConfigureAndExecute<CreateProfileResponse>(apiContext, HttpMethod.POST, resourcePath, webProfile.ConvertToJson());
        }
开发者ID:ruanzx,项目名称:PayPal-NET-SDK,代码行数:15,代码来源:WebProfile.cs

示例11: Create

        /// <summary>
        /// Creates the Webhook for the application associated with the access token.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="webhook"><seealso cref="Webhook"/> object to be created.</param>
        /// <returns>Webhook</returns>
        public static Webhook Create(APIContext apiContext, Webhook webhook)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);

            // Configure and send the request
            var resourcePath = "v1/notifications/webhooks";
            return PayPalResource.ConfigureAndExecute<Webhook>(apiContext, HttpMethod.POST, resourcePath, webhook.ConvertToJson());
        }
开发者ID:paypal,项目名称:PayPal-NET-SDK,代码行数:15,代码来源:Webhook.cs

示例12: GetApiContext

 // Returns APIContext object
 public static APIContext GetApiContext()
 {
     // Pass in a `APIContext` object to authenticate the call with a unique order id
      var apiContext = new APIContext(GetAccessToken())
      {
          Config = GetConfig()
      };
      return apiContext;
 }
开发者ID:chandrasoma-senani123,项目名称:PayPalIntegration,代码行数:10,代码来源:PayPalConfiguration.cs

示例13: APIContextValidConstructorWithAccessTokenTest

 public void APIContextValidConstructorWithAccessTokenTest()
 {
     var apiContext = new APIContext("abc");
     Assert.IsFalse(string.IsNullOrEmpty(apiContext.RequestId));
     Assert.IsFalse(apiContext.MaskRequestId);
     Assert.AreEqual("abc", apiContext.AccessToken);
     Assert.IsNull(apiContext.Config);
     Assert.IsNull(apiContext.HTTPHeaders);
     Assert.IsNotNull(apiContext.SdkVersion);
 }
开发者ID:ruanzx,项目名称:PayPal-NET-SDK,代码行数:10,代码来源:APIContextTest.cs

示例14: Get

        /// <summary>
        /// Obtain the Refund transaction resource for the given identifier.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="refundId">Identifier of the Refund Transaction Resource to obtain the data for.</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
            var pattern = "v1/payments/refund/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { refundId });
            return PayPalResource.ConfigureAndExecute<Refund>(apiContext, HttpMethod.GET, resourcePath);
        }
开发者ID:GHLabs,项目名称:PayPal-NET-SDK,代码行数:17,代码来源:Refund.cs

示例15: Get

        /// <summary>
        /// Obtain the payment instruction resource for the given identifier.
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="paymentId">Identifier of the Payment instruction resource to obtain the data for.</param>
        /// <returns>PaymentInstruction</returns>
        public static PaymentInstruction Get(APIContext apiContext, string paymentId)
        {
            // Validate the arguments to be used in the request
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(paymentId, "paymentId");

            // Configure and send the request
            var pattern = "v1/payments/payments/payment/{0}/payment-instruction";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { paymentId });
            return PayPalResource.ConfigureAndExecute<PaymentInstruction>(apiContext, HttpMethod.GET, resourcePath);
        }
开发者ID:ruanzx,项目名称:PayPal-NET-SDK,代码行数:17,代码来源:PaymentInstruction.cs


注:本文中的PayPal.Api.APIContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。