Skip to content

Commit e401c30

Browse files
committed
chore: update subscription API to include allowed payment methods in requests and responses
1 parent 99a7a6c commit e401c30

File tree

9 files changed

+357
-3
lines changed

9 files changed

+357
-3
lines changed

.openapi-generator/FILES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Monei/model/subscription_interval.py
9696
Monei/model/subscription_last_payment.py
9797
Monei/model/subscription_payment_method.py
9898
Monei/model/subscription_payment_method_card.py
99+
Monei/model/subscription_payment_methods.py
99100
Monei/model/subscription_retry_schedule.py
100101
Monei/model/subscription_retry_schedule_inner.py
101102
Monei/model/subscription_status.py
@@ -109,3 +110,4 @@ Monei/model_utils.py
109110
Monei/models/__init__.py
110111
Monei/rest.py
111112
test/__init__.py
113+
test/test_subscription_payment_methods.py

Monei/api/subscriptions_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def __init__(self, api_client=None):
431431
def activate(self, id, **kwargs):
432432
"""Activate Subscription # noqa: E501
433433
434-
Activates a subscription by attaching a payment method and initiating the billing cycle. **Activation Process**: 1. This endpoint transitions a `PENDING` subscription to `ACTIVE` status 2. An initial payment is created to validate the payment method: - For regular subscriptions: First billing cycle payment is processed immediately - For trial subscriptions: A zero-amount payment is created to verify the payment method **Payment Method Updates**: If the subscription is already active, this endpoint can be used to update the payment method. The update process creates a zero-amount payment to verify the new payment method works correctly. **Important Notes**: - Subscription billing begins immediately upon successful activation (unless in trial period) - The payment method provided will be used for all future recurring charges - Activation failures (due to invalid payment method) will keep the subscription in `PENDING` status # noqa: E501
434+
Activates a subscription by attaching a payment method and initiating the billing cycle. **Activation Process**: 1. This endpoint transitions a `PENDING` subscription to `ACTIVE` status 2. An initial payment is created to validate the payment method: - For regular subscriptions: First billing cycle payment is processed immediately - For trial subscriptions: A zero-amount payment is created to verify the payment method **Payment Method Updates**: If the subscription is already active, this endpoint can be used to update the payment method. The update process creates a zero-amount payment to verify the new payment method works correctly. **Important Notes**: - Subscription billing begins immediately upon successful activation (unless in trial period) - The payment method provided will be used for all future recurring charges - Activation failures (due to invalid payment method) will keep the subscription in `PENDING` status - You can specify `allowedPaymentMethods` to restrict which payment methods (e.g., `card`, `bizum`) are accepted for the subscription # noqa: E501
435435
This method makes a synchronous HTTP request by default. To make an
436436
asynchronous HTTP request, please pass async_req=True
437437
@@ -559,7 +559,7 @@ def cancel(self, id, **kwargs):
559559
def create(self, create_subscription_request, **kwargs):
560560
"""Create Subscription # noqa: E501
561561
562-
Creates a new subscription with the specified parameters. **Subscription Lifecycle**: 1. When first created, the subscription has a `PENDING` status 2. To initiate billing, you must call the [activate endpoint](https://docs.monei.com/apis/rest/subscriptions-activate/) with payment details 3. Once activated, the subscription will automatically bill according to the configured interval **Key Configuration Parameters**: - **Billing settings**: Amount, currency, interval (daily, weekly, monthly, yearly) - **Schedule customization**: Interval count, trial period duration - **Customer information**: Contact details, billing and shipping addresses - **Communication**: Callback URLs for webhook notifications about subscription events **Best Practices**: - Set clear, descriptive names for subscriptions to help with identification - Configure appropriate webhook notifications to monitor subscription status changes - Consider offering trial periods to increase customer conversion rates - Use metadata to store additional information relevant to your business logic # noqa: E501
562+
Creates a new subscription with the specified parameters. **Subscription Lifecycle**: 1. When first created, the subscription has a `PENDING` status 2. To initiate billing, you must call the [activate endpoint](https://docs.monei.com/apis/rest/subscriptions-activate/) with payment details 3. Once activated, the subscription will automatically bill according to the configured interval **Key Configuration Parameters**: - **Billing settings**: Amount, currency, interval (daily, weekly, monthly, yearly) - **Schedule customization**: Interval count, trial period duration - **Allowed payment methods**: An array of strings specifying which payment methods are allowed for this subscription (e.g., `card`, `bizum`) - **Customer information**: Contact details, billing and shipping addresses - **Communication**: Callback URLs for webhook notifications about subscription events **Best Practices**: - Set clear, descriptive names for subscriptions to help with identification - Configure appropriate webhook notifications to monitor subscription status changes - Consider offering trial periods to increase customer conversion rates - Use metadata to store additional information relevant to your business logic # noqa: E501
563563
This method makes a synchronous HTTP request by default. To make an
564564
asynchronous HTTP request, please pass async_req=True
565565
@@ -940,7 +940,7 @@ def send_status(self, id, **kwargs):
940940
def update(self, id, update_subscription_request, **kwargs):
941941
"""Update Subscription # noqa: E501
942942
943-
Updates the configuration of an existing subscription. **Modifiable Parameters**: - Billing information (amount, description) - Customer details (contact information, billing/shipping addresses) - Subscription settings (cancelAtPeriodEnd, pauseAtPeriodEnd, skipIntervalCount) - Metadata (for your internal tracking) **Update Effects**: - Amount changes apply to the next billing cycle - Customer information updates take effect immediately - Setting `cancelAtPeriodEnd` to true will end the subscription after the current period - Setting `pauseAtPeriodEnd` to true will pause billing after the current period - Setting `skipIntervalCount` skips billing for the specified number of intervals without changing subscription status **Note**: Some fundamental properties cannot be changed once a subscription is created, including currency and billing interval. To modify these, you would need to cancel the existing subscription and create a new one. # noqa: E501
943+
Updates the configuration of an existing subscription. **Modifiable Parameters**: - Billing information (amount, description, allowedPaymentMethods) - Customer details (contact information, billing/shipping addresses) - Subscription settings (cancelAtPeriodEnd, pauseAtPeriodEnd, skipIntervalCount) - Metadata (for your internal tracking) **Update Effects**: - Amount changes apply to the next billing cycle - Customer information updates take effect immediately - Setting `cancelAtPeriodEnd` to true will end the subscription after the current period - Setting `pauseAtPeriodEnd` to true will pause billing after the current period - Setting `skipIntervalCount` skips billing for the specified number of intervals without changing subscription status **Note**: Some fundamental properties cannot be changed once a subscription is created, including currency and billing interval. To modify these, you would need to cancel the existing subscription and create a new one. # noqa: E501
944944
This method makes a synchronous HTTP request by default. To make an
945945
asynchronous HTTP request, please pass async_req=True
946946

Monei/model/activate_subscription_request.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
from Monei.exceptions import ApiAttributeError
2929

3030

31+
def lazy_import():
32+
from Monei.model.subscription_payment_methods import SubscriptionPaymentMethods
33+
34+
globals()["SubscriptionPaymentMethods"] = SubscriptionPaymentMethods
35+
36+
3137
class ActivateSubscriptionRequest(ModelNormal):
3238
"""NOTE: This class is auto generated by OpenAPI Generator.
3339
Ref: https://openapi-generator.tech
@@ -62,6 +68,7 @@ def additional_properties_type():
6268
This must be a method because a model may have properties that are
6369
of type self, this must run after the class is loaded
6470
"""
71+
lazy_import()
6572
return (
6673
bool,
6774
date,
@@ -86,6 +93,7 @@ def openapi_types():
8693
openapi_types (dict): The key is attribute name
8794
and the value is attribute type.
8895
"""
96+
lazy_import()
8997
return {
9098
"payment_token": (
9199
bool,
@@ -110,6 +118,7 @@ def openapi_types():
110118
str,
111119
none_type,
112120
), # noqa: E501
121+
"allowed_payment_methods": (SubscriptionPaymentMethods,), # noqa: E501
113122
"sequence_id": (str,), # noqa: E501
114123
"complete_url": (str,), # noqa: E501
115124
"fail_url": (str,), # noqa: E501
@@ -127,6 +136,7 @@ def discriminator():
127136
"payment_token": "paymentToken", # noqa: E501
128137
"session_id": "sessionId", # noqa: E501
129138
"add_amount": "addAmount", # noqa: E501
139+
"allowed_payment_methods": "allowedPaymentMethods", # noqa: E501
130140
"sequence_id": "sequenceId", # noqa: E501
131141
"complete_url": "completeUrl", # noqa: E501
132142
"fail_url": "failUrl", # noqa: E501
@@ -177,6 +187,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
177187
payment_token (bool, date, datetime, dict, float, int, list, str, none_type): A payment token generated by monei.js [Components](https://docs.monei.com/monei-js/overview/) or a paymentToken [saved after a previous successful payment](https://docs.monei.com/guides/save-payment-method/). In case of the first one, you will also need to send the `sessionId` used to generate the token in the first place. . [optional] # noqa: E501
178188
session_id (str): A unique identifier within your system that adds security to the payment process. You need to pass the same session ID as the one used on the frontend to initialize MONEI Component (if you needed to). This is required if a payment token (not permanent) was already generated in the frontend. . [optional] # noqa: E501
179189
add_amount (bool, date, datetime, dict, float, int, list, str, none_type): The amount to be added to the subscription's initial payment. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge 1.00 USD). . [optional] # noqa: E501
190+
allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501
180191
sequence_id (str): A permanent identifier that refers to the initial payment of a sequence of payments. This value needs to be sent in the path for `RECURRING` payments. . [optional] # noqa: E501
181192
complete_url (str): The URL the customer will be directed to after transaction completed (successful or failed - except if `failUrl` is provided). . [optional] # noqa: E501
182193
fail_url (str): The URL the customer will be directed to after transaction has failed, instead of `completeUrl` (used in hosted payment page). This allows to provide two different URLs for successful and failed payments. . [optional] # noqa: E501
@@ -275,6 +286,7 @@ def __init__(self, *args, **kwargs): # noqa: E501
275286
payment_token (bool, date, datetime, dict, float, int, list, str, none_type): A payment token generated by monei.js [Components](https://docs.monei.com/monei-js/overview/) or a paymentToken [saved after a previous successful payment](https://docs.monei.com/guides/save-payment-method/). In case of the first one, you will also need to send the `sessionId` used to generate the token in the first place. . [optional] # noqa: E501
276287
session_id (str): A unique identifier within your system that adds security to the payment process. You need to pass the same session ID as the one used on the frontend to initialize MONEI Component (if you needed to). This is required if a payment token (not permanent) was already generated in the frontend. . [optional] # noqa: E501
277288
add_amount (bool, date, datetime, dict, float, int, list, str, none_type): The amount to be added to the subscription's initial payment. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge 1.00 USD). . [optional] # noqa: E501
289+
allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501
278290
sequence_id (str): A permanent identifier that refers to the initial payment of a sequence of payments. This value needs to be sent in the path for `RECURRING` payments. . [optional] # noqa: E501
279291
complete_url (str): The URL the customer will be directed to after transaction completed (successful or failed - except if `failUrl` is provided). . [optional] # noqa: E501
280292
fail_url (str): The URL the customer will be directed to after transaction has failed, instead of `completeUrl` (used in hosted payment page). This allows to provide two different URLs for successful and failed payments. . [optional] # noqa: E501

Monei/model/create_subscription_request.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ def lazy_import():
3333
from Monei.model.payment_customer import PaymentCustomer
3434
from Monei.model.payment_shipping_details import PaymentShippingDetails
3535
from Monei.model.subscription_interval import SubscriptionInterval
36+
from Monei.model.subscription_payment_methods import SubscriptionPaymentMethods
3637
from Monei.model.subscription_retry_schedule import SubscriptionRetrySchedule
3738

3839
globals()["PaymentBillingDetails"] = PaymentBillingDetails
3940
globals()["PaymentCustomer"] = PaymentCustomer
4041
globals()["PaymentShippingDetails"] = PaymentShippingDetails
4142
globals()["SubscriptionInterval"] = SubscriptionInterval
43+
globals()["SubscriptionPaymentMethods"] = SubscriptionPaymentMethods
4244
globals()["SubscriptionRetrySchedule"] = SubscriptionRetrySchedule
4345

4446

@@ -107,6 +109,7 @@ def openapi_types():
107109
"currency": (str,), # noqa: E501
108110
"interval": (SubscriptionInterval,), # noqa: E501
109111
"interval_count": (int,), # noqa: E501
112+
"allowed_payment_methods": (SubscriptionPaymentMethods,), # noqa: E501
110113
"description": (str,), # noqa: E501
111114
"customer": (PaymentCustomer,), # noqa: E501
112115
"billing_details": (PaymentBillingDetails,), # noqa: E501
@@ -130,6 +133,7 @@ def discriminator():
130133
"currency": "currency", # noqa: E501
131134
"interval": "interval", # noqa: E501
132135
"interval_count": "intervalCount", # noqa: E501
136+
"allowed_payment_methods": "allowedPaymentMethods", # noqa: E501
133137
"description": "description", # noqa: E501
134138
"customer": "customer", # noqa: E501
135139
"billing_details": "billingDetails", # noqa: E501
@@ -190,6 +194,7 @@ def _from_openapi_data(
190194
through its discriminator because we passed in
191195
_visited_composed_classes = (Animal,)
192196
interval_count (int): Number of intervals between subscription payments.. [optional] # noqa: E501
197+
allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501
193198
description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501
194199
customer (PaymentCustomer): [optional] # noqa: E501
195200
billing_details (PaymentBillingDetails): [optional] # noqa: E501
@@ -299,6 +304,7 @@ def __init__(self, amount, currency, interval, *args, **kwargs): # noqa: E501
299304
through its discriminator because we passed in
300305
_visited_composed_classes = (Animal,)
301306
interval_count (int): Number of intervals between subscription payments.. [optional] # noqa: E501
307+
allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501
302308
description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501
303309
customer (PaymentCustomer): [optional] # noqa: E501
304310
billing_details (PaymentBillingDetails): [optional] # noqa: E501

Monei/model/subscription.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def lazy_import():
3636
from Monei.model.subscription_interval import SubscriptionInterval
3737
from Monei.model.subscription_last_payment import SubscriptionLastPayment
3838
from Monei.model.subscription_payment_method import SubscriptionPaymentMethod
39+
from Monei.model.subscription_payment_methods import SubscriptionPaymentMethods
3940
from Monei.model.subscription_retry_schedule import SubscriptionRetrySchedule
4041
from Monei.model.subscription_status import SubscriptionStatus
4142

@@ -46,6 +47,7 @@ def lazy_import():
4647
globals()["SubscriptionInterval"] = SubscriptionInterval
4748
globals()["SubscriptionLastPayment"] = SubscriptionLastPayment
4849
globals()["SubscriptionPaymentMethod"] = SubscriptionPaymentMethod
50+
globals()["SubscriptionPaymentMethods"] = SubscriptionPaymentMethods
4951
globals()["SubscriptionRetrySchedule"] = SubscriptionRetrySchedule
5052
globals()["SubscriptionStatus"] = SubscriptionStatus
5153

@@ -119,6 +121,7 @@ def openapi_types():
119121
"interval": (SubscriptionInterval,), # noqa: E501
120122
"interval_count": (int,), # noqa: E501
121123
"currency": (str,), # noqa: E501
124+
"allowed_payment_methods": (SubscriptionPaymentMethods,), # noqa: E501
122125
"description": (str,), # noqa: E501
123126
"customer": (PaymentCustomer,), # noqa: E501
124127
"billing_details": (PaymentBillingDetails,), # noqa: E501
@@ -160,6 +163,7 @@ def discriminator():
160163
"interval": "interval", # noqa: E501
161164
"interval_count": "intervalCount", # noqa: E501
162165
"currency": "currency", # noqa: E501
166+
"allowed_payment_methods": "allowedPaymentMethods", # noqa: E501
163167
"description": "description", # noqa: E501
164168
"customer": "customer", # noqa: E501
165169
"billing_details": "billingDetails", # noqa: E501
@@ -247,6 +251,7 @@ def _from_openapi_data(
247251
through its discriminator because we passed in
248252
_visited_composed_classes = (Animal,)
249253
currency (str): Three-letter [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217), in uppercase. Must be a supported currency. . [optional] # noqa: E501
254+
allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501
250255
description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501
251256
customer (PaymentCustomer): [optional] # noqa: E501
252257
billing_details (PaymentBillingDetails): [optional] # noqa: E501
@@ -389,6 +394,7 @@ def __init__(
389394
through its discriminator because we passed in
390395
_visited_composed_classes = (Animal,)
391396
currency (str): Three-letter [ISO currency code](https://en.wikipedia.org/wiki/ISO_4217), in uppercase. Must be a supported currency. . [optional] # noqa: E501
397+
allowed_payment_methods (SubscriptionPaymentMethods): [optional] # noqa: E501
392398
description (str): An arbitrary string attached to the subscription. Often useful for displaying to users. . [optional] # noqa: E501
393399
customer (PaymentCustomer): [optional] # noqa: E501
394400
billing_details (PaymentBillingDetails): [optional] # noqa: E501

0 commit comments

Comments
 (0)