クラス
SettlementSettings
Admin settlement config page for Amazon Pay
ソース ソース
ファイル: src/Admin/SettlementSettings.php
class SettlementSettings extends Factory { /** * Register hook for old Amazon versions * * @return void */ public function init() { parent::init(); add_filter('usces_filter_acting_payment_slug', [$this, 'filterActingPaymentSlug'], 10, 2); } /** * Filters the name displayed when trying to unregister the Amazon Pay module. * * Expected: * ※Amazon Payを未選択にすることはできません。支払方法を「削除」もしくは「停止」してください。 * * Actual: * ※を未選択にすることはできません。支払方法を「削除」もしくは「停止」してください。 * * This is a filter to circumvent this bug, which will be released upstream in usc-e-shop.1.9.15 * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param string $assumed_acting * @param array $acting_parts * @return string */ public function filterActingPaymentSlug($assumed_acting, $acting_parts) { if ($assumed_acting === 'amazon') { return $this->module->getActing(); } return $assumed_acting; } /** * Override method * * Filters the documentation url * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param string $url * @return string */ protected function filterDocumentationUrl($url) { $url = 'https://aivec.co.jp/plugin/welcart-amazon-pay'; return $url; } /** * Displays description of Amazon Pay * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array $acting_opts * @return void */ protected function moduleDescription($acting_opts) { ?> <p> <?php _e('Amazon Pay lets Amazon account holders use their registered information to make purchases', 'wcexaap'); ?> </p> <p> <?php _e('Notice: DLSeller automatic payments are not supported yet.', 'wcexaap'); ?> </p> <p> <?php _e('When testing, make sure that the environment option is correct', 'wcexaap'); ?> </p> <?php } /** * Amazon Pay config options * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array $acting_opts * @return void */ protected function settlementModuleFields($acting_opts) { ?> <tr> <th> <a class="explanation-label" id="label_ex_merchant_id_amazon"> <?php echo esc_html__('Merchant ID', 'wcexaap'); ?> </a> </th> <td> <input name="merchant_id" type="text" id="merchant_id_amazon" value="<?php echo esc_attr($acting_opts['merchant_id']); ?>" size="20" /> </td> </tr> <tr id="ex_merchant_id_amazon" class="explanation"> <td colspan="2"> <?php echo esc_html__('Can be found on your Amazon Seller Central account.', 'wcexaap'); ?> </td> </tr> <tr> <th> <a class="explanation-label" id="label_ex_access_key_amazon"> <?php echo esc_html__('Access Key', 'wcexaap'); ?> </a> </th> <td> <input name="access_key" type="text" id="access_key_amazon" value="<?php echo esc_attr($acting_opts['access_key']); ?>" size="20" /> </td> </tr> <tr id="ex_access_key_amazon" class="explanation"> <td colspan="2"> <?php echo esc_html__('Can be found on your Amazon Seller Central account.', 'wcexaap'); ?> </td> </tr> <tr> <th> <a class="explanation-label" id="label_ex_secret_key_amazon"> <?php echo esc_html__('Secret Key', 'wcexaap'); ?> </a> </th> <td> <input name="secret_key" type="text" id="secret_key_amazon" value="<?php echo esc_attr($acting_opts['secret_key']); ?>" size="20" /> </td> </tr> <tr id="ex_secret_key_amazon" class="explanation"> <td colspan="2"> <?php echo esc_html__('Can be found on your Amazon Seller Central account.', 'wcexaap'); ?> </td> </tr> <tr> <th> <a class="explanation-label" id="label_ex_client_id_amazon"> <?php echo esc_html__('Client ID', 'wcexaap'); ?> </a> </th> <td> <input name="client_id" type="text" id="client_id_amazon" value="<?php echo esc_attr($acting_opts['client_id']); ?>" size="20" /> </td> </tr> <tr id="ex_client_id_amazon" class="explanation"> <td colspan="2"> <?php echo esc_html__('Can be found on your Amazon Seller Central account.', 'wcexaap'); ?> </td> </tr> <tr> <th> <a class="explanation-label" id="label_ex_public_key_id_amazon"> <?php echo esc_html__('Public Key ID', 'wcexaap'); ?> </a> </th> <td> <input name="public_key_id" type="text" id="public_key_id_amazon" value="<?php echo esc_attr($acting_opts['public_key_id']); ?>" size="20" /> </td> </tr> <tr id="ex_public_key_id_amazon" class="explanation"> <td colspan="2"> <?php echo sprintf( // translators: integration central URL __('This can be generated on the <a href="%s">Amazon Pay Integration Central page</a> of Seller Central.', 'wcexaap'), $acting_opts['integrationCentralUrl'] ); ?> </td> </tr> <tr> <th> <a class="explanation-label" id="label_ex_private_key_amazon"> <?php echo esc_html__('Private Key', 'wcexaap'); ?> </a> </th> <td> <textarea name="private_key" type="text" id="private_key_amazon" size="20" style="width: 100%; min-height: 100px" ><?php echo esc_html($acting_opts['private_key']); ?></textarea> </td> </tr> <tr id="ex_private_key_amazon" class="explanation"> <td colspan="2"> <?php echo sprintf( // translators: integration central URL __('A string representation of the private key you generated on the <a href="%s">Amazon Pay Integration Central page</a> of Seller Central.', 'wcexaap'), $acting_opts['integrationCentralUrl'] ); ?> </td> </tr> <tr class="radio"> <th> <a class="explanation-label" id="label_ex_address_priority"> <?php echo esc_html__('Address Priority', 'wcexaap'); ?> </a> </th> <td> <div> <label> <input name="address_priority" type="radio" id="address_priority_1" value="amazon" <?php echo $acting_opts['address_priority'] === 'amazon' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Use the buyers Amazon address', 'wcexaap'); ?></span> </label> <label> <input name="address_priority" type="radio" id="address_priority_2" value="welcart" <?php echo $acting_opts['address_priority'] === 'welcart' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Use the buyers entered address', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr id="ex_address_priority" class="explanation"> <td colspan="2"> <?php _e('Prioritizing the buyers Amazon address will prompt the buyer to pick a payment method and address from their Amazon account', 'wcexaap'); ?> </td> </tr> <tr class="radio"> <th> <a class="explanation-label" id="label_ex_sync_with_order_status_changes"> <?php echo esc_html__('Sync Amazon Pay capture/cancel with Welcart order status change', 'wcexaap'); ?> </a> </th> <td> <div> <label> <input name="sync_with_order_status_changes" type="radio" id="sync_with_order_status_changes_1" value="on" <?php echo $acting_opts['sync_with_order_status_changes'] === 'on' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Sync', 'wcexaap'); ?></span> </label> <label> <input name="sync_with_order_status_changes" type="radio" id="sync_with_order_status_changes_2" value="off" <?php echo $acting_opts['sync_with_order_status_changes'] === 'off' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Do not sync', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr id="ex_sync_with_order_status_changes" class="explanation"> <td colspan="2"> <?php _e('If synced, changing the order status for an Amazon Pay order will execute the corresponding Amazon Pay settlement action.', 'wcexaap'); ?> </td> </tr> <tr class="radio"> <th> <a class="explanation-label" id="label_ex_use_social_login"> <?php echo esc_html__('Show "Login with Amazon" button on member login page', 'wcexaap'); ?> </a> </th> <td> <div> <label> <input name="use_social_login" type="radio" id="use_social_login_1" value="on" <?php echo $acting_opts['use_social_login'] === 'on' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Show', 'wcexaap'); ?></span> </label> <label> <input name="use_social_login" type="radio" id="use_social_login_2" value="off" <?php echo $acting_opts['use_social_login'] === 'off' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Hide', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr id="ex_use_social_login" class="explanation"> <td colspan="2"> <?php _e('Customers who created their Welcart account by using their Amazon account details can use the "Login with Amazon" feature.', 'wcexaap'); ?> </td> </tr> <!-- <tr class="radio"> <th> <a class="explanation-label" id="label_ex_transaction_processing_type"> <?php // echo esc_html__('Transaction Processing', 'wcexaap'); ?> </a> </th> <td> <div> <label> <input name="transaction_processing_type" type="radio" id="transaction_processing_type_1" value="sync" <?php // echo $acting_opts['transaction_processing_type'] === 'sync' ? 'checked' : ''; ?> /> <span><?php // echo esc_html__('Synchronous', 'wcexaap'); ?></span> </label> <label> <input name="transaction_processing_type" type="radio" id="transaction_processing_type_2" value="async" <?php // echo $acting_opts['transaction_processing_type'] === 'async' ? 'checked' : ''; ?> /> <span><?php // echo esc_html__('Asynchronous', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr id="ex_transaction_processing_type" class="explanation"> <td colspan="2"> <?php // echo esc_html__('Synchronous processing verifies a customers checkout details (payment method) when they make a purchase.', 'wcexaap'); ?> <br><br> <?php // echo esc_html__('Asynchronous transactions can take up to 24 hours to process but it may result in lower decline rates as it gives Amazon Pay more time to investigate transactions. In this case, the customer will only be notified about whether their payment succeeded after theyve completed checkout (via email from Amazon).', 'wcexaap'); ?> </td> </tr> --> <?php } /** * Add Amazon Pay specific extra settings * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array $acting_opts * @return void */ protected function extraSettings($acting_opts) { (new Semantic())->loadIconCss(); ?> <!-- <div class="settlement_service"> <span class="service_title"> <?php // echo esc_html__('IPN', 'wcexaap'); ?> </span> </div> <table class="settle_table aivec"> <tr> <th> <div style="display: flex; flex-flow: row nowrap; align-items: center;"> <a class="explanation-label" id="label_ex_ipn_endpoint_amazon"> <?php // echo esc_html__('IPN Endpoint', 'wcexaap'); ?> </a> <?php if ($acting_opts['ipn_verified'] === true) : ?> <i class="green check circle icon" style="margin-left: 8px;"></i> <?php endif; ?> </div> </th> <td> <?php // $ipn = new IPNEndpointRegistration($this->module); // echo $ipn->getVueMountElement(); // $ipn->loadComponent(); ?> </td> </tr> <tr id="ex_ipn_endpoint_amazon" class="explanation"> <td colspan="2"> <?php // echo esc_html__('Register your URL to recieve instant payment notifications.', 'wcexaap'); ?> </td> </tr> </table> --> <div class="settlement_service"> <span class="service_title"> <?php echo esc_html__('QuickPay', 'wcexaap'); ?> </span> </div> <table class="settle_table aivec"> <tr class="radio"> <th><?php echo esc_html__('QuickPay', 'wcexaap'); ?></th> <td> <div> <label> <input name="use_quickpay" type="radio" id="use_quickpay_1" value="on" <?php echo $acting_opts['use_quickpay'] === 'on' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Enable', 'wcexaap'); ?></span> </label> <label> <input name="use_quickpay" type="radio" id="use_quickpay_2" value="off" <?php echo $acting_opts['use_quickpay'] === 'off' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Disable', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr class="radio"> <th><?php echo esc_html__('Quickpay button placement', 'wcexaap'); ?></th> <td> <div> <label> <input name="quickpay_btn_position" type="radio" id="quickpay_btn_position_1" value="below" <?php echo $acting_opts['quickpay_btn_position'] === 'below' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Below cart button', 'wcexaap'); ?></span> </label> <label> <input name="quickpay_btn_position" type="radio" id="quickpay_btn_position_2" value="above" <?php echo $acting_opts['quickpay_btn_position'] === 'above' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Above cart button', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr class="radio"> <th><?php echo esc_html__('Notes text field', 'wcexaap'); ?></th> <td> <div> <label> <input name="quickpay_notes_field" type="radio" id="quickpay_notes_field_1" value="on" <?php echo $acting_opts['quickpay_notes_field'] === 'on' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Show', 'wcexaap'); ?></span> </label> <label> <input name="quickpay_notes_field" type="radio" id="quickpay_notes_field_2" value="off" <?php echo $acting_opts['quickpay_notes_field'] === 'off' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Hide', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr class="radio"> <th><?php echo esc_html__('Custom order field', 'usces'); ?></th> <td> <div> <label> <input name="quickpay_custom_order_fields" type="radio" id="quickpay_custom_order_fields_1" value="on" <?php echo $acting_opts['quickpay_custom_order_fields'] === 'on' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Show', 'wcexaap'); ?></span> </label> <label> <input name="quickpay_custom_order_fields" type="radio" id="quickpay_custom_order_fields_2" value="off" <?php echo $acting_opts['quickpay_custom_order_fields'] === 'off' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Hide', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr class="radio"> <th> <a class="explanation-label" id="label_ex_quickap_custom_delivery_fields_amazon"> <?php echo esc_html__('Custom delivery field', 'usces'); ?> </a> </th> <td> <div> <label> <input name="quickpay_custom_delivery_fields" type="radio" id="quickpay_custom_delivery_fields_1" value="on" <?php echo $acting_opts['quickpay_custom_delivery_fields'] === 'on' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Show', 'wcexaap'); ?></span> </label> <label> <input name="quickpay_custom_delivery_fields" type="radio" id="quickpay_custom_delivery_fields_2" value="off" <?php echo $acting_opts['quickpay_custom_delivery_fields'] === 'off' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Hide', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr id="ex_quickap_custom_delivery_fields_amazon" class="explanation"> <td colspan="2"> <?php echo esc_html__('If selected, this will only show for non-DLSeller items.', 'wcexaap'); ?> </td> </tr> <tr class="radio"> <th> <a class="explanation-label" id="label_ex_quickpay_default_customer_address_details"> <?php echo esc_html__('How to save address details', 'wcexaap'); ?> </a> </th> <td> <div> <label> <input name="quickpay_default_customer_address_details" type="radio" id="quickpay_default_customer_address_details_1" value="on" <?php echo $acting_opts['quickpay_default_customer_address_details'] === 'on' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Save delivery address as customer address details', 'wcexaap'); ?></span> </label> <label> <input name="quickpay_default_customer_address_details" type="radio" id="quickpay_default_customer_address_details_2" value="off" <?php echo $acting_opts['quickpay_default_customer_address_details'] === 'off' ? 'checked' : ''; ?> /> <span><?php echo esc_html__('Leave customer address details blank', 'wcexaap'); ?></span> </label> </div> </td> </tr> <tr id="ex_quickpay_default_customer_address_details" class="explanation"> <td colspan="2"> <?php echo esc_html__('An Amazon account only contains a customers email address and name, not address details.', 'wcexaap'); ?> </td> </tr> </table> <?php } /** * Filter options with POST * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array $options * @return array */ protected function filterUpdateOptionsProcessing($options) { $options['use_quickpay'] = isset($_POST['use_quickpay']) ? sanitize_text_field(wp_unslash($_POST['use_quickpay'])) : $options['use_quickpay']; $options['quickpay_btn_position'] = isset($_POST['quickpay_btn_position']) ? sanitize_text_field(wp_unslash($_POST['quickpay_btn_position'])) : $options['quickpay_btn_position']; $options['quickpay_notes_field'] = isset($_POST['quickpay_notes_field']) ? sanitize_text_field(wp_unslash($_POST['quickpay_notes_field'])) : $options['quickpay_notes_field']; $options['quickpay_custom_order_fields'] = isset($_POST['quickpay_custom_order_fields']) ? sanitize_text_field(wp_unslash($_POST['quickpay_custom_order_fields'])) : $options['quickpay_custom_order_fields']; $options['quickpay_custom_delivery_fields'] = isset($_POST['quickpay_custom_delivery_fields']) ? sanitize_text_field(wp_unslash($_POST['quickpay_custom_delivery_fields'])) : $options['quickpay_custom_delivery_fields']; $options['quickpay_default_customer_address_details'] = isset($_POST['quickpay_default_customer_address_details']) ? $_POST['quickpay_default_customer_address_details'] : $options['quickpay_default_customer_address_details']; $options['merchant_id'] = isset($_POST['merchant_id']) ? trim($_POST['merchant_id']) : ''; $options['access_key'] = isset($_POST['access_key']) ? trim($_POST['access_key']) : ''; $options['secret_key'] = isset($_POST['secret_key']) ? $_POST['secret_key'] : ''; $options['client_id'] = isset($_POST['client_id']) ? trim($_POST['client_id']) : ''; $options['public_key_id'] = isset($_POST['public_key_id']) ? trim($_POST['public_key_id']) : ''; $options['private_key'] = isset($_POST['private_key']) ? trim($_POST['private_key']) : ''; $options['sync_with_order_status_changes'] = isset($_POST['sync_with_order_status_changes']) ? $_POST['sync_with_order_status_changes'] : $options['sync_with_order_status_changes']; $options['use_social_login'] = isset($_POST['use_social_login']) ? $_POST['use_social_login'] : $options['use_social_login']; $options['transaction_processing_type'] = isset($_POST['transaction_processing_type']) ? $_POST['transaction_processing_type'] : $options['transaction_processing_type']; $options['address_priority'] = isset($_POST['address_priority']) ? $_POST['address_priority'] : $options['address_priority']; return $options; } /** * Filter error message after form validation * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param string $error_message * @return string */ protected function validateFormPost($error_message) { if (\WCUtils::is_blank($_POST['merchant_id'])) { $error_message .= '※' . __('Please enter the Merchant ID.', 'wcexaap') . '<br />'; } if (\WCUtils::is_blank($_POST['access_key'])) { $error_message .= '※' . __('Please enter the Access Key.', 'wcexaap') . '<br />'; } if (\WCUtils::is_blank($_POST['secret_key'])) { $error_message .= '※' . __('Please select the Secret Key.', 'wcexaap') . '<br />'; } if (\WCUtils::is_blank($_POST['client_id'])) { $error_message .= '※' . __('Please enter the Client ID.', 'wcexaap') . '<br />'; } if (\WCUtils::is_blank($_POST['public_key_id'])) { $error_message .= '※' . __('Please enter your Public Key ID.', 'wcexaap') . '<br />'; } if (\WCUtils::is_blank($_POST['private_key'])) { $error_message .= '※' . __('Please enter your Private Key.', 'wcexaap') . '<br />'; } return $error_message; } }
- extraSettings — Add Amazon Pay specific extra settings
- filterActingPaymentSlug — Filters the name displayed when trying to unregister the Amazon Pay module.
- filterDocumentationUrl — Override method
- filterUpdateOptionsProcessing — Filter options with POST
- init — Register hook for old Amazon versions
- moduleDescription — Displays description of Amazon Pay
- settlementModuleFields — Amazon Pay config options
- validateFormPost — Filter error message after form validation