###前提・実現したいこと
現在Stripe(決済サービス)のAPIをつなげて、アプリ内でクレジットカード決済を行おうと試みております。
以下のエラーが起きてしまいます。
###発生している問題・エラーメッセージ
以下のコードを記入しますと
if let paymentRequest = Stripe.paymentRequestWithMerchantIdentifier(appleMerchantId) { if Stripe.canSubmitPaymentRequest(paymentRequest) { 以下のエラーが出てしまいます。 "Initilizer for conditional binding must have Optional value"
###該当のソースコード
以下がコード全体となります。
func beginPayment() { if (stripePublishableKey == "") { let alert = UIAlertController( title: "You need to set your Stripe publishable key.", message: "You can find your publishable key at https://dashboard.stripe.com/account/apikeys .", preferredStyle: UIAlertControllerStyle.alert ) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil) alert.addAction(action) present(alert, animated: true, completion: nil) return } if (appleMerchantId != "") { ** if let paymentRequest = Stripe.paymentRequestWithMerchantIdentifier(appleMerchantId) { if Stripe.canSubmitPaymentRequest(paymentRequest) {** paymentRequest.paymentSummaryItems = [PKPaymentSummaryItem(label: "Cool shirt", amount: NSDecimalNumber(string: "10.00")), PKPaymentSummaryItem(label: "Stripe shirt shop", amount: NSDecimalNumber(string: "10.00"))] let paymentAuthVC = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest) paymentAuthVC.delegate = self presentViewController(paymentAuthVC, animated: true, completion: nil) return } } } else { print("You should set an appleMerchantId.") } }
考えられるエラーの問題をお聞きしたく、こちらに投稿しました。
###試したこと
guard let ~ elseを試みましたが失敗。。
他に方法がないかお聞きしたいです。
###補足情報(言語/FW/ツール等のバージョンなど)
現在使っているSwift3です。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/26 02:47