Open10

shopify アプリの Tips

yoshixiyoshixi

Q shopify serve で ngrokのtunnel error がでる

以下のようなエラーパターン
https://github.com/inconshreveable/ngrok/issues/408

A

shopify tunnel stop で一回 ngrok のtunnel を kill する必要がある。
以下のようなMakefile で make start でうまくいく

SHOPIFYCMD=shopify
SHOPIFY_TUNNEL_STOP=$(SHOPIFYCMD) tunnel stop
SHOPIFY_SERVE=$(SHOPIFYCMD) serve

start: stop serve
stop:
	$(SHOPIFY_TUNNEL_STOP)
serve:
	$(SHOPIFY_SERVE)
yoshixiyoshixi

ShopifyでBilling Graphql APIを使う

  • 大きく、OnetimeとSubscriptionがある。

  • 今回はSubscriptionを使いたいので、SubscriptionをBillingAPIで調べる。

  • 全体像がかかれているのは以下
    https://shopify.dev/tutorials/bill-for-your-app-using-graphql-admin-api

  • Anuual Subscriptionを作成するサンプルコードが以下に示されているので、参考にすれば 30days も行けそう。

https://shopify.dev/tutorials/create-an-annual-subscription

  • testの仕方は以下にかかれている。test flagをつけばテストできるっぽい。

https://shopify.dev/concepts/app-store/getting-your-app-approved/testing-your-app-before-submitting

  • Subscription系のよく使うGraphqlAPIのサンプルは以下にたくさんのっている。

https://shopify.dev/tutorials/manage-subscriptions-with-billing-api

  • 上記含め多くの情報は、Charge for your app のセクションに主なものはまとまっている。
    https://shopify.dev/tutorials
yoshixiyoshixi

ShopifyAppをts化する手順

# appをcreate
$ shopify create node --name=y-shipping-app

# typescriptをいれる
$ npm install --save-dev typescript ts-node @types/node @types/react @types/react-dom @types/koa @types/koa-session @types/koa-router @types/js-cookie\n

# packageを最新化
$ ncu -u

参考
https://qiita.com/winuim/items/59af5630d5260e8c0451