Link Authentication Element
Link Authentication Element を使用して、Link を連携させます。
Link は、顧客の決済と配送先の情報を保存して自動入力します。顧客は、クレジットカード、デビットカード、アメリカの銀行口座など、さまざまな資金供給元を使用して Link で支払うことができます。link.com で詳細をご覧ください。
Link Authentication Element を使用して、1 つでメールアドレスの収集と Link の認証の両方に対応するメールアドレス入力フィールドを作成します。
オプション | 説明 |
---|---|
Theme | Use the dropdown to choose a theme or customize the theme with the Elements Appearance API. |
Desktop and mobile size | Use the dropdown to set the max pixel width of the parent element that the Address Element is mounted to. You can set it to 750px (Desktop) or 320px (Mobile). |
Customer location | Use the dropdown to choose a location for accepting complete addresses. Changing the location localizes the UI language and displays locally relevant payment methods. |
Layout | Use the dropdown to display the element using tabs (displayed horizontally) or accordion (displayed vertically) layouts. |
サンプルから開始する
実際の Link Authentication Element を確認するには、まず、以下のいずれかのサンプルをご覧ください。
はじめに
始める前に、ドメインを登録する必要があります。
Link Authentication Element を作成する
次のコードは、Link Authentication Element のインスタンスを作成して、DOM にマウントします。
メールアドレスを取得する
linkAuthenticationElement
コンポーネントの onChange
プロパティーを使用して、メールアドレスの詳細を取得できます。ユーザーがメールアドレスフィールドを更新するか、保存された顧客のメールアドレスが自動入力されると、常に onChange
ハンドラーが起動します。
linkAuthenticationElement.on('change', (event) => { const email = event.value.email; });
顧客データを事前入力する
Link Authentication Element はメールアドレスを受け付けます。顧客のメールアドレスを指定することにより、顧客が defaultValues オプションを使用して支払いページに到達するとすぐに Link の認証フローが開始されます。
// Create the Link Authentication Element with the defaultValues option const linkAuthenticationElement = elements.create("linkAuthentication", {defaultValues: {email: "foo@bar.com"}}); // Mount the Link Authentication Element to its corresponding DOM node linkAuthenticationElement.mount("#link-authentication-element");
追加の顧客データを事前入力する場合、defaultValues.billingDetails オブジェクトを Payment Element に追加します。これにより、顧客の名前、電話番号、配送先住所が事前入力されます。できるだけ多くの顧客の情報を事前入力すると、Link アカウントの作成と再利用を効率化できます。
次のコードは、すべての値が事前入力された Payment Element を示しています。
Elements を組み合わせる
Link Authentication Element は、リピートユーザーが支払い情報を事前入力することによってのみ Payment Element とやり取りします。ただし、Link Authentication Element、Address Element、Payment Element を使用した以下の例のように、他の Element と共に表示することもできます。

Link Authentication Element を他の Elements とともに使用して決済ページを構成する
デザイン
Appearance API を使用して、すべての Elements のスタイルを管理できます。テーマを選択するか、特定の詳細を更新することができます。

Appearance API を使用して、Elements の表示とスタイルを変更する
次の例では、「flat」のテーマで Element に使用されるデフォルトのテキストの色を上書きします。
const stripe = Stripe(
); const appearance = { theme: 'flat' variables: { colorPrimaryText: '#262626' } };'pk_test_TYooMQauvdEDq54NiTphI7jx'