手動キャプチャーを有効にする
対象となる Stripe の決済手段に対し、個別にオーソリとキャプチャーすることを許可します。
Stripe は、一部の決済手段タイプの手動キャプチャーに対応しています。対象となる決済手段の Payment Action
プロパティをオーソリのみに設定することで、この動作を設定できます。
通常、新たに開始された決済手段の手動キャプチャーを有効にするには、Stripe モジュールをアップグレードする必要があります。このガイドでは、決済手段のヘルパーファイルを直接更新し、Stripe モジュールをアップグレードすることなく対象となる決済手段の手動キャプチャーを有効にする方法を説明します。
新しいモジュールを作成する
次のディレクトリー構造で新しいモジュールを作成します。Vendor
を任意のベンダー名に置き換えます。
app/code/Vendor/StripeCustomizations/ ├── etc/ │ ├── module.xml │ └── di.xml ├── Plugin/ │ └── Helper/ │ └── PaymentMethodPlugin.php ├── registration.php
registration.
内で、モジュールを Magento に登録します。
<?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Vendor_StripeCustomizations', __DIR__ );
etc/module.
内でモジュールを定義し、依存関係を設定して Stripe モジュールの後に読み込まれるようにします。
<?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 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\PaymentMethod"> <plugin name="vendor_stripecustomizations_helper_paymentmethod_plugin" type="Vendor\StripeCustomizations\Plugin\Helper\PaymentMethodPlugin" sortOrder="10" disabled="false" /> </type> </config>
Plugin/Helper/PaymentMethodPlugin.
内で、afterMethod
インターセプターを作成します。
<?php namespace Vendor\Module\Plugin; class PaymentMethodPlugin { public function afterGetPaymentMethodsThatCanCaptureManually( \StripeIntegration\Payments\Helper\PaymentMethod $subject, $result ) { // Modify or extend the result to include another payment method code that supports manual capture. $result[] = 'new_payment_method_code'; return $result; } }
以下のモジュールを有効化します。
php bin/magento module:enable Vendor_StripeCustomizations php bin/magento setup:upgrade php bin/magento cache:clean php bin/magento cache:flush