# PaymentElement フォームに表示される規約を非表示にする

カスタムモジュールを使用して、PaymentElement の下にある規約テキストを無効にします。

PaymentElement 内の一部の決済手段には、その使用に関連する規約が表示されます。このガイドに従って、カスタムモジュールを使用して PaymentElement の下にある規約テキストを無効にします。

詳細については、[API ドキュメント](https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options-terms)をご覧ください。

## 新しいモジュールを作成

次のディレクトリー構造で新しいモジュールを作成します。`Vendor` を任意のベンダー名に置き換えます。

```
app/code/Vendor/StripeCustomizations/
├── etc/
│   ├── module.xml
│   └── di.xml
├── Plugin/
│   └── Helper/
│       └── PaymentMethodOptions.php
└── registration.php
```

`registration.php` 内で、モジュールを Magento に登録します。

```php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Vendor_StripeCustomizations',
    __DIR__
);
```

`etc/module.xml` 内でモジュールを定義し、依存関係を設定して、Stripe モジュールの後に確実に読み込まれるようにします。

```xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_StripeCustomizations" setup_version="1.0.0">
        <sequence>
            <module name="StripeIntegration_Payments"/>
        </sequence>
    </module>
</config>
```

`etc/di.xml` 内で、以下のプラグインを定義します。

```xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="StripeIntegration\Payments\Helper\PaymentMethodOptions">
        <plugin
            name="vendor_stripecustomizations_helper_paymentmethodoptions_plugin"
            type="Vendor\StripeCustomizations\Plugin\Helper\PaymentMethodOptions"
            sortOrder="10"
            disabled="false" />
    </type>
</config>
```

`Plugin/Helper/PaymentMethodOptions.php` 内で、プラグインクラスを作成します。

```php
<?php
namespace Vendor\StripeCustomizations\Plugin\Helper;

class PaymentMethodOptions
{
    /**
     * After plugin for getPaymentElementTerms method.
     *
     * @param $subject
     * @param array $result
     * @return array
     */
    public function afterGetPaymentElementTerms($subject, $result)
    {
        if (isset($result['paypal']))
        {
            // Can be 'auto', 'always', or 'never'. We recommend against using 'auto' due to the usage of deferred intents in the module.
            $result['paypal'] = 'never';
        }

        return $result;
    }
}
```
