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