當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。