This commit is contained in:
Mikhail Filimonov 2024-11-14 13:19:53 +04:00
parent 572f45bcaa
commit 0a9f514e03

View File

@ -172,6 +172,7 @@ extension BotPaymentMethod {
public enum BotPaymentFormRequestError {
case generic
case alreadyActive
}
extension BotPaymentInvoice {
@ -385,8 +386,12 @@ func _internal_fetchBotPaymentInvoice(postbox: Postbox, network: Network, source
let flags: Int32 = 0
return network.request(Api.functions.payments.getPaymentForm(flags: flags, invoice: invoice, themeParams: nil))
|> `catch` { _ -> Signal<Api.payments.PaymentForm, BotPaymentFormRequestError> in
return .fail(.generic)
|> `catch` { error -> Signal<Api.payments.PaymentForm, BotPaymentFormRequestError> in
if error.errorDescription == "SUBSCRIPTION_ALREADY_ACTIVE" {
return .fail(.alreadyActive)
} else {
return .fail(.generic)
}
}
|> mapToSignal { result -> Signal<TelegramMediaInvoice, BotPaymentFormRequestError> in
return postbox.transaction { transaction -> TelegramMediaInvoice in