Skip to content

Commit 9ea10c4

Browse files
committed
feat(paypal): custom_id support
1 parent 054e132 commit 9ea10c4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

paypal_subscription/paypal.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,15 @@ def create_plan(self, product_id: str, name: str, description: str, price: str,
168168
url = f"{self.base_url}/v1/billing/plans"
169169
return self._make_request(url=url, method="POST", json=data, headers=self.headers)
170170

171-
def update_subscription_price(self, subscription_id: str, new_price: str, currency: str = "EUR") -> Dict[str, Any]:
171+
def update_subscription_price(self, subscription_id: str, new_price: str, currency: str = "EUR", custom_id: str = '') -> Dict[str, Any]:
172172
"""
173173
Update the subscription price.
174174
175175
Args:
176176
subscription_id (str): Subscription ID.
177177
new_price (str): New subscription price.
178178
currency (str): Currency code (default is "EUR").
179+
custom_id (str): Custom data to send to paypal that you will get back
179180
180181
Returns:
181182
Dict[str, Any]: API response with updated subscription details.
@@ -190,11 +191,12 @@ def update_subscription_price(self, subscription_id: str, new_price: str, curren
190191
"sequence": 1,
191192
"pricing_scheme": {"fixed_price": {"value": new_price, "currency_code": currency}}
192193
}
193-
]
194+
],
195+
"custom_id": custom_id
194196
}
195197
return self._make_request(url=url, method="POST", json=data, headers=self.headers)
196198

197-
def create_subscription(self, plan_id: str, subscriber_email: str, return_url: str, cancel_url: str) -> Dict[str, Any]:
199+
def create_subscription(self, plan_id: str, subscriber_email: str, return_url: str, cancel_url: str, custom_id: str = '') -> Dict[str, Any]:
198200
"""
199201
Create a new subscription.
200202
@@ -203,6 +205,7 @@ def create_subscription(self, plan_id: str, subscriber_email: str, return_url: s
203205
subscriber_email (str): Subscriber's email.
204206
return_url (str): URL to redirect to after the subscriber approves the subscription.
205207
cancel_url (str): URL to redirect to if the subscriber cancels the subscription.
208+
custom_id (str): Custom data to send to paypal that you will get back
206209
207210
Returns:
208211
Dict[str, Any]: API response with subscription details.
@@ -215,7 +218,8 @@ def create_subscription(self, plan_id: str, subscriber_email: str, return_url: s
215218
"application_context": {
216219
"return_url": return_url,
217220
"cancel_url": cancel_url
218-
}
221+
},
222+
"custom_id": custom_id
219223
}
220224

221225
url = f"{self.base_url}/v1/billing/subscriptions"

0 commit comments

Comments
 (0)