mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various fixes
This commit is contained in:
@@ -476,13 +476,10 @@ private func formSupportApplePay(_ paymentForm: BotPaymentForm) -> Bool {
|
||||
|
||||
private func availablePaymentMethods(form: BotPaymentForm, current: BotCheckoutPaymentMethod?) -> [BotCheckoutPaymentMethod] {
|
||||
var methods: [BotCheckoutPaymentMethod] = []
|
||||
var hasApplePay = false
|
||||
if formSupportApplePay(form) && hasApplePaySupport {
|
||||
methods.append(.applePay)
|
||||
}
|
||||
if let current = current {
|
||||
if !methods.contains(current) {
|
||||
methods.append(current)
|
||||
}
|
||||
hasApplePay = true
|
||||
}
|
||||
if let savedCredentials = form.savedCredentials {
|
||||
if !methods.contains(.savedCredentials(savedCredentials)) {
|
||||
@@ -492,6 +489,11 @@ private func availablePaymentMethods(form: BotPaymentForm, current: BotCheckoutP
|
||||
if !form.additionalPaymentMethods.isEmpty {
|
||||
methods.append(contentsOf: form.additionalPaymentMethods.map { .other($0) })
|
||||
}
|
||||
if let current = current {
|
||||
if !methods.contains(current) {
|
||||
methods.insert(current, at: hasApplePay ? 1 : 0)
|
||||
}
|
||||
}
|
||||
return methods
|
||||
}
|
||||
|
||||
@@ -1284,6 +1286,22 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
return
|
||||
}
|
||||
|
||||
let totalAmount = currentTotalPrice(paymentForm: paymentForm, validatedFormInfo: self.currentValidatedFormInfo, currentShippingOptionId: self.currentShippingOptionId, currentTip: self.currentTipAmount)
|
||||
let currencyValue = formatCurrencyAmount(totalAmount, currency: paymentForm.invoice.currency)
|
||||
|
||||
let proceedWithCompletion: (Bool, EngineMessage.Id?) -> Void = { [weak self] success, receiptMessageId in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
if success {
|
||||
strongSelf.dismissAnimated()
|
||||
strongSelf.completed(currencyValue, receiptMessageId)
|
||||
} else {
|
||||
strongSelf.dismissAnimated()
|
||||
}
|
||||
}
|
||||
|
||||
let credentials: BotPaymentCredentials
|
||||
if let receivedCredentials = receivedCredentials {
|
||||
credentials = receivedCredentials
|
||||
@@ -1467,9 +1485,6 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
tipAmount = 0
|
||||
}
|
||||
|
||||
let totalAmount = currentTotalPrice(paymentForm: paymentForm, validatedFormInfo: self.currentValidatedFormInfo, currentShippingOptionId: self.currentShippingOptionId, currentTip: self.currentTipAmount)
|
||||
let currencyValue = formatCurrencyAmount(totalAmount, currency: paymentForm.invoice.currency)
|
||||
|
||||
self.payDisposable.set((self.context.engine.payments.sendBotPaymentForm(source: self.source, formId: paymentForm.id, validatedInfoId: self.currentValidatedFormInfo?.id, shippingOptionId: self.currentShippingOptionId, tipAmount: tipAmount, credentials: credentials) |> deliverOnMainQueue).start(next: { [weak self] result in
|
||||
if let strongSelf = self {
|
||||
strongSelf.inProgressDimNode.isUserInteractionEnabled = false
|
||||
@@ -1484,19 +1499,6 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
strongSelf.applePayController = nil
|
||||
applePayController.presentingViewController?.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
let proceedWithCompletion: (Bool, EngineMessage.Id?) -> Void = { success, receiptMessageId in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
if success {
|
||||
strongSelf.dismissAnimated()
|
||||
strongSelf.completed(currencyValue, receiptMessageId)
|
||||
} else {
|
||||
strongSelf.dismissAnimated()
|
||||
}
|
||||
}
|
||||
|
||||
switch result {
|
||||
case let .done(receiptMessageId):
|
||||
|
||||
Reference in New Issue
Block a user