├── .gitignore ├── README.md ├── assets └── js │ └── frontend │ ├── blocks.asset.php │ └── blocks.js ├── icons ├── aman.svg ├── amaninstallments.svg ├── amex.png ├── applepay.svg ├── basata.svg ├── creditcard.svg ├── fawry.png ├── forsa.png ├── halan.svg ├── knet.svg ├── mada.svg ├── meeza.png ├── meezaqr.png ├── nbe-installment.png ├── omannet.png ├── paypal.svg ├── paytabs.png ├── sadad.png ├── souhoola.png ├── stcpay.png ├── tabby.svg ├── tamara.svg ├── touchpoints_adcb.svg ├── tru.svg ├── unionpay.png ├── urpay.svg ├── valu.png └── valu_long.png ├── images └── logo-animation.gif ├── includes ├── _managed_form.php ├── _valu_widget.php ├── blocks │ └── class-wc-paytabs-payments-blocks.php ├── paytabs_core.php ├── paytabs_functions.php ├── paytabs_gateways.php ├── paytabs_payment_methods.php ├── paytabs_payment_token.php └── widgets │ └── valu.php ├── package-lock.json ├── package.json ├── paytabs-woocommerce.php ├── resources └── js │ └── frontend │ └── index.js └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/* 2 | node_modules 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PayTabs - WooCommerce 2 | 3 | Official WooCommerce plugin for PayTabs 4 | 5 | --- 6 | 7 | ## Installation 8 | 9 | *Note:* **WooCommerce** must be installed and activated for PayTabs plugin to work. 10 | 11 | ### Install using FTP method 12 | 13 | 1. Download the latest release of the plugin 14 | 2. Upload the folder `paytabs-woocommerce` to the wordpress installation directory: `wp-content/plugins/` 15 | 16 | *Note: Delete any previous PayTabs plugin.* 17 | 18 | ### Install using WordPress Admin panel 19 | 20 | 1. Download the latest release of the plugin 21 | 2. Go to `"WordPress admin panel" >> Plugins >> Add New` 22 | 3. Select `Upload Plugin` 23 | 4. Click `Browse` and select the downloaded zip file (`paytabs-woocommerce.zip`) 24 | 5. Click `Install Now` 25 | 6. If a previous version exists, select `Replace current with uploaded` 26 | 27 | --- 28 | 29 | ## Activating the Plugin 30 | 31 | 1. Go to `"Wordpress admin panel" >> Plugins >> Installed Plugins` 32 | 2. Look for `PayTabs - WooCommerce Payment Gateway` and click `Activate` 33 | 34 | --- 35 | 36 | ## Configure the Plugin 37 | 38 | 1. Go to `"WordPress admin panel" >> WooCommerce >> Settings` 39 | 2. Select `Payments` tab 40 | 3. Select the preferred payment method from the available list of PayTabs payment methods 41 | 4. Check the `Enable Payment Gateway` 42 | 5. Enter the primary credentials: 43 | - **Profile ID**: Enter the Profile ID of your PayTabs account 44 | - **Server Key**: `Merchant’s Dashboard >> Developers >> Key management >> Server Key` 45 | 6. Click `Save changes` 46 | 47 | ## Use Auth - Capture - Void 48 | 49 | 1. In the configuration page select transaction type: **Auth**. 50 | 2. The default order-status for **Auth** Orders is **on-hold** unless you change it from the configuration page. 51 | 3. To **Capture** an **Auth** order you need to go to the order edit view >> change the order status to **Completed** then Save, the **Capture** will be done. 52 | 4. To **Void** the **Auth** order, you need to go to the order edit view >> change the order status to **Cancelled** then Save, the **Void** will be done. 53 | 54 | ## Use iFrame 55 | 56 | --- 57 | 58 | 1. In the configuration page select Payment form type: **iFrame**. 59 | 2. Save the configuration. 60 | 61 | ## Log Access 62 | 63 | ### PayTabs custome log 64 | 65 | 1. Access `debug_paytabs.log` file found at: `/wp-content/debug_paytabs.log` 66 | 67 | --- 68 | 69 | Done 70 | -------------------------------------------------------------------------------- /assets/js/frontend/blocks.asset.php: -------------------------------------------------------------------------------- 1 | array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => '36a58bf9a6f684597cde'); 2 | -------------------------------------------------------------------------------- /assets/js/frontend/blocks.js: -------------------------------------------------------------------------------- 1 | (()=>{"use strict";var e={20:(e,t,n)=>{var s=n(609),i=Symbol.for("react.element"),o=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,a=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var s,o={},c=null,l=null;for(s in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(l=t.ref),t)r.call(t,s)&&!d.hasOwnProperty(s)&&(o[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps)void 0===o[s]&&(o[s]=t[s]);return{$$typeof:i,type:e,key:c,ref:l,props:o,_owner:a.current}}t.Fragment=o,t.jsx=c,t.jsxs=c},609:e=>{e.exports=window.React},848:(e,t,n)=>{e.exports=n(20)}},t={};window.wp.i18n;const n=window.wc.wcBlocksRegistry,s=window.wp.htmlEntities,i=window.wc.wcSettings;var o=function n(s){var i=t[s];if(void 0!==i)return i.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,n),o.exports}(848);const r=(0,i.getSetting)("paytabs_blocks_data",{}),a=e=>{const{PaymentMethodLabel:t}=e.components;return(0,o.jsxs)(o.Fragment,{children:[e.setting.description&&(0,o.jsx)("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",paddingRight:5,paddingLeft:5},children:(0,o.jsx)(t,{text:e.setting.description})}),e.showSaveNote&&(0,o.jsx)("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",paddingRight:5,paddingLeft:5},children:(0,o.jsx)("strong",{children:"Will Save to Account"})})]})},d=e=>{const{PaymentMethodLabel:t}=e.components;return(0,o.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",paddingRight:5,paddingLeft:5},children:[(0,o.jsx)(t,{text:(0,s.decodeEntities)(e.setting.title)}),""!=e.setting.icon&&(0,o.jsx)("img",{src:e.setting.icon,alt:e.setting.name})]})};let c=r.cart.has_subscription;r.blocks.forEach((e=>{let t=e.supports.includes("tokenization")&&e.enable_tokenise,i=t&&c,r={name:e.name,label:(0,o.jsx)(d,{setting:e}),content:(0,o.jsx)(a,{setting:e,showSaveNote:i}),edit:(0,o.jsx)("div",{children:(0,s.decodeEntities)(e.description)}),canMakePayment:()=>!0,ariaLabel:(0,s.decodeEntities)(e.title),supports:{showSavedCards:t,showSaveOption:t&&!c,features:e.supports}};(0,n.registerPaymentMethod)(r)}))})(); -------------------------------------------------------------------------------- /icons/amaninstallments.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/amex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/amex.png -------------------------------------------------------------------------------- /icons/applepay.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /icons/basata.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /icons/creditcard.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /icons/fawry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/fawry.png -------------------------------------------------------------------------------- /icons/forsa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/forsa.png -------------------------------------------------------------------------------- /icons/halan.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /icons/knet.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 34 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /icons/mada.svg: -------------------------------------------------------------------------------- 1 | 2 | 10 | 12 | 14 | 15 | 18 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /icons/meeza.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/meeza.png -------------------------------------------------------------------------------- /icons/meezaqr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/meezaqr.png -------------------------------------------------------------------------------- /icons/nbe-installment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/nbe-installment.png -------------------------------------------------------------------------------- /icons/omannet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/omannet.png -------------------------------------------------------------------------------- /icons/paypal.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /icons/paytabs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/paytabs.png -------------------------------------------------------------------------------- /icons/sadad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/sadad.png -------------------------------------------------------------------------------- /icons/souhoola.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/souhoola.png -------------------------------------------------------------------------------- /icons/stcpay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/stcpay.png -------------------------------------------------------------------------------- /icons/tabby.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /icons/tamara.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /icons/touchpoints_adcb.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /icons/tru.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /icons/unionpay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/unionpay.png -------------------------------------------------------------------------------- /icons/urpay.svg: -------------------------------------------------------------------------------- 1 | 2 | 11 | 13 | 18 | 21 | 24 | 27 | 30 | 33 | 36 | 39 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /icons/valu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/valu.png -------------------------------------------------------------------------------- /icons/valu_long.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/icons/valu_long.png -------------------------------------------------------------------------------- /images/logo-animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paytabscom/paytabs-woocommerce/90614863f599e1f7263c46a3e4bcfebeb13cd9f0/images/logo-animation.gif -------------------------------------------------------------------------------- /includes/_managed_form.php: -------------------------------------------------------------------------------- 1 | client_key; 4 | 5 | $_js_path = 'payment/js/paylib.js'; 6 | $_js_url = $this->get_endpoint_url() . $_js_path; 7 | ?> 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 | 17 | 18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 |
29 | 30 |
31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /includes/_valu_widget.php: -------------------------------------------------------------------------------- 1 | getIconWidget(); 4 | 5 | ?> 6 | 7 |
8 | 9 | 10 | 13 | 16 | 17 |
11 | valU logo 12 | 14 | 15 |
18 |
-------------------------------------------------------------------------------- /includes/blocks/class-wc-paytabs-payments-blocks.php: -------------------------------------------------------------------------------- 1 | gateways = $this->get_gateways(); 28 | } 29 | 30 | public function get_gateways() 31 | { 32 | $gateways = WC()->payment_gateways->payment_gateways(); 33 | $enabled_gateways = []; 34 | 35 | foreach ($gateways as $gateway) { 36 | if ((substr($gateway->id, 0, 8) === "paytabs_") && $gateway->enabled == "yes") { 37 | $enabled_gateways[$gateway->id] = $gateway; 38 | } 39 | } 40 | return $enabled_gateways; 41 | } 42 | 43 | /** 44 | * Returns if this payment method should be active. If false, the scripts will not be enqueued. 45 | * 46 | * @return boolean 47 | */ 48 | public function is_active() 49 | { 50 | return true; // $this->gateway->is_available(); 51 | } 52 | 53 | /** 54 | * Returns an array of scripts/handles to be registered for this payment method. 55 | * 56 | * @return array 57 | */ 58 | public function get_payment_method_script_handles() 59 | { 60 | $script_path = 'assets/js/frontend/blocks.js'; 61 | $script_asset_path = PAYTABS_PAYPAGE_DIR . 'assets/js/frontend/blocks.asset.php'; 62 | $script_asset = file_exists($script_asset_path) 63 | ? require($script_asset_path) 64 | : array( 65 | 'dependencies' => array(), 66 | 'version' => '1.2.0' 67 | ); 68 | $script_url = PAYTABS_PAYPAGE_URL . $script_path; 69 | 70 | wp_register_script( 71 | $this->id, 72 | $script_url, 73 | $script_asset['dependencies'], 74 | $script_asset['version'], 75 | true 76 | ); 77 | 78 | if (function_exists('wp_set_script_translations')) { 79 | // wp_set_script_translations( 'wc-dummy-payments-blocks', 'woocommerce-gateway-dummy', WC_Dummy_Payments::plugin_abspath() . 'languages/' ); 80 | } 81 | 82 | return [$this->id]; 83 | } 84 | 85 | /** 86 | * Returns an array of key=>value pairs of data made available to the payment methods script. 87 | * 88 | * @return array 89 | */ 90 | public function get_payment_method_data() 91 | { 92 | $data = []; 93 | 94 | foreach ($this->gateways as $gateway) { 95 | $gateWayData = [ 96 | 'name' => $gateway->id, 97 | 'title' => $gateway->title, 98 | 'supports' => array_filter($gateway->supports, [$gateway, 'supports']), 99 | 'icon' => $gateway->getIcon(), 100 | 'description' => $gateway->description, 101 | 'enable_tokenise' => $gateway->enable_tokenise, 102 | ]; 103 | 104 | $key = "blocks"; 105 | $data[$key][] = $gateWayData; 106 | } 107 | $data['cart']['has_subscription'] = class_exists('WC_Subscriptions_Cart') && WC_Subscriptions_Cart::cart_contains_subscription(); 108 | 109 | return $data; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /includes/paytabs_functions.php: -------------------------------------------------------------------------------- 1 |

PayTabs requires WooCommerce to be installed and active.

'; 8 | } 9 | 10 | function woocommerce_paytabs_version_check($version = '3.0') 11 | { 12 | global $woocommerce; 13 | if (version_compare($woocommerce->version, $version, ">=")) { 14 | return true; 15 | } 16 | 17 | return false; 18 | } 19 | 20 | function paytabs_error_log($message, $severity) 21 | { 22 | $severity_str = $severity == 1 ? 'Info' : ($severity == 2 ? 'Warning' : 'Error'); 23 | 24 | $_prefix = date('c') . " PayTabs.{$severity_str}: "; 25 | error_log($_prefix . $message . PHP_EOL, 3, PAYTABS_DEBUG_FILE); 26 | } 27 | 28 | function woocommerce_paytabs_htaccess_notice() 29 | { 30 | echo '

Ensure that you allow "override all" in your server\'s configurations to enable the proper functionality of the .htaccess file.

'; 31 | } 32 | 33 | 34 | function woocommerce_paytabs_check_log_permission() 35 | { 36 | // Print message to the merchant to make sure allow the webserver setting. 37 | // add_action('admin_notices', 'woocommerce_paytabs_htaccess_notice'); 38 | 39 | $permission = 40 | PHP_EOL . 41 | "" . PHP_EOL . 42 | " Order Allow,Deny" . PHP_EOL . 43 | " Deny from all" . PHP_EOL . 44 | ""; 45 | 46 | // prevent debug file from opening inside the browser 47 | if (!file_exists(PAYTABS_HTACCESS_FILE)) { 48 | $myhtaccessfile = fopen(PAYTABS_HTACCESS_FILE, "w"); 49 | $res = fwrite($myhtaccessfile, $permission); 50 | fclose($myhtaccessfile); 51 | 52 | if ($res) { 53 | PaytabsHelper::log("Debug file secured.", 1); 54 | } else { 55 | PaytabsHelper::log("Could not write to .htaccess file.", 3); 56 | } 57 | } else { 58 | // Try to read the content online 59 | $url = PAYTABS_DEBUG_FILE_URL; 60 | $ch = curl_init($url); 61 | curl_setopt($ch, CURLOPT_HEADER, true); // we want headers 62 | curl_setopt($ch, CURLOPT_NOBODY, true); // we don't need body 63 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 64 | curl_setopt($ch, CURLOPT_TIMEOUT, 10); 65 | @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 66 | @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 67 | $output = curl_exec($ch); 68 | $error_num = curl_errno($ch); 69 | $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 70 | curl_close($ch); 71 | 72 | if ($httpcode === 403) { 73 | PaytabsHelper::log("Debug file already secured.", 1); 74 | } elseif ($error_num) { 75 | $output_err = curl_error($ch); 76 | PaytabsHelper::log("Checking .htaccess error: [{$output_err}].", 2); 77 | } else { 78 | $htaccess_file_content = file_get_contents(PAYTABS_HTACCESS_FILE); 79 | 80 | if (strpos($htaccess_file_content, PAYTABS_DEBUG_FILE_NAME) !== false) { 81 | PaytabsHelper::log("Allow 'override all' into your webserver to enable the proper functioning of the .htaccess file.", 2); 82 | } else { 83 | $htaccessFile = PAYTABS_HTACCESS_FILE; 84 | file_put_contents($htaccessFile, $permission, FILE_APPEND); 85 | 86 | PaytabsHelper::log("Debug file appended to htaccess.", 1); 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /includes/paytabs_gateways.php: -------------------------------------------------------------------------------- 1 | valu_product_id = $this->get_option('valu_product_id'); 108 | 109 | $this->valu_widget_enable = $this->get_option('valu_widget_enable') == 'yes'; 110 | $this->valu_widget_static_content = $this->get_option('valu_widget_static_content') == 'yes'; 111 | $this->valu_widget_phone_number = $this->get_option('valu_widget_phone_number'); 112 | $this->valu_widget_price_threshold = $this->get_option('valu_widget_price_threshold'); 113 | } 114 | 115 | public function init_form_fields() 116 | { 117 | parent::init_form_fields(); 118 | 119 | $this->form_fields['valu_widget_enable'] = [ 120 | 'title' => __('ValU widget', 'PayTabs'), 121 | 'label' => __('Enable ValU widget.', 'PayTabs'), 122 | 'description' => __('Show valU widget in product\'s details page.', 'PayTabs'), 123 | 'type' => 'checkbox', 124 | 'default' => 'no' 125 | ]; 126 | $this->form_fields['valu_widget_static_content'] = [ 127 | 'title' => __('ValU widget, Static content', 'PayTabs'), 128 | 'type' => 'checkbox', 129 | 'label' => __('ValU widget, Static content.', 'PayTabs'), 130 | 'description' => __('Display the static content in the widget, Otherwise call the API to fetch live content based on the price.', 'PayTabs'), 131 | 'default' => 'no' 132 | ]; 133 | $this->form_fields['valu_widget_phone_number'] = [ 134 | 'title' => __('ValU phone number', 'PayTabs'), 135 | 'type' => 'text', 136 | 'description' => __('Registered valU phone number.', 'PayTabs'), 137 | 'default' => '', 138 | 'desc_tip' => true, 139 | ]; 140 | $this->form_fields['valu_widget_price_threshold'] = [ 141 | 'title' => __('ValU price threshold', 'PayTabs'), 142 | 'type' => 'text', 143 | 'description' => __('Display The widget if the product price higher than the current thershold.', 'PayTabs'), 144 | 'default' => '1000', 145 | 'desc_tip' => true, 146 | ]; 147 | } 148 | 149 | public function getIconWidget() 150 | { 151 | $icon_name = 'valu_long.png'; 152 | 153 | $iconPath = PAYTABS_PAYPAGE_DIR . "icons/{$icon_name}"; 154 | $icon = ''; 155 | if (file_exists($iconPath)) { 156 | $icon = PAYTABS_PAYPAGE_ICONS_URL . "{$icon_name}"; 157 | } 158 | 159 | return $icon; 160 | } 161 | } 162 | 163 | class WC_Gateway_Paytabs_Meeza extends WC_Gateway_Paytabs 164 | { 165 | protected $_code = 'meeza'; 166 | protected $_title = 'PayTabs - Meeza'; 167 | protected $_description = 'PayTabs - Meeza payment method'; 168 | } 169 | 170 | class WC_Gateway_Paytabs_Meezaqr extends WC_Gateway_Paytabs 171 | { 172 | protected $_code = 'meezaqr'; 173 | protected $_title = 'PayTabs - Meeza QR'; 174 | protected $_description = 'PayTabs - Meeza QR payment method'; 175 | } 176 | 177 | class WC_Gateway_Paytabs_Unionpay extends WC_Gateway_Paytabs 178 | { 179 | protected $_code = 'unionpay'; 180 | protected $_title = 'PayTabs - UnionPay'; 181 | protected $_description = 'PayTabs - UnionPay payment method'; 182 | } 183 | 184 | class WC_Gateway_Paytabs_Samsungpay extends WC_Gateway_Paytabs 185 | { 186 | protected $_code = 'samsungpay'; 187 | protected $_title = 'PayTabs - SamsungPay'; 188 | protected $_description = 'PayTabs - SamsungPay payment method'; 189 | } 190 | 191 | class WC_Gateway_Paytabs_Aman extends WC_Gateway_Paytabs 192 | { 193 | protected $_code = 'aman'; 194 | protected $_title = 'PayTabs - Aman'; 195 | protected $_description = 'PayTabs - Aman payment method'; 196 | 197 | protected $_icon = "aman.svg"; 198 | } 199 | 200 | 201 | class WC_Gateway_Paytabs_Urpay extends WC_Gateway_Paytabs 202 | { 203 | protected $_code = 'urpay'; 204 | protected $_title = 'PayTabs - UrPay'; 205 | protected $_description = 'PayTabs - UrPay payment method'; 206 | 207 | protected $_icon = "urpay.svg"; 208 | } 209 | 210 | 211 | class WC_Gateway_Paytabs_Paypal extends WC_Gateway_Paytabs 212 | { 213 | protected $_code = 'paypal'; 214 | protected $_title = 'PayTabs - PayPal'; 215 | protected $_description = 'PayTabs - PayPal payment method'; 216 | 217 | protected $_icon = "paypal.svg"; 218 | } 219 | 220 | 221 | class WC_Gateway_Paytabs_Installment extends WC_Gateway_Paytabs 222 | { 223 | protected $_code = 'installment'; 224 | protected $_title = 'PayTabs - Installment'; 225 | protected $_description = 'PayTabs - Installment payment method'; 226 | 227 | protected $_icon = "nbe-installment.png"; 228 | } 229 | 230 | 231 | class WC_Gateway_Paytabs_Touchpoints extends WC_Gateway_Paytabs 232 | { 233 | protected $_code = 'touchpoints'; 234 | protected $_title = 'PayTabs - Touchpoints'; 235 | protected $_description = 'PayTabs - ADCB Touchpoints payment method'; 236 | 237 | protected $_icon = "touchpoints_adcb.svg"; 238 | } 239 | 240 | class WC_Gateway_Paytabs_Forsa extends WC_Gateway_Paytabs 241 | { 242 | protected $_code = 'forsa'; 243 | protected $_title = 'PayTabs - Forsa'; 244 | protected $_description = 'PayTabs - Forsa payment method'; 245 | 246 | protected $_icon = "forsa.png"; 247 | } 248 | 249 | class WC_Gateway_Paytabs_Tabby extends WC_Gateway_Paytabs 250 | { 251 | protected $_code = 'tabby'; 252 | protected $_title = 'PayTabs - Tabby'; 253 | protected $_description = 'PayTabs - Tabby payment method'; 254 | 255 | protected $_icon = "tabby.svg"; 256 | } 257 | 258 | class WC_Gateway_Paytabs_Souhoola extends WC_Gateway_Paytabs 259 | { 260 | protected $_code = 'souhoola'; 261 | protected $_title = 'PayTabs - Souhoola'; 262 | protected $_description = 'PayTabs - Souhoola payment method'; 263 | 264 | protected $_icon = "souhoola.png"; 265 | } 266 | 267 | class WC_Gateway_Paytabs_AmanInstallments extends WC_Gateway_Paytabs 268 | { 269 | protected $_code = 'amaninstallments'; 270 | protected $_title = 'PayTabs - Aman installments'; 271 | protected $_description = 'PayTabs - Aman installments payment method'; 272 | 273 | protected $_icon = "amaninstallments.svg"; 274 | } 275 | 276 | class WC_Gateway_Paytabs_Tamara extends WC_Gateway_Paytabs 277 | { 278 | protected $_code = 'tamara'; 279 | protected $_title = 'PayTabs - Tamara '; 280 | protected $_description = 'PayTabs - Tamara payment method'; 281 | 282 | protected $_icon = "tamara.svg"; 283 | } 284 | 285 | class WC_Gateway_Paytabs_Halan extends WC_Gateway_Paytabs 286 | { 287 | protected $_code = 'halan'; 288 | protected $_title = 'PayTabs - Halan '; 289 | protected $_description = 'PayTabs - Halan payment method'; 290 | 291 | protected $_icon = "halan.svg"; 292 | } 293 | 294 | class WC_Gateway_Paytabs_Basata extends WC_Gateway_Paytabs 295 | { 296 | protected $_code = 'basata'; 297 | protected $_title = 'PayTabs - Basata'; 298 | protected $_description = 'PayTabs - Basata payment method'; 299 | 300 | protected $_icon = "basata.svg"; 301 | } 302 | 303 | class WC_Gateway_Paytabs_Tru extends WC_Gateway_Paytabs 304 | { 305 | protected $_code = 'shahry'; 306 | protected $_title = 'PayTabs - TRU'; 307 | protected $_description = 'PayTabs - TRU payment method'; 308 | 309 | protected $_icon = "tru.svg"; 310 | } 311 | -------------------------------------------------------------------------------- /includes/paytabs_payment_token.php: -------------------------------------------------------------------------------- 1 | '', 14 | 'last4' => '', 15 | 'expiry_year' => '', 16 | 'expiry_month' => '', 17 | 'payment_method_type' => '', 18 | ); 19 | 20 | 21 | public function validate() 22 | { 23 | if (false === parent::validate()) { 24 | return false; 25 | } 26 | 27 | if (!$this->get_tran_ref()) { // || !$this->get_token()) { 28 | return false; 29 | } 30 | 31 | return true; 32 | } 33 | 34 | public function get_display_name($deprecated = '') 35 | { 36 | $last4 = $this->get_last4(); 37 | if (empty($last4) || $last4 == 'N/A') { 38 | $str = 'P' . substr($this->get_tran_ref(), -3); 39 | } else { 40 | $str = $last4; 41 | } 42 | return "Pay using existing card (...$str)"; 43 | } 44 | 45 | 46 | public function get_tran_ref($context = 'view') 47 | { 48 | return $this->get_prop('tran_ref', $context); 49 | } 50 | 51 | public function set_tran_ref($tran_ref) 52 | { 53 | $this->set_prop('tran_ref', $tran_ref); 54 | } 55 | 56 | /** 57 | * Set the last four digits. 58 | * 59 | * @since 4.0.0 60 | * @version 4.0.0 61 | * @param string $last4 62 | */ 63 | public function set_last4($last4) 64 | { 65 | $this->set_prop('last4', $last4); 66 | } 67 | 68 | public function get_last4($context = 'view') 69 | { 70 | return $this->get_prop('last4', $context); 71 | } 72 | 73 | /** 74 | * Set Stripe payment method type. 75 | * 76 | * @param string $type Payment method type. 77 | */ 78 | public function set_payment_method_type($type) 79 | { 80 | $this->set_prop('payment_method_type', $type); 81 | } 82 | 83 | /** 84 | * Returns Stripe payment method type. 85 | * 86 | * @param string $context What the value is for. Valid values are view and edit. 87 | * @return string $payment_method_type 88 | */ 89 | public function get_payment_method_type($context = 'view') 90 | { 91 | return $this->get_prop('payment_method_type', $context); 92 | } 93 | 94 | 95 | /** 96 | * Set the card type (mastercard, visa, ...). 97 | * 98 | * @since 2.6.0 99 | * @param string $type Credit card type (mastercard, visa, ...). 100 | */ 101 | public function set_card_type($type) 102 | { 103 | $this->set_prop('card_type', $type); 104 | } 105 | 106 | public function get_card_type($context = 'view') 107 | { 108 | return $this->get_prop('card_type', $context); 109 | } 110 | 111 | /** 112 | * Set the expiration year for the card (YYYY format). 113 | * 114 | * @since 2.6.0 115 | * @param string $year Credit card expiration year. 116 | */ 117 | public function set_expiry_year($year) 118 | { 119 | $this->set_prop('expiry_year', $year); 120 | } 121 | 122 | public function get_expiry_year($context = 'view') 123 | { 124 | return $this->get_prop('expiry_year', $context); 125 | } 126 | 127 | /** 128 | * Set the expiration month for the card (formats into MM format). 129 | * 130 | * @since 2.6.0 131 | * @param string $month Credit card expiration month. 132 | */ 133 | public function set_expiry_month($month) 134 | { 135 | $this->set_prop('expiry_month', str_pad($month, 2, '0', STR_PAD_LEFT)); 136 | } 137 | 138 | public function get_expiry_month($context = 'view') 139 | { 140 | return $this->get_prop('expiry_month', $context); 141 | } 142 | } 143 | 144 | function get_account_saved_payment_methods_list_item_paytabs($item, $payment_token) 145 | { 146 | if ('paytabs' === strtolower($payment_token->get_type())) { 147 | $item['method']['last4'] = $payment_token->get_last4(); 148 | // $item['method']['expire'] = $payment_token->get_expiry_year(); 149 | $item['method']['brand'] = isset($item['method']['gateway']) ? $item['method']['gateway'] : ('PayTabs, ' . $payment_token->get_display_name()); 150 | $item['expires'] = $payment_token->get_expiry_month() . '/' . $payment_token->get_expiry_year(); 151 | } 152 | return $item; 153 | } 154 | -------------------------------------------------------------------------------- /includes/widgets/valu.php: -------------------------------------------------------------------------------- 1 | valu_widget_enable) { 9 | 10 | $product_price = $this->get_product_price(); 11 | if ($product_price) { 12 | if ($product_price >= $valu_payment->valu_widget_price_threshold) { 13 | 14 | if ($valu_payment->valu_widget_static_content) { 15 | $plan = $this->get_static_content(); 16 | } else { 17 | $plan = $this->call_valu_api($valu_payment, $product_price); 18 | } 19 | 20 | if ($plan) { 21 | include(PAYTABS_PAYPAGE_DIR . 'includes/_valu_widget.php'); 22 | } 23 | } 24 | } 25 | } 26 | } 27 | 28 | private function get_static_content() 29 | { 30 | return "Buy Now & Pay Later up to 60 Months!"; 31 | } 32 | 33 | private function get_product_price() 34 | { 35 | // Get the current product's ID. 36 | $product_id = get_the_ID(); 37 | $product = wc_get_product($product_id); 38 | $product_price = 0; 39 | 40 | if ($product) { 41 | // Get the product price. 42 | $product_price = $product->get_price(); 43 | } 44 | 45 | return $product_price; 46 | } 47 | 48 | private function call_valu_api($valu_payment, $product_price) 49 | { 50 | $_paytabsApi = PaytabsApi::getInstance($valu_payment->paytabs_endpoint, $valu_payment->merchant_id, $valu_payment->merchant_key); 51 | $phone_number = $valu_payment->valu_widget_phone_number; 52 | 53 | $data = [ 54 | 'cart_amount' => $product_price, 55 | 'cart_currency' => "EGP", 56 | 'customer_details' => [ 57 | "phone" => $phone_number 58 | ], 59 | ]; 60 | 61 | PaytabsHelper::log("valU inquiry, {$product_price}", 1); 62 | $details = $_paytabsApi->inquiry_valu($data); 63 | 64 | if (!$details || !$details->success) { 65 | $_err_msg = json_encode($details); 66 | PaytabsHelper::log("valU Details error: [{$_err_msg}]", 3); 67 | return false; 68 | } 69 | 70 | $installments_count = 3; 71 | $valu_plan = $this->getValUPlan($details, $installments_count); 72 | 73 | if (!$valu_plan) { 74 | return false; 75 | } 76 | 77 | try { 78 | $installment_amount = $valu_plan->emi; 79 | 80 | $calculated_installment = round($product_price / $installments_count, 2); 81 | $is_free_interest = $calculated_installment >= $installment_amount; 82 | 83 | $txt_free = $is_free_interest ? "interest-free" : ""; 84 | 85 | $msg = "Pay {$installments_count} {$txt_free} payments of EGP $installment_amount."; 86 | 87 | return $msg; 88 | } catch (\Throwable $th) { 89 | PaytabsHelper::log("valU widget error: " . $th->getMessage(), 3); 90 | } 91 | 92 | return false; 93 | } 94 | 95 | private function getValUPlan($details, $installments_count) 96 | { 97 | try { 98 | $plansList = $details->valuResponse->productList[0]->tenureList; 99 | foreach ($plansList as $plan) { 100 | if ($plan->tenorMonth == $installments_count) { 101 | return $plan; 102 | } 103 | } 104 | } catch (\Throwable $th) { 105 | PaytabsHelper::log("valU Plan error: " . $th->getMessage(), 3); 106 | } 107 | 108 | $_log = json_encode($plansList); 109 | PaytabsHelper::log("valU Plan error: No Plan selected, [{$_log}]", 2); 110 | 111 | return false; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "paytabs-woocommerce", 3 | "title": "PayTabs - WooCommerce", 4 | "version": "1.1.3", 5 | "author": "PayTabs", 6 | "license": "GPL-3.0+", 7 | "keywords": [], 8 | "engines": { 9 | "node": ">=18", 10 | "npm": ">=8" 11 | }, 12 | "devDependencies": { 13 | "@woocommerce/dependency-extraction-webpack-plugin": "^3.1", 14 | "@wordpress/scripts": "^30.12", 15 | "cross-env": "7.0.3" 16 | }, 17 | "scripts": { 18 | "build": "wp-scripts build", 19 | "check-engines": "wp-scripts check-engines", 20 | "check-licenses": "wp-scripts check-licenses", 21 | "format": "wp-scripts format", 22 | "lint:css": "wp-scripts lint-style", 23 | "lint:js": "wp-scripts lint-js", 24 | "lint:md:docs": "wp-scripts lint-md-docs", 25 | "lint:pkg-json": "wp-scripts lint-pkg-json", 26 | "packages-update": "wp-scripts packages-update", 27 | "plugin-zip": "wp-scripts plugin-zip", 28 | "start": "wp-scripts start", 29 | "test:e2e": "wp-scripts test-e2e", 30 | "test:unit": "wp-scripts test-unit-js" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /paytabs-woocommerce.php: -------------------------------------------------------------------------------- 1 | 3rd party payment gateway. Ideal payment solutions for your internet business. 11 | 12 | * Version: 5.7.2 13 | * Requires PHP: 7.0 14 | * Requires Plugins: woocommerce 15 | 16 | * Author: PayTabs 17 | * Author URI: mailto:integration@paytabs.com 18 | 19 | * GitHub Plugin URI: https://github.com/paytabscom/paytabs-woocommerce 20 | */ 21 | 22 | if (!function_exists('add_action')) { 23 | exit; 24 | } 25 | 26 | 27 | define('PAYTABS_PAYPAGE_VERSION', '5.7.2'); 28 | define('PAYTABS_PAYPAGE_DIR', plugin_dir_path(__FILE__)); 29 | define('PAYTABS_PAYPAGE_URL', plugins_url("/", __FILE__)); 30 | define('PAYTABS_PAYPAGE_ICONS_URL', plugins_url("icons/", __FILE__)); 31 | define('PAYTABS_PAYPAGE_IMAGES_URL', plugins_url("images/", __FILE__)); 32 | define('PAYTABS_DEBUG_FILE', WP_CONTENT_DIR . "/debug_paytabs.log"); 33 | define('PAYTABS_HTACCESS_FILE', WP_CONTENT_DIR . "/.htaccess"); 34 | define('PAYTABS_DEBUG_FILE_URL', get_bloginfo('url') . "/wp-content/debug_paytabs.log"); 35 | 36 | define('PAYTABS_PAYPAGE_METHODS', [ 37 | 'mada' => 'WC_Gateway_Paytabs_Mada', 38 | 'all' => 'WC_Gateway_Paytabs_All', 39 | 'creditcard' => 'WC_Gateway_Paytabs_Creditcard', 40 | 'stcpay' => 'WC_Gateway_Paytabs_Stcpay', 41 | // 'stcpayqr' => 'WC_Gateway_Paytabs_Stcpayqr', 42 | 'applepay' => 'WC_Gateway_Paytabs_Applepay', 43 | 'omannet' => 'WC_Gateway_Paytabs_Omannet', 44 | 'sadad' => 'WC_Gateway_Paytabs_Sadad', 45 | // 'fawry' => 'WC_Gateway_Paytabs_Fawry', 46 | 'knet' => 'WC_Gateway_Paytabs_Knpay', 47 | 'amex' => 'WC_Gateway_Paytabs_Amex', 48 | 'valu' => 'WC_Gateway_Paytabs_Valu', 49 | 'meeza' => 'WC_Gateway_Paytabs_Meeza', 50 | 'meezaqr' => 'WC_Gateway_Paytabs_Meezaqr', 51 | 'unionpay' => 'WC_Gateway_Paytabs_Unionpay', 52 | 'aman' => 'WC_Gateway_Paytabs_Aman', 53 | 'urpay' => 'WC_Gateway_Paytabs_Urpay', 54 | 'paypal' => 'WC_Gateway_Paytabs_Paypal', 55 | 'installment' => 'WC_Gateway_Paytabs_Installment', 56 | 'touchpoints' => 'WC_Gateway_Paytabs_Touchpoints', 57 | // 'samsungpay' => 'WC_Gateway_Paytabs_Samsungpay', 58 | 'forsa' => 'WC_Gateway_Paytabs_Forsa', 59 | 'tabby' => 'WC_Gateway_Paytabs_Tabby', 60 | 'souhoola' => 'WC_Gateway_Paytabs_Souhoola', 61 | 'amaninstallments' => 'WC_Gateway_Paytabs_AmanInstallments', 62 | 'tamara' => 'WC_Gateway_Paytabs_Tamara', 63 | 'halan' => 'WC_Gateway_Paytabs_Halan', 64 | 'basata' => 'WC_Gateway_Paytabs_Basata', 65 | 'tru' => 'WC_Gateway_Paytabs_Tru', 66 | ]); 67 | 68 | require_once PAYTABS_PAYPAGE_DIR . 'includes/paytabs_core.php'; 69 | require_once PAYTABS_PAYPAGE_DIR . 'includes/paytabs_functions.php'; 70 | 71 | // Plugin activated 72 | register_activation_hook(__FILE__, 'woocommerce_paytabs_activated'); 73 | 74 | // Load plugin function when woocommerce loaded 75 | add_action('plugins_loaded', 'woocommerce_paytabs_init', 10, 0); 76 | 77 | // 78 | 79 | function woocommerce_paytabs_init() 80 | { 81 | 82 | if (!class_exists('WooCommerce') || !class_exists('WC_Payment_Gateway')) { 83 | add_action('admin_notices', 'woocommerce_paytabs_missing_wc_notice'); 84 | return; 85 | } 86 | 87 | define('WooCommerce2', !woocommerce_paytabs_version_check('3.0')); 88 | 89 | // PT 90 | require_once PAYTABS_PAYPAGE_DIR . 'includes/paytabs_payment_methods.php'; 91 | require_once PAYTABS_PAYPAGE_DIR . 'includes/paytabs_gateways.php'; 92 | require_once PAYTABS_PAYPAGE_DIR . 'includes/paytabs_payment_token.php'; 93 | require_once PAYTABS_PAYPAGE_DIR . 'includes/widgets/valu.php'; 94 | 95 | 96 | /** 97 | * Add the Gateway to WooCommerce 98 | **/ 99 | function woocommerce_add_paytabs_gateway($gateways) 100 | { 101 | $paytabs_gateways = array_values(PAYTABS_PAYPAGE_METHODS); 102 | $gateways = array_merge($gateways, $paytabs_gateways); 103 | 104 | return $gateways; 105 | } 106 | 107 | function paytabs_filter_gateways($load_gateways) 108 | { 109 | if (is_admin()) return $load_gateways; 110 | 111 | $gateways = []; 112 | $currency = get_woocommerce_currency(); 113 | 114 | foreach ($load_gateways as $gateway) { 115 | 116 | $code = array_search($gateway, PAYTABS_PAYPAGE_METHODS); 117 | 118 | if ($code) { 119 | $allowed = PaytabsHelper::paymentAllowed($code, $currency); 120 | if ($allowed) { 121 | $gateways[] = $gateway; 122 | } 123 | } else { 124 | // Not PayTabs Gateway 125 | $gateways[] = $gateway; 126 | } 127 | } 128 | 129 | return $gateways; 130 | } 131 | 132 | 133 | /** 134 | * Add URL link to PayTabs plugin name pointing to WooCommerce payment tab 135 | */ 136 | function paytabs_add_action_links($links) 137 | { 138 | $settings_url = admin_url('admin.php?page=wc-settings&tab=checkout'); 139 | 140 | $links[] = "Settings"; 141 | 142 | return $links; 143 | } 144 | 145 | add_filter('woocommerce_payment_gateways', 'woocommerce_add_paytabs_gateway'); 146 | add_filter('woocommerce_payment_gateways', 'paytabs_filter_gateways', 10, 1); 147 | add_filter('woocommerce_payment_methods_list_item', 'get_account_saved_payment_methods_list_item_paytabs', 10, 2); 148 | add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'paytabs_add_action_links'); 149 | 150 | add_action('woocommerce_single_product_summary', 'pt_valu_widget', 21); 151 | 152 | add_action('woocommerce_blocks_loaded', 'woocommerce_gateway_paytabs_woocommerce_block_support'); 153 | function woocommerce_gateway_paytabs_woocommerce_block_support() 154 | { 155 | if (class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) { 156 | require_once 'includes/blocks/class-wc-paytabs-payments-blocks.php'; 157 | add_action( 158 | 'woocommerce_blocks_payment_method_type_registration', 159 | function (Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) { 160 | $payment_method_registry->register(new WC_Gateway_Paytabs_Blocks_Support()); 161 | } 162 | ); 163 | } 164 | } 165 | 166 | function pt_valu_widget() 167 | { 168 | $enabled_gateways = WC()->payment_gateways->get_available_payment_gateways(); 169 | 170 | if (array_key_exists('paytabs_valu', $enabled_gateways)) { 171 | $valu_payment = $enabled_gateways['paytabs_valu']; 172 | 173 | $valu_widget = new ValuWidget(); 174 | $valu_widget->init($valu_payment); 175 | } 176 | } 177 | } 178 | 179 | 180 | function woocommerce_paytabs_activated() 181 | { 182 | PaytabsHelper::log("Activate hook.", 1); 183 | woocommerce_paytabs_check_log_permission(); 184 | } 185 | -------------------------------------------------------------------------------- /resources/js/frontend/index.js: -------------------------------------------------------------------------------- 1 | import { sprintf, __ } from '@wordpress/i18n'; 2 | import { registerPaymentMethod } from '@woocommerce/blocks-registry'; 3 | import { decodeEntities } from '@wordpress/html-entities'; 4 | import { getSetting } from '@woocommerce/settings'; 5 | 6 | const settings = getSetting('paytabs_blocks_data', {}); 7 | 8 | // const defaultLabel = __('PayTabs Payments'); 9 | 10 | /** 11 | * Content component 12 | */ 13 | const Content = (props) => { 14 | const { PaymentMethodLabel } = props.components; 15 | 16 | return ( 17 | <> 18 | {props.setting.description && ( 19 |
28 | 29 |
30 | )} 31 | {props.showSaveNote && ( 32 |
41 | Will Save to Account 42 |
43 | )} 44 | 45 | ); 46 | }; 47 | 48 | /** 49 | * Label component 50 | * 51 | * @param {*} props Props from payment API. 52 | */ 53 | const Label = (props) => { 54 | const { PaymentMethodLabel } = props.components; 55 | 56 | return ( 57 |
66 | 69 | {props.setting.icon != '' && ( 70 | {props.setting.name} 71 | )} 72 |
73 | ); 74 | }; 75 | 76 | let hasSubscription = settings.cart.has_subscription; 77 | settings.blocks.forEach((setting) => { 78 | let supportTokenization = 79 | setting.supports.includes('tokenization') && setting.enable_tokenise; 80 | let showSaveNote = supportTokenization && hasSubscription; 81 | let gateWay = { 82 | name: setting.name, 83 | label: