LoginSignup
4
3

More than 5 years have passed since last update.

Apple Pay 実装のハマり所

Last updated at Posted at 2018-04-21

はじめに

最近、自社のアプリ(ねこすた)でApplePayを実装したので、そこではまった内容まとめ。

実装

今回、PayJPを利用したので、ドキュメント通りに作業。
特に難しいところは無くすぐに実装は完了しました。

Debugでは動くのにReleaseだと動かない?

これ結構はまりました。通常のDebugモードだとうまくうごくのですが、Releaseモードだとボタンを押しても全然反応しない。
deploygateで配信してると駄目なのか?と、TestFlightで配信してもだめ。AppStoreから配信されているものじゃないとだめ?
いろいろ悩んだあげく、Nekostabe.entitlementstというファイルを発見。※Nekostabeの箇所は各々の名前で置き換えてください
これはAPNsの設定をしたときに出来るファイルだが、Merchant IDsを設定したときにも内容が追記されている。
通常、Merchant IDはTARGETS > CapabilitiesのMerchant IDsで設定するが、ここで設定しただけだと、Debugに設定されているhoge.entitlementstしか更新されない!
Releaseで設定されている、entitlementstファイルも同様にMerchant IDsの内容を書き込んであげなければならない。
設定は以下から確認できる。
TARGETS > Build Settings > Code Signing Entitlements

以下みたいな感じになるはず

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>aps-environment</key>
	<string>production</string>
	<key>com.apple.developer.in-app-payments</key>
	<array>
		<string>merchant.jp.co.funseek.necosta</string>
	</array>
</dict>
</plist>

これでReleaseモードでも動くようになる

Apple Payでクレカの設定がされていない場合

今回のアプリではカレンダーの購入という流れだったので、Apple Payで購入ボタンを表示。
購入ボタンを押せばApple Payのペイメントシートが表示されて購入できる。
Apple Payでクレカの設定がされていない場合は、設定する画面に移動する。(ここはApple Pay側がよしなにやってくれる)
これで問題なしと思いきや、リジェクトされて以下のメッセージ

We noticed that the Apple Pay button in your app does not directly initiate the Apple Pay payment sheet. Specifically, when the user taps the Apple Pay button, a modal alert regarding Apple Pay is displayed and closed automatically.

Next Steps

To resolve this issue, please revise your app to ensure that the Apple Pay button directly initiates the Apple Pay payment sheet.

Resources

Please review the Apple Pay Human Interface Guidelines to help ensure your app is in compliance with these terms and conditions.

Human Interface Guidelines
https://developer.apple.com/ios/human-interface-guidelines/technologies/apple-pay/

Apple Payでクレカの設定がされていない場合は、セットアップボタンを表示しろってこと?わからなかったのでResolution Centerで返信して聞いてみたけど具体的な内容は教えてくれず。
Apple Payでクレカの設定がされていない場合は、セットアップボタンを表示するように修正して、再度申請。
無事通りました。確かにセットアップボタンを表示したほうがいいっぽいことは書いてあるけど、これmustなの?って感じではありましたが、通ったのでよしとする。

最後に

Apple Pay便利だけど、自動改札で毎回起動するのがうざい(suicaじゃなくてiPhoneケースにいれてあるパスモで通るとき)

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3