How do I get “transaction_id” and “receipt_data” from Superwall?

I have implemented Superwall in my Swift iOS App. I haven’t implemented StoreKit. I have shown paywall like below:

//superwall delegate
  Superwall.shared.delegate = self
            
//show paywall
Superwall.shared.register(event: SuperwallEvents.CAMPAIGN_TRIGGER.rawValue) {
print("Action to take if they are on a paid plan")
 }

Below is the delegate method:

// MARK: - Superwall Delegate
extension InputCameraScreen: SuperwallDelegate {
    func handleSuperwallEvent(withInfo eventInfo: SuperwallEventInfo) {
        switch eventInfo.event {
        case .transactionComplete(let transaction, let product, let paywallInfo):
            print("Converted from paywall originalTransactionIdentifier: (transaction?.originalTransactionIdentifier ?? "")")
            print("Converted from paywall storeTransactionId: (transaction?.storeTransactionId ?? "")")
            print("Converted from paywall productIdentifier: (product.productIdentifier)")
            print("Converted from paywall paywallInfo: (paywallInfo.identifier)")
        case .transactionRestore(let restoreType, let paywallInfo):
            print("transactionRestore restoreType (restoreType)")
        default:
            print("default (#function) - (eventInfo.event)")
        }
    }
}

I have some queries:

  1. Do I need StoreKit along with Superwall? I have downloaded Example Projects and I followed “Superwall-UIKit-Swift.xcodeproj” this example which doesn’t implement StoreKit. So, I’m a little bit confused about implementing StoreKit along with Superwall.

  2. So, users can purchase subscriptions even if they don’t have an account, But after purchasing subscriptions how do i connect this purchase with user’s account?

  3. How do I get “transaction_id” and “receipt_data” from Superwall? I have to send this data to the server.

Apologies if I have missed some points or misunderstood something. This is my first time implementing subscriptions in my app. I would genuinely appreciate any guidance someone could provide.

Thank you!

Dev rel at Superwall here, let me answer your questions one by one:

Do I need StoreKit along with Superwall? I have downloaded Example Projects and I followed “Superwall-UIKit-Swift.xcodeproj” this example which doesn’t implement StoreKit. So, I’m a little bit confused about implementing StoreKit along with Superwall.

No! We handle every aspect of the transaction, no need to dip down into StoreKit unless you need more fine-grain control over the purchasing pipeline. Under the hood, we are just using StoreKit anyways (on iOS at least).

So, users can purchase subscriptions even if they don’t have an account, But after purchasing subscriptions how do i connect this purchase with user’s account?

That’s where your own application logic comes in. We can tell you about their subscription status via Superwall.shared.subscriptionStatus and then you can forward that or otherwise attach that paid status to your user. You could even listen for changes in that status, too:

subscribedCancellable = Superwall.shared.$subscriptionStatus
  .receive(on: DispatchQueue.main)
  .sink { [weak self] status in
    switch status {
    case .unknown:
      self?.subscriptionLabel.text = "Loading subscription status."
    case .active:
      self?.subscriptionLabel.text = "You currently have an active subscription. Therefore, the paywall will never show. For the purposes of this app, delete and reinstall the app to clear subscriptions."
    case .inactive:
      self?.subscriptionLabel.text = "You do not have an active subscription so the paywall will show when clicking the button."
    }
  }

Now, if the user could purchase your subscription from somewhere else, like on your website – then you would want to use a PurchaseController to match up their subscription status manually. Docs on that here.

How do I get “transaction_id” and “receipt_data” from Superwall? I have to send this data to the server.

You’re on the right path in your code sample:

func handleSuperwallEvent(withInfo eventInfo: SuperwallEventInfo) {
    switch eventInfo.event {
    case .transactionComplete(let transaction, let product, let paywallInfo):
        // Use either sk1Transaction or sk2Transaction 
        if let sk2xaction = transaction?.sk2Transaction {
            // You have the StoreKit transaction here to query as needed
        }
    default:
        print("Default event: (eventInfo.event.description)")
    }
}

Getting receipt data is different in StoreKit 1/2, I’m not sure which you’re using. Here’s a good resource for StoreKit 1 and in StoreKit 2, that concept doesn’t apply since it’s been more or less replaced with Transaction.currentEntitlements. Check out our blog post over StoreKit 2 to see how it all works.

Hope this helps!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật