InApp购买消耗服务器验证设置

时间:2019-10-21 16:18:58

标签: ios swift in-app-purchase swiftystorekit

我将SwiftyStoreKit用于InApp购买易损罐的消耗品。一切都可以用于测试,但是根据this answer,注释服务器端验证不是必需的,但建议这样做。答案为"consumables, un-consumables and subscriptions are susceptible to fraudulent attacks. Often though iap crackers or network spoofing. Validating the receipt can mitigate this problem"

1-如果userA向我发送了小费,那么如果一切都通过Apple,那么攻击者怎么可能截获该小费并取钱?

2-我是否需要设置Heroku实例或使用其他方式进行服务器验证?我找不到任何东西。我假设我需要在下面的success case的{​​{1}}中添加服务器端代码,但是从那时起我不知道如何设置服务器。

if product.needsFinishTransaction { SwiftyStoreKit.finishTransaction(product.transaction) }

代码如下:

AppDelegate:

SwiftyStoreKit.purchaseProduct(product, quantity: 1, atomically: true) { result in

    switch result {
        case .success(let product):
            // fetch content from your server, then:
            if product.needsFinishTransaction {
                SwiftyStoreKit.finishTransaction(product.transaction)
            }
            print("Purchase Success: \(product.productId)")
        // failed cases ...
    }
}

TipJarVC。购买是在func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { SwiftyStoreKit.completeTransactions(atomically: true) { purchases in for purchase in purchases { switch purchase.transaction.transactionState { case .purchased, .restored: if purchase.needsFinishTransaction { // Deliver content from server, then: SwiftyStoreKit.finishTransaction(purchase.transaction) } // Unlock content case .failed, .purchasing, .deferred: break // do nothing @unknown default: break } } } } 中进行的:

collectionView's didSelect item

1 个答案:

答案 0 :(得分:0)

您不必担心攻击者-因为它仅与越狱设备有关,他们唯一可以做的就是免费使用付费功能。而且没有人可以拿钱。一切都很安全。

如果您只想购买IAP,则可以使用SwiftyStoreKit

您可以从我们的博客中阅读有关收据验证的this article