Ejemplo n.º 1
0
 public static IRestResponse ActivateSubscription(string subscriptionId)
 {
     var client = RestCleintV1.client("/v1/payments/billing/subscriptions/" + subscriptionId + "/activate");
     var request = new RestRequest(Method.POST);
     request.AddHeader("Content-Type", "application/json");
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 2
0
 public static IRestResponse GetSubscription(string subscriptionId)
 {
     var client = RestCleintV1.client("/v1/catalogs/subscriptions/" + subscriptionId);
     var request = new RestRequest(Method.GET);
     request.AddHeader("Content-type", "application/json");
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 3
0
 public static IRestResponse GetPlan(string planId)
 {
     var client = RestCleintV1.client("/v1/payments/billing/plans/" + planId);
     var request = new RestRequest(Method.GET);
     request.AddHeader("Content-Type", "application/json");
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 4
0
 public static IRestResponse ListPans(string productId, int pageSize, int page, bool totalRequired)
 {
     var client = RestCleintV1.client($"/v1/billing/plans?product_id={productId}&page_size={pageSize}&page={page}&total_required={totalRequired}");
     var request = new RestRequest(Method.GET);
     request.AddHeader("Content-type", "application/json");           
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 5
0
 public static IRestResponse CreateSubscription(string planId)
 {
     var client = RestCleintV1.client("/v1/billing/subscriptions");
     var request = new RestRequest(Method.POST);
     request.AddHeader("Content-type", "application/json");
     request.AddHeader("Prefer", "return=representation");
     request.AddHeader("PayPal-Request-Id", "SUBSCRIPTION-my-testing01");
     request.AddJsonBody(BuildSubscriptionBody(planId));
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 6
0
 public static IRestResponse SuspendSubscription(string subscriptionId)
 {
     var client = RestCleintV1.client("/v1/payments/billing/subscriptions/" + subscriptionId + "/suspend");
     var request = new RestRequest(Method.POST);
     request.AddHeader("Content-Type", "application/json");
     request.AddJsonBody(new CancelSubscription
     {
         Reason = "Iten out of stock"
     });
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 7
0
 public static IRestResponse CancelSubscription(string subscriptionId)
 {
     var client = RestCleintV1.client("/v1/payments/billing/subscriptions/" + subscriptionId + "/cancel");
     var request = new RestRequest(Method.POST);
     request.AddHeader("Content-Type", "application/json");
     request.AddJsonBody(new CancelSubscription
     {
         Reason = "Not satisfied with the service"
     });
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 8
0
 public static IRestResponse PatchPlan(string planId)
 {
     var client = RestCleintV1.client("/v1/payments/billing/plans/" + planId);
     var request = new RestRequest(Method.PATCH);
     request.AddHeader("Content-Type", "application/json");
     request.AddJsonBody(new List<PatchObject>()
     {
         new PatchObject() {
             Op = "replace",
             Path = "/payment_preferences/payment_failure_threshold",
             Value = 7
         }
     });
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 9
0
 public static IRestResponse UpdateProduct(string productId)
 {
     var client = RestCleintV1.client("/v1/catalogs/products/" + productId);
     var request = new RestRequest(Method.PATCH);
     request.AddHeader("Content-type", "application/json");
     request.AddJsonBody(new List<PatchObject>()
     {
         new PatchObject()
         {
             Op = "replace",
             Path = "/description",
             Value = "Premium video streaming service"
         }
     });
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 10
0
 public static IRestResponse UpdatePlanPricing(string planId)
 {
     var client = RestCleintV1.client("/v1/payments/billing/plans/" + planId + "/update-pricing-schemes");
     var request = new RestRequest(Method.POST);
     request.AddHeader("Content-Type", "application/json");
     request.AddJsonBody(new List<PricingScheme>() { 
         new PricingScheme()
         {
             FixedPrice = new Currency()
             {
                 Value = "50",
                 CurrencyCode = "USD"
             }                
         }
     });
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 11
0
 public static IRestResponse CreateProduct()
 {
     var client = RestCleintV1.client("/v1/catalogs/products");
     var request = new RestRequest(Method.POST);
     request.AddHeader("Content-type", "application/json");
     request.AddHeader("Prefer", "return=representation");
     request.AddHeader("PayPal-Request-Id", "PRODUCT-my-testing01");
     request.AddJsonBody(new Product
     {                
         Name = "Video Streaming Service",
         Description = "Video streaming service",
         Type = "SERVICE",
         Category = "SOFTWARE",
         ImageUrl = "https://example.com/streaming.jpg",
         HomeUrl = "https://example.com/home"
     });
     IRestResponse response = client.Execute(request);
     return response;
 }
Ejemplo n.º 12
0
 public static IRestResponse UpdateSubscription(string subscriptionId)
 {
     var client = RestCleintV1.client("/v1/catalogs/subscriptions/" + subscriptionId);
     var request = new RestRequest(Method.PATCH);
     request.AddHeader("Content-type", "application/json");
     request.AddJsonBody(new List<PatchObject>()
     {
         new PatchObject()
         {
             Op = "replace",
             Path = "/billing_info/outstanding_balance",
             Value = new Currency
             {
                 Value = "50.00",
                 CurrencyCode = "USD"
             }
         }
     });
     IRestResponse response = client.Execute(request);
     return response;
 }