iOS IAP收据包含旧的耗材购买

时间:2017-04-28 10:08:16

标签: ios swift in-app-purchase

在我的应用程序中,我有3个消费品购买,当我购买时,我收到IAP收据,其中包含4个购买:一个我刚刚购买,另外3个旧购买。这3个旧的购买总是 相同。看起来似乎没有调用finishTransaction方法。我正在以沙盒模式购物。如果我切换到另一个测试用户一切正常。我只收到一次购物收据。为什么我一直收到旧的购买,如何从收据中删除它们?

这是我收到的收据:

{
  "status" : 200,
  "exectime" : 2032,
  "response" : {
    "status" : 0,
    "receipt" : {
      "receipt_type" : "ProductionSandbox",
      "app_item_id" : 0,
      "receipt_creation_date" : "2017-04-28 04:34:20 Etc\/GMT",
      "bundle_id" : "xxxx",
      "original_purchase_date" : "2013-08-01 07:00:00 Etc\/GMT",
      "in_app" : [
        {
          "product_id" : "xxxx.50Minutes",
          "quantity" : "1",
          "transaction_id" : "xxxx",
          "purchase_date_ms" : "1493289005000",
          "original_purchase_date_pst" : "2017-04-27 03:30:05 America\/Los_Angeles",
          "purchase_date_pst" : "2017-04-27 03:30:05 America\/Los_Angeles",
          "original_purchase_date_ms" : "1493289005000",
          "is_trial_period" : "false",
          "original_purchase_date" : "2017-04-27 10:30:05 Etc\/GMT",
          "original_transaction_id" : "xxxx",
          "purchase_date" : "2017-04-27 10:30:05 Etc\/GMT"
        },
        {
          "product_id" : "xxxx.15Minutes",
          "quantity" : "1",
          "transaction_id" : "xxxx",
          "purchase_date_ms" : "1493289017000",
          "original_purchase_date_pst" : "2017-04-27 03:30:17 America\/Los_Angeles",
          "purchase_date_pst" : "2017-04-27 03:30:17 America\/Los_Angeles",
          "original_purchase_date_ms" : "1493289017000",
          "is_trial_period" : "false",
          "original_purchase_date" : "2017-04-27 10:30:17 Etc\/GMT",
          "original_transaction_id" : "xxxx",
          "purchase_date" : "2017-04-27 10:30:17 Etc\/GMT"
        },
        {
          "product_id" : "xxxx.15Minutes",
          "quantity" : "1",
          "transaction_id" : "xxxx",
          "purchase_date_ms" : "1493354060000",
          "original_purchase_date_pst" : "2017-04-27 21:34:20 America\/Los_Angeles",
          "purchase_date_pst" : "2017-04-27 21:34:20 America\/Los_Angeles",
          "original_purchase_date_ms" : "1493354060000",
          "is_trial_period" : "false",
          "original_purchase_date" : "2017-04-28 04:34:20 Etc\/GMT",
          "original_transaction_id" : "xxxx",
          "purchase_date" : "2017-04-28 04:34:20 Etc\/GMT"
        },
        {
          "product_id" : "xxxx.100Minutes",
          "quantity" : "1",
          "transaction_id" : "xxxx",
          "purchase_date_ms" : "1493289033000",
          "original_purchase_date_pst" : "2017-04-27 03:30:33 America\/Los_Angeles",
          "purchase_date_pst" : "2017-04-27 03:30:33 America\/Los_Angeles",
          "original_purchase_date_ms" : "1493289033000",
          "is_trial_period" : "false",
          "original_purchase_date" : "2017-04-27 10:30:33 Etc\/GMT",
          "original_transaction_id" : "xxxx",
          "purchase_date" : "2017-04-27 10:30:33 Etc\/GMT"
        }
      ],
      "adam_id" : 0,
      "receipt_creation_date_pst" : "2017-04-27 21:34:20 America\/Los_Angeles",
      "request_date" : "2017-04-28 04:34:34 Etc\/GMT",
      "request_date_pst" : "2017-04-27 21:34:34 America\/Los_Angeles",
      "version_external_identifier" : 0,
      "request_date_ms" : "1493354074233",
      "original_purchase_date_pst" : "2013-08-01 00:00:00 America\/Los_Angeles",
      "application_version" : "1",
      "original_purchase_date_ms" : "1375340400000",
      "receipt_creation_date_ms" : "1493354060000",
      "original_application_version" : "1.0",
      "download_id" : 0
    },
    "environment" : "Sandbox"
  },
  "memory" : 649368
}

1 个答案:

答案 0 :(得分:0)

这些是待处理的交易。解决方案是创建新的沙箱用户。然后添加queue.finishTransaction(transaction)所有交易状态

public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
        for transaction in transactions {
            switch (transaction.transactionState) {
            case .purchased:
                 queue.finishTransaction(transaction)
                break
            case .failed:
                queue.finishTransaction(transaction)
                break
            case .restored:
                queue.finishTransaction(transaction)
                break
            case .deferred:
                break
            case .purchasing:
                break
            }
        }
    }