質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

App Store

App Storeは、Apple社が運営する、iPhone、iPod touch、iPad向けアプリケーションソフトのダウンロードサービスです。携帯電話、Wi-Fiによる無線通信に対応しており、多くのアプリケーションをダウンロード、インストールすることができます。世界中の開発者によってアプリケーションが登録されており、有償のソフトもあればフリーソフトも多く登録されています。

Q&A

解決済

1回答

1042閲覧

Xcode Apple審査のリジェクト(課金のレシート検証?)修正について

kenben

総合スコア17

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

App Store

App Storeは、Apple社が運営する、iPhone、iPod touch、iPad向けアプリケーションソフトのダウンロードサービスです。携帯電話、Wi-Fiによる無線通信に対応しており、多くのアプリケーションをダウンロード、インストールすることができます。世界中の開発者によってアプリケーションが登録されており、有償のソフトもあればフリーソフトも多く登録されています。

0グッド

0クリップ

投稿2020/09/26 07:38

こんにちは。
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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

コードをたどって自分で解決できました。

投稿2020/09/30 02:23

kenben

総合スコア17

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問