1616# You should have received a copy of the GNU Lesser General Public License
1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
19- from datetime import datetime
20- from typing import Union , List , Optional
19+ from typing import List , Optional , Union
2120
2221import pyrogram
23- from pyrogram import utils , raw , types
22+ from pyrogram import raw , types
2423
2524
2625class CreateInvoiceLink :
@@ -32,7 +31,7 @@ async def create_invoice_link(
3231 currency : str ,
3332 prices : List ["types.LabeledPrice" ],
3433 provider_token : Optional [str ] = None ,
35- subscription_period : datetime = None ,
34+ subscription_period : Optional [ int ] = None ,
3635 max_tip_amount : Optional [int ] = None ,
3736 suggested_tip_amounts : Optional [List [int ]] = None ,
3837 start_parameter : Optional [str ] = None ,
@@ -47,7 +46,7 @@ async def create_invoice_link(
4746 need_shipping_address : Optional [bool ] = None ,
4847 send_phone_number_to_provider : Optional [bool ] = None ,
4948 send_email_to_provider : Optional [bool ] = None ,
50- is_flexible : Optional [bool ] = None
49+ is_flexible : Optional [bool ] = None ,
5150 ) -> str :
5251 """Create invoice link.
5352
@@ -75,7 +74,7 @@ async def create_invoice_link(
7574 provider_token (``str``, *optional*):
7675 Payment provider token, obtained via `@BotFather <https://t.me/botfather>`_. Pass an empty string for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
7776
78- subscription_period (:py:obj:`~datetime.datetime `, *optional*):
77+ subscription_period (``int` `, *optional*):
7978 The number of seconds the subscription will be active for before the next payment.
8079 The currency must be set to “XTR” (Telegram Stars) if the parameter is used.
8180 Currently, it must always be 2592000 (30 days) if specified.
@@ -129,46 +128,39 @@ async def create_invoice_link(
129128 ``str``: On success, the invoice url is returned.
130129
131130 """
132- media = raw .types .InputMediaInvoice (
133- title = title ,
134- description = description ,
135- photo = raw .types .InputWebDocument (
136- url = photo_url ,
137- mime_type = "image/jpg" ,
138- size = photo_size ,
139- attributes = [
140- raw .types .DocumentAttributeImageSize (
141- w = photo_width ,
142- h = photo_height
143- )
144- ]
145- ) if photo_url else None ,
146- invoice = raw .types .Invoice (
147- currency = currency ,
148- prices = [i .write () for i in prices ],
149- test = self .test_mode ,
150- name_requested = need_name ,
151- phone_requested = need_phone_number ,
152- email_requested = need_email ,
153- shipping_address_requested = need_shipping_address ,
154- flexible = is_flexible ,
155- phone_to_provider = send_phone_number_to_provider ,
156- email_to_provider = send_email_to_provider ,
157- max_tip_amount = max_tip_amount ,
158- suggested_tip_amounts = suggested_tip_amounts ,
159- subscription_period = utils .datetime_to_timestamp (subscription_period )
160- ),
161- payload = payload .encode () if isinstance (payload , str ) else payload ,
162- provider = provider_token ,
163- provider_data = raw .types .DataJSON (
164- data = provider_data if provider_data else "{}"
165- ),
166- start_param = start_parameter
167- )
168-
169131 r = await self .invoke (
170132 raw .functions .payments .ExportInvoice (
171- invoice_media = media
133+ invoice_media = raw .types .InputMediaInvoice (
134+ title = title ,
135+ description = description ,
136+ photo = raw .types .InputWebDocument (
137+ url = photo_url ,
138+ mime_type = "image/jpg" ,
139+ size = photo_size ,
140+ attributes = [
141+ raw .types .DocumentAttributeImageSize (w = photo_width , h = photo_height )
142+ ],
143+ ) if photo_url else None ,
144+ invoice = raw .types .Invoice (
145+ currency = currency ,
146+ prices = [i .write () for i in prices ],
147+ test = self .test_mode ,
148+ name_requested = need_name ,
149+ phone_requested = need_phone_number ,
150+ email_requested = need_email ,
151+ shipping_address_requested = need_shipping_address ,
152+ flexible = is_flexible ,
153+ phone_to_provider = send_phone_number_to_provider ,
154+ email_to_provider = send_email_to_provider ,
155+ max_tip_amount = max_tip_amount ,
156+ suggested_tip_amounts = suggested_tip_amounts ,
157+ subscription_period = subscription_period ,
158+ ),
159+ payload = payload .encode () if isinstance (payload , str ) else payload ,
160+ provider = provider_token ,
161+ provider_data = raw .types .DataJSON (data = provider_data or "{}" ),
162+ start_param = start_parameter ,
163+ )
172164 )
173165 )
174166
0 commit comments