こんにちは。
Xcodeでの課金部分でAppleの審査が通らず困っております。ご助言いただければ幸いです。
いずれもソフトは最新バージョンです。
以下引用の通りAppleより2度リジェクトされております。
なんとなくレシートがSandbox用なのにProductサーバーに送っちゃってるからどこかで条件分岐しろみたいなことだと理解しているんですが、コードのどこでどう分岐してどう記述すれば良いのかわかりません。
そもそも自身の環境では、SandboxでもTestFlight環境でもうまく動作するため、よくわからずにいます。
ネット上では課金部分のコードサンプルが少なく、ここ数日困っています。
よろしくお願いいたします。
We found that your in-app purchase products exhibited one or more bugs when reviewed on iPad running iOS 14.0 on Wi-Fi.
We were still unable to purchase your in-app purchase products because nothing occurred after tapped action buttons.
Next Steps
When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code "Sandbox receipt used in production," you should validate against the test environment instead.
Swift
1import UIKit 2import SwiftyStoreKit 3import Firebase 4 5class BillingViewController: UIViewController { 6 7 @IBOutlet weak var pointLabel: UILabel! 8 9 var userPoint = Int() 10 let userid = Auth.auth().currentUser?.uid 11 let indicator = UIActivityIndicatorView() 12 13 @IBOutlet weak var buy500PointButton: UIButton! 14 @IBOutlet weak var buy1000PointButton: UIButton! 15 @IBOutlet weak var buy1500PointButton: UIButton! 16 @IBOutlet weak var buy2000PointButton: UIButton! 17 18 override func viewDidLoad() { 19 super.viewDidLoad() 20 21 22 // Do any additional setup after loading the view. 23 } 24 25 26 27 28 func purchase(PRODUCT_ID:String,POINT:Int){ 29 30 SwiftyStoreKit.purchaseProduct(PRODUCT_ID) { (result) in 31 32 self.indicator.stopAnimating() 33 34 // ボタンを元の状態に戻す 35 self.changeButton() 36 37 switch result{ 38 case .success(_): 39 // 購入成功 40 // 購入検証 41 self.verifyPurchase(PRODUCT_ID: PRODUCT_ID,POINT: POINT) 42 43 break 44 45 case .error(let error): 46 // 購入失敗 47 print(error) 48 49 break 50 } 51 } 52 } 53 54 55 func verifyPurchase(PRODUCT_ID:String,POINT:Int){ 56 let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "aaaaaaaaaaaaaaaaaaaaa") 57 SwiftyStoreKit.verifyReceipt(using: appleValidator) { (result) in 58 switch result{ 59 case .success(let receipt): 60 let purchaseResult = SwiftyStoreKit.verifyPurchase(productId: PRODUCT_ID, inReceipt: receipt) 61 62 switch purchaseResult { 63 // リストア成功 64 // 購入があったときの処理を記載 65 66 case .purchased: 67 self.updateUserPoint(point: POINT) 68 break 69 case .notPurchased: 70 71 break 72 } 73 74 break 75 case .error(error: let error): 76 print(error) 77 78 } 79 80 81 } 82 83 } 84 85 86 87 @IBAction func buy500PointAction(_ sender: Any) { 88 buy500PointButton.isEnabled = false 89 buy500PointButton.backgroundColor = .gray 90 buy500PointButton.alpha = 0.5 91 92 purchase(PRODUCT_ID: "500point",POINT: 500) 93 94 } 95 96 @IBAction func buy1000PointAction(_ sender: Any) { 97 buy1000PointButton.isEnabled = false 98 buy1000PointButton.backgroundColor = .gray 99 buy1000PointButton.alpha = 0.5 100 purchase(PRODUCT_ID: "1000point",POINT: 1000) 101 102 } 103 104 @IBAction func buy1500PointAction(_ sender: Any) { 105 buy1500PointButton.isEnabled = false 106 buy1500PointButton.backgroundColor = .gray 107 buy1500PointButton.alpha = 0.5 108 purchase(PRODUCT_ID: "1500point",POINT: 1500) 109 110 } 111 112 113 @IBAction func buy2000PointAction(_ sender: Any) { 114 buy2000PointButton.isEnabled = false 115 buy2000PointButton.backgroundColor = .gray 116 buy2000PointButton.alpha = 0.5 117 purchase(PRODUCT_ID: "2000point",POINT: 2000) 118 119 } 120 121 122 123 124 125 func changeButton(){ 126 buy500PointButton.isEnabled = true 127 buy500PointButton.backgroundColor = .systemPink 128 buy500PointButton.alpha = 1 129 130 buy1000PointButton.isEnabled = true 131 buy1000PointButton.backgroundColor = .systemPink 132 buy1000PointButton.alpha = 1 133 134 buy1500PointButton.isEnabled = true 135 buy1500PointButton.backgroundColor = .systemPink 136 buy1500PointButton.alpha = 1 137 138 buy2000PointButton.isEnabled = true 139 buy2000PointButton.backgroundColor = .systemPink 140 buy2000PointButton.alpha = 1 141 142 } 143 144 145 146} 147
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。