0

我正在开发一个插件来在 WooCommerce 中集成支付网关。我以前做过一个。

但在这一个中,我需要在网关设置中上传一个密钥文件,用于在向相关门户网站发出支付请求之前对数据进行哈希处理。

我有以下允许选择文件的代码,但我怀疑这在后端是否有效。

    'sandbox_pvt_key' => array(
        'title'       => __( 'Test Private Key', 'woocommerce-custom-gateway' ),
        'type'        => 'file',
        'desc_tip'    => true,
        'description' => __( 'Please upload the test private key file; this is needed in order to test payment.', 'woocommerce-custom-gateway' ),
        'default'     => '',
    ),

输出如下所示: 在此处输入图像描述

任何人都可以知道网关设置中是否支持此选项吗?如果没有,任何人都可以指导我如何通过一些钩子/过滤器或任何其他方式自定义它。

4

1 回答 1

0

这可以在process_admin_options()中实现

public function process_admin_options() {
   $this->upload_key_files();

   $saved = parent::process_admin_options();

   return $saved;
}

private function upload_key_files() {
    //handle uploads here
}
于 2020-09-16T04:51:37.300 回答