From 9ffd0c2942115963d7f1b9d5dab7a5e662ba7393 Mon Sep 17 00:00:00 2001 From: deadtik Date: Thu, 29 Jan 2026 18:08:29 +0530 Subject: [PATCH 1/2] fix: alias subscription.edit to subscription.update to match docs --- razorpay/resources/subscription.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/razorpay/resources/subscription.py b/razorpay/resources/subscription.py index d313b963..c7d8e9f4 100644 --- a/razorpay/resources/subscription.py +++ b/razorpay/resources/subscription.py @@ -85,7 +85,7 @@ def edit(self, subscription_id, data={}, **kwargs): Update particular subscription Args: - subscription_id : Id for which subscription has to be edited + subscription_id : Id for which subscription has to be edited Returns: Subscription dict for given subscription id """ @@ -143,4 +143,7 @@ def delete_offer(self, subscription_id, offer_id, data={}, **kwargs): Subscription Dict for given subscription id """ url = "{}/{}/{}".format(self.base_url, subscription_id, offer_id) - return self.delete_url(url, data, **kwargs) + return self.delete_url(url, data, **kwargs) + + # Alias update to edit to match documentation (Fixes Issue #282) + update = edit \ No newline at end of file From 3d00a3974e27455ba3fab95cbd697e83e0f72fe2 Mon Sep 17 00:00:00 2001 From: deadtik Date: Thu, 29 Jan 2026 18:54:32 +0530 Subject: [PATCH 2/2] fix: auto-cast string booleans to integers in payment_link.create (Fixes #321) --- razorpay/resources/payment_link.py | 101 ++++++++++++++++++----------- 1 file changed, 64 insertions(+), 37 deletions(-) diff --git a/razorpay/resources/payment_link.py b/razorpay/resources/payment_link.py index 843786d6..fbe1d484 100644 --- a/razorpay/resources/payment_link.py +++ b/razorpay/resources/payment_link.py @@ -1,6 +1,8 @@ +import warnings +from typing import Dict, Any, Union, Optional + from .base import Resource from ..constants.url import URL -import warnings class PaymentLink(Resource): @@ -8,82 +10,107 @@ def __init__(self, client=None): super(PaymentLink, self).__init__(client) self.base_url = URL.V1 + URL.PAYMENT_LINK_URL - def fetch_all(self, data={}, **kwargs): # pragma: no cover + def fetch_all(self, data: Optional[Dict[str, Any]] = None, **kwargs) -> Dict[str, Any]: # pragma: no cover + """ + Fetch all Payment Link entities (Deprecated) + """ warnings.warn("Will be Deprecated in next release", DeprecationWarning) return self.all(data, **kwargs) - def all(self, data={}, **kwargs): + def all(self, data: Optional[Dict[str, Any]] = None, **kwargs) -> Dict[str, Any]: """ - Fetch all Payment link entities + Fetch all Payment Link entities + + Args: + data: Dictionary of filters Returns: - Dictionary of Payment link data + Dictionary of Payment Link data """ return super(PaymentLink, self).all(data, **kwargs) - def fetch(self, payment_link_id, data={}, **kwargs): + def fetch(self, payment_link_id: str, data: Optional[Dict[str, Any]] = None, **kwargs) -> Dict[str, Any]: """ - Fetch Payment link for given Id + Fetch Payment Link for given ID Args: - payment_link_id : Id for which Payment link object has to be retrieved + payment_link_id : Unique identifier for the Payment Link Returns: - Payment link dict for given payment_link_id Id + Payment Link dictionary """ return super(PaymentLink, self).fetch(payment_link_id, data, **kwargs) - def create(self, data={}, **kwargs): + def create(self, data: Dict[str, Any], **kwargs) -> Dict[str, Any]: """ - Create Payment link from given dict + Create Payment Link from given dict Args: - data : Dictionary having keys using which Payment link have to be created + data : Dictionary containing Payment Link details Returns: - Payment link Dict which was created + Payment Link Dict which was created + """ + # Fix for Issue #321: Intercept and fix "string boolean" mistakes + # If user passes "true"/"false" strings, convert them to 1/0 integers + if 'options' in data: + checkout = data['options'].get('checkout', {}) + if 'method' in checkout: + for key, value in checkout['method'].items(): + if isinstance(value, str): + if value.lower() == 'true': + checkout['method'][key] = 1 + elif value.lower() == 'false': + checkout['method'][key] = 0 + url = self.base_url return self.post_url(url, data, **kwargs) - def cancel(self, payment_link_id, **kwargs): + def cancel(self, payment_link_id: str, **kwargs) -> Dict[str, Any]: """ - Cancel an unpaid Payment link with given ID via API - It can only be called on an Payment link that is not in the paid state. + Cancel an unpaid Payment Link with given ID via API. + It can only be called on a Payment Link that is not in the paid state. Args: - payment_link_id : Id for cancel the Payment link + payment_link_id : Unique identifier for the Payment Link + Returns: - The response for the API will be the Payment link entity, similar to create/update API response, with status attribute's value as cancelled + Payment Link entity with status attribute as 'cancelled' """ - url = "{}/{}/cancel".format(self.base_url, payment_link_id) + url = f"{self.base_url}/{payment_link_id}/cancel" return self.post_url(url, {}, **kwargs) - - def edit(self, payment_link_id, data={}, **kwargs): + + def edit(self, payment_link_id: str, data: Optional[Dict[str, Any]] = None, **kwargs) -> Dict[str, Any]: """ - Edit the Payment link - Args: - data : Dictionary having keys using which order have to be edited - reference_id : Adds a unique reference number to an existing link. + Edit the Payment Link - expire_by : Timestamp, in Unix format, when the payment links should expire. + Args: + payment_link_id: Unique identifier for the Payment Link + data : Dictionary having keys to update: + - reference_id : Adds a unique reference number + - expire_by : Timestamp (Unix) when the link should expire + - notes : Key-value pair as notes - notes : key value pair as notes - - Returns: + Returns: Payment Link Dict which was edited """ - url = '{}/{}'.format(self.base_url, payment_link_id) + url = f"{self.base_url}/{payment_link_id}" return self.patch_url(url, data, **kwargs) - def notifyBy(self, payment_link_id, medium, **kwargs): + def notifyBy(self, payment_link_id: str, medium: str, **kwargs) -> Dict[str, Any]: """ - Send notification + Send notification for the Payment Link Args: - payment_link_id : Unique identifier of the Payment Link that should be resent. - - medium : sms/email + payment_link_id : Unique identifier of the Payment Link + medium : The medium to send notification (sms/email) + + Returns: + API response dictionary """ - url = "{}/{}/notify_by/{}".format(self.base_url, payment_link_id, medium) - return self.post_url(url, {}, **kwargs) + url = f"{self.base_url}/{payment_link_id}/notify_by/{medium}" + return self.post_url(url, {}, **kwargs) + + # Alias to fix camelCase naming violation (PEP 8) + notify_by = notifyBy \ No newline at end of file