カテゴリー:
documentation
閲覧数:352 配信日:2019-04-11 10:20
docs
Payments > PREPARING FOR SCA > Checkout (new) > Using Checkout with Connect
・Using Checkout with Connect
・Connectでチェックアウトを使用する
・2019年4月11日時点で、PHPコードが掲載されていないため省略。恐らく作成中なのだと思われ。後で要チェック!
・2019/5/2。Ruby以外のコードも掲載された
Checkoutを使用してConnect DirectとDestinationの料金を作成する方法を学ぶ
・チェックアウトは、接続されたStripeアカウントを含むConnect directまたはdestinationの料金の作成をサポートする
・APIを介して自分で請求を作成するのではなく、Checkoutをサーバーシステムに組み込み 、Checkoutに請求を作成させる
直接請求
Checkoutを使用して接続アカウントに直接請求を作成するには
・サーバーシステムを使用して統合し、接続StripeアカウントのIDを指定する
・必要に応じて、支払いの一部をプラットフォームに転送するための申請料を指定できる
・結果として得られる「チェックアウト」ページは、接続先アカウントの会社名、アイコン、ロゴ、および色を使用してブランドが付けられる
Server側コード
▼Checkout (new) connect デモ1
・2019/5/3時点で、区切り文字がおかしいため修正
$checkoutSession = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'name' => "Cucumber from Roger's Farm",
'amount' => 200,
'currency' => 'usd',
'quantity' => 10,
]],
'payment_intent_data' => [
'application_fee_amount' => 200,
],
'success_url' => 'https://xxxx/thanks.php',
'cancel_url' => 'https://xxxx/cancel.php',
], [
'stripe_account' => 'acct_xxxx',
]);
Client側コード
・子アカウントは再び手動で指定する必要がある
※$checkoutSessionからは取得できないたため
▼Checkout (new) connect デモ2
<script src="https://js.stripe.com/v3"></script>
<script>
// Initialize Stripe.js with the same connected account ID used when creating
// the Checkout Session.
const stripe = Stripe('pk_test_xxxx', {
stripeAccount: 'acct_xxxx',
});
stripe.redirectToCheckout({
// Pass the ID of the Checkout Session you created on your server.
sessionId: '<?php echo $checkoutSession->id; ?>',
}).then((result) => {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
});
</script>
Destination charges
・省略
ブランディング
プラットフォームアカウントとStandard Connectアカウントは
・ダッシュボードのブランド設定を介して独自のブランドを制御する
プラットフォーム
・Accounts APIを介してExpressアカウントとCustomアカウントのブランド設定を構成できる。
account update API
・ブランド設定のために以下のパラメーターを受け入れる
・icon。「チェックアウト」ページのヘッダーには、会社名の横にiconが表示される
・logo。指定した場合、[チェックアウト]ページのヘッダーにアイコンおよび会社名の代わりにlogoが表示される
・primary_color。チェックアウトページのさまざまなUI要素のアクセントカラーとして使用される
・このメソッドはテストモードでは使用不可。試すと下記エラーが発生する
( ! ) Fatal error: Uncaught Stripe\Error\InvalidRequest: Only live keys can access this method
▼Checkout (new) branding デモ1
・2019/5/4時点で、区切り文字がおかしいため修正
・第2引数の後に,があるとエラーが発生するため削除
\Stripe\Stripe::setApiKey("sk_test_xxxx");
$account = \Stripe\Account::update(
'acct_xxxx',
[
'settings' => [
'branding' => [
'icon' => 'file_123',
'logo' => 'file_456',
'primary_color' => '#663399',
],
],
]
);