bizz84/SwiftyStoreKit

User payment is successful, StoreKit return fails "paymentCancelled".

开放

#537 创建于 2020年4月2日

 (10 条评论) (4 个反应) (0 位负责人)Swift (792 个派生)batch import
area: purchase flowsdifficulty: advancedhelp wantedstatus: needs analysistype: bug

仓库指标

星标
 (6,419 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Platform

  • iOS
  • macOS
  • tvOS

In-app purchase type

  • Consumable
  • Non-consumable
  • Auto-Renewable Subscription
  • Non-Renewing Subscription

Environment

  • Sandbox
  • Production

Version

0.15.0

Report

Issue summary

When the user tried to re-new subscription In the production environment sometimes it works properly but in some cases, user payment is successful but dramatically StoreKit return error "paymentCancelled" it the SKError class which means user canceled the request but user claims he did not cancel. Also customer proves that they paid.

It failed in production but working in the sandbox.

Here's the method I used for purchase single product :

SwiftyStoreKit.purchaseProduct("com.musevisions.SwiftyStoreKit.Purchase1", quantity: 1, atomically: false) { 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)")
    case .error(let error):
        switch error.code {
        case .unknown: print("Unknown error. Please contact support")
        case .clientInvalid: print("Not allowed to make the payment")
        case .paymentCancelled: break
        case .paymentInvalid: print("The purchase identifier was invalid")
        case .paymentNotAllowed: print("The device is not allowed to make the payment")
        case .storeProductNotAvailable: print("The product is not available in the current storefront")
        case .cloudServicePermissionDenied: print("Access to cloud service information is not allowed")
        case .cloudServiceNetworkConnectionFailed: print("Could not connect to the network")
        case .cloudServiceRevoked: print("User has revoked permission to use this cloud service")
        default: print((error as NSError).localizedDescription)
        }
    }
}

Please advise what I'm doing wrong.

Your thoughts and suggestions highly appreciated.

Thanks in advance.

贡献者指南