How to use pkpaymentsummaryitemtype.pending in ApplePay/Swift?

Viewed 72

In my app I need to add pending pay (after user have got some service). I'm implement apple pay and received token. But I don't get how to make payment with item type pkpaymentsummaryitemtype.pending?

Here is my pay method:

func makePay()
    {
        
        let request = PKPaymentRequest()
        
        request.merchantIdentifier = ApplePaySwagMerchantID
        request.supportedNetworks = SupportedPaymentNetworks
        request.merchantCapabilities = PKMerchantCapability.capability3DS
        
        
        request.countryCode = "US"
        request.currencyCode = "USD"
        
        
        request.paymentSummaryItems = [
            PKPaymentSummaryItem(label: "Some service", amount: 0, type: PKPaymentSummaryItemType.pending)]
        
        let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request)!
        applePayController.delegate = self
        
        var topVC = UIApplication.shared.keyWindow?.rootViewController
        while((topVC!.presentedViewController) != nil) {
             topVC = topVC!.presentedViewController
        }
        topVC?.present(applePayController, animated: true)
       
    }

But when I have to show and debit final amount? I cant find examples of code on swift/IOS.

Or if I understood correct - with that type I just received authorization first and than with received token my bank/payment system will debit final amount after I send it?

Is it correct?

0 Answers
Related