protected void Page_Load(object sender, EventArgs e) { var CurrContext = HttpContext.Current; var profile = new WebProfile(); var patchRequest = new PatchRequest(); try { var apiContext = Configuration.GetAPIContext(); // Setup the profile we want to create profile.name = Guid.NewGuid().ToString(); profile.presentation = new Presentation(); profile.presentation.brand_name = "Sample brand"; profile.presentation.locale_code = "US"; profile.presentation.logo_image = "https://www.paypal.com/"; profile.input_fields = new InputFields(); profile.input_fields.address_override = 1; profile.input_fields.allow_note = true; profile.input_fields.no_shipping = 0; profile.flow_config = new FlowConfig(); profile.flow_config.bank_txn_pending_url = "https://www.paypal.com/"; profile.flow_config.landing_page_type = "billing"; // Create the profile var response = profile.Create(apiContext); // Create a patch and add it to the PatchRequest object used to // perform the partial update on the profile. var patch1 = new Patch(); patch1.op = "add"; patch1.path = "/presentation/brand_name"; patch1.value = "New brand name"; patchRequest.Add(patch1); var patch2 = new Patch(); patch2.op = "remove"; patch2.path = "/flow_config/landing_page_type"; patchRequest.Add(patch1); // Get the profile object and partially update the profile. var retrievedProfile = WebProfile.Get(apiContext, response.id); retrievedProfile.PartialUpdate(apiContext, patchRequest); CurrContext.Items.Add("ResponseJson", "Experience profile successfully updated."); // Delete the newly-created profile retrievedProfile.Delete(apiContext); } catch (Exception ex) { CurrContext.Items.Add("Error", ex.Message); } CurrContext.Items.Add("RequestJson", patchRequest.ConvertToJson()); Server.Transfer("~/Response.aspx"); }
protected void Page_Load(object sender, EventArgs e) { try { // In order to update the plan, you must define one or more // patches to be applied to the plan. The patches will be // applied in the order in which they're specified. // // The 'value' of each Patch object will need to be a Plan object // that contains the fields that will be modified. // More Information: https://developer.paypal.com/webapps/developer/docs/api/#patchrequest-object var tempPlan = new Plan(); tempPlan.description = "Some updated description (" + Guid.NewGuid().ToString() + ")."; // NOTE: Only the 'replace' operation is supported when updating // billing plans. var patch = new Patch() { op = "replace", path = "/", value = tempPlan }; var patchRequest = new PatchRequest(); patchRequest.Add(patch); HttpContext.Current.Items.Add("RequestJson", Common.FormatJsonString(patchRequest.ConvertToJson())); // Get the plan we want to update. var apiContext = Configuration.GetAPIContext(); var planId = "P-23P27073KJ353233VHEXQM4Y"; var plan = Plan.Get(apiContext, planId); // Update the plan. plan.Update(apiContext, patchRequest); // After it's been updated, get it again to make sure it was updated properly (and so we can see what it looks like afterwards). var updatedPlan = Plan.Get(apiContext, planId); HttpContext.Current.Items.Add("ResponseTitle", "Updated Billing Plan Details"); HttpContext.Current.Items.Add("ResponseJson", Common.FormatJsonString(updatedPlan.ConvertToJson())); } catch (Exception ex) { HttpContext.Current.Items.Add("Error", ex.Message); } Server.Transfer("~/Response.aspx"); }
/// <summary> /// Partially update an existing web experience profile by passing the ID of the profile to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, path of the profile location to update, and a new value if needed to complete the operation. /// </summary> /// <param name="apiContext">APIContext used for the API call.</param> /// <param name="profileId">ID fo the web profile to partially update.</param> /// <param name="patchRequest">PatchRequest</param> public static void PartialUpdate(APIContext apiContext, string profileId, PatchRequest patchRequest) { // Validate the arguments to be used in the request ArgumentValidator.ValidateAndSetupAPIContext(apiContext); ArgumentValidator.Validate(profileId, "profileId"); ArgumentValidator.Validate(patchRequest, "patchRequest"); // Configure and send the request var pattern = "v1/payment-experience/web-profiles/{0}"; var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { profileId }); PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, patchRequest.ConvertToJson()); }
/// <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="webhookId">ID of the webhook to be updated.</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()); }
/// <summary> /// Partially update the Payment resource for the given identifier /// </summary> /// <param name="apiContext">APIContext used for the API call.</param> /// <param name="paymentId">ID of the payment to update.</param> /// <param name="patchRequest">PatchRequest</param> public static void Update(APIContext apiContext, string paymentId, PatchRequest patchRequest) { // Validate the arguments to be used in the request ArgumentValidator.ValidateAndSetupAPIContext(apiContext); ArgumentValidator.Validate(paymentId, "paymentId"); ArgumentValidator.Validate(patchRequest, "patchRequest"); // Configure and send the request var pattern = "v1/payments/payment/{0}"; var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { paymentId }); PayPalResource.ConfigureAndExecute(apiContext, HttpMethod.PATCH, resourcePath, patchRequest.ConvertToJson()); }
/// <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="creditCardId">ID fo the credit card to update.</param> /// <param name="patchRequest">PatchRequest</param> /// <returns>CreditCard</returns> public static CreditCard Update(APIContext apiContext, string creditCardId, PatchRequest patchRequest) { // Validate the arguments to be used in the request ArgumentValidator.ValidateAndSetupAPIContext(apiContext); ArgumentValidator.Validate(creditCardId, "creditCardId"); ArgumentValidator.Validate(patchRequest, "patchRequest"); // Configure and send the request var pattern = "v1/vault/credit-cards/{0}"; var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { creditCardId }); return(PayPalResource.ConfigureAndExecute <CreditCard>(apiContext, HttpMethod.PATCH, resourcePath, patchRequest.ConvertToJson())); }
/// <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()); }
/// <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="webhookId">ID of the webhook to be updated.</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())); }