Plugin Directory

Changeset 2940706


Ignore:
Timestamp:
07/20/2023 08:51:16 AM (3 years ago)
Author:
binancepay
Message:

support fiat selection in order currency

Location:
binance-pay/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • binance-pay/trunk/class-wc-gateway-binancepay.php

    r2900971 r2940706  
    3737            $this->has_fields = false;
    3838            $this->method_title = 'Binance Pay';
    39             $this->icon = apply_filters('woocommerce_binance_pay_icon', plugins_url('/assets/binance-logo.svg',__FILE__ ));
     39            $this->icon = apply_filters('woocommerce_binance_pay_icon', plugins_url('/assets/binance-logo.svg', __FILE__));
    4040            $this->method_description = 'A payment gateway that sends your customers to Binance to pay with cryptocurrency.';
    4141
     
    4747            $this->api_key = $this->get_option('api_key');
    4848            $this->secret_key = $this->get_option('secret_key');
     49            $this->transaction_currency = $this->get_option('transaction_currency');
    4950
    5051            add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
     
    6970                    'title' => 'Secret Key',
    7071                    'type' => 'password',
     72                ),
     73                'transaction_currency' => array(
     74                    'title' => 'Currency',
     75                    'type' => 'select',
     76                    'class' => 'wc-enhanced-select',
     77                    'description' => 'This is the currency used to create order in Binance Pay.  With fiat selection, your customers will pay you with equivalent USDT, and your settlement currency will be in USDT as well.', 'woocommerce',
     78                    'default' => '',
     79                    'desc_tip' => true,
     80                    'custom_attributes' => array('required' => 'required'),
     81                    'options' => array(
     82                        'BUSD' => 'BUSD',
     83                        'USDT' => 'USDT',
     84                        'USD' => 'USD',
     85                        'EUR' => 'EUR',
     86                        'CHF' => 'CHF',
     87                        'GBP' => 'GBP',
     88                        'ARS' => 'ARS',
     89                        'CNY' => 'CNY',
     90                        'HKD' => 'HKD',
     91                        'NGN' => 'NGN',
     92                    ),
    7193                )
    7294            );
     
    131153            $req = array(
    132154                'env' => array('terminalType' => 'WEB'),
    133                 'merchantTradeNo' => $order_id,
    134                 'orderAmount' => $order->get_total(),
    135                 'currency' => 'BUSD');
     155                'merchantTradeNo' => $order_id
     156            );
     157            $currency = $this->transaction_currency;
     158            if (empty($currency)) {
     159                $currency = 'BUSD';
     160            }
     161            if ($currency == 'BUSD' || $currency == 'USDT') {
     162                $req['orderAmount'] = $order->get_total();
     163                $req['currency'] = $currency;
     164            } else {
     165                $req['fiatAmount'] = $order->get_total();
     166                $req['fiatCurrency'] = $currency;
     167            }
    136168            $req['goods'] = array();
    137169            $req['passThroughInfo'] = "wooCommerce-1.0";
     
    173205            );
    174206            $args = array(
    175                 'body'        => json_encode($req),
    176                 'timeout'     => '60',
     207                'body' => json_encode($req),
     208                'timeout' => '60',
    177209                'redirection' => '8',
    178210                'httpversion' => '1.0',
    179                 'blocking'    => true,
    180                 'headers'     => $headers,
    181                 'cookies'     => array(),
    182             );
    183             $response = wp_remote_post( $this->api_path . 'v2/order', $args );
     211                'blocking' => true,
     212                'headers' => $headers,
     213                'cookies' => array(),
     214            );
     215            $response = wp_remote_post($this->api_path . 'v2/order', $args);
    184216            $responseBody = wp_remote_retrieve_body($response);
    185217            error_log("binance response " . $responseBody);
  • binance-pay/trunk/readme.txt

    r2919963 r2940706  
    55Tested up to: 6.2
    66Requires PHP: 5.6
    7 Stable tag: 1.0.3
     7Stable tag: 1.1.0
    88License: Apache License, Version 2.0
    99License URI: http://www.apache.org/licenses/LICENSE-2.0
     
    5050= 1.0.3 =
    5151* Update readme.txt
     52= 1.1.0 =
     53* Support the configuration of fiat currency, with fiat selection, your customers will pay you with equivalent USDT, and your settlement currency will be in USDT as well.
Note: See TracChangeset for help on using the changeset viewer.