Settings > Payments > 1pay.cx. * * Pure rendering: the gateway gathers the saved settings and the live catalogue into a * context array (OnePayCx_Gateway::panel_context()) and this class turns it into markup. * * Every control is a real form field that posts under woocommerce_onepaycx_, so the * page works as a plain form without JavaScript and saves through the gateway's normal * process_admin_options() path: * - fiat_disabled[] checkbox ticked = method switched OFF (the saved list is a blocklist, * so methods added later are on by default); shown as an on/off switch. * - crypto_accepted[] checkbox ticked = coin accepted. * - payout_addresses[] one text field per coin that needs its own address. * Both lists always post an empty entry, so switching everything back on saves an empty * list instead of "field not posted, keep the old value". * * All text is translatable (text domain 1pay-cx-payments). All images ship with the plugin. */ if (!defined('ABSPATH')) { exit; } final class OnePayCx_Settings_UI { /** The eight methods shown first, in this order; the rest sit behind "Show N more". */ const POPULAR = array('card', 'applepay', 'googlepay', 'cashapp', 'venmo', 'revolut', 'robinhood', 'coinbase'); /** Method marks that ship as logo images (assets/icons/.png). */ const ICON_PNG = array('banxa', 'coinbase', 'rampnetwork', 'revolut', 'topper', 'transak'); /** Method marks that ship as generated tiles (assets/icons/.svg). Anything else gets a monogram. */ const ICON_SVG = array( 'applepay', 'binance', 'blockchaincom', 'card', 'cashapp', 'crossmint', 'googlepay', 'ideal', 'interac', 'klarna', 'koywe', 'meld', 'mercuryo', 'moonpay', 'particle', 'paypal', 'ramp', 'robinhood', 'sardine', 'simpleswap', 'simplex', 'stripe', 'transfi', 'upi', 'utorg', 'venmo', 'wert', ); const FIAT_ID_RE = '/^[a-zA-Z0-9_-]{1,40}$/'; const CRYPTO_ID_RE = '/^[a-z0-9-]{1,40}$/'; // --------------------------------------------------------------------- // Static layout: which networks and coins the panel knows how to show // --------------------------------------------------------------------- /** EVM networks: rows of coin pills, all paid to the one EVM address. [asset id, label, default on] */ public static function networks() { return array( array('id' => 'polygon', 'name' => 'Polygon', 'icon' => 'pol', 'timing' => 'now', 'min' => 0, 'coins' => array(array('usdc-polygon', 'USDC', true), array('usdt-polygon', 'USDT', true), array('pol', 'POL', false))), array('id' => 'base', 'name' => 'Base', 'icon' => 'base', 'timing' => 'now', 'min' => 0, 'coins' => array(array('usdc-base', 'USDC', true), array('eth-base', 'ETH', false))), array('id' => 'arbitrum', 'name' => 'Arbitrum', 'icon' => 'arb', 'timing' => 'now', 'min' => 0, 'coins' => array(array('usdc-arbitrum', 'USDC', false), array('usdt-arbitrum', 'USDT', false), array('eth-arbitrum', 'ETH', false))), array('id' => 'bsc', 'name' => 'BNB Chain', 'icon' => 'bnb', 'timing' => 'now', 'min' => 0, 'coins' => array(array('usdt-bsc', 'USDT', true), array('usdc-bsc', 'USDC', false), array('bnb', 'BNB', false))), array('id' => 'ethereum', 'name' => 'Ethereum', 'icon' => 'eth', 'timing' => 'batch', 'min' => 50, 'coins' => array(array('usdc-ethereum', 'USDC', false), array('usdt-ethereum', 'USDT', false), array('eth', 'ETH', false))), ); } /** * Coins that need their own payout address. `key` is the payout_addresses key (an asset id the * server maps: sol covers sol/usdc-solana/usdt-solana, trx covers trx/usdt-tron); `subs` are the * token pills of a coin whose one address covers several assets. [asset id, label, default on] */ public static function coins() { $base58 = '[1-9A-HJ-NP-Za-km-z]'; return array( array('id' => 'xmr', 'key' => 'xmr', 'name' => 'Monero', 'tick' => 'XMR', 'icon' => 'xmr', 'timing' => 'xmr', 'ph' => '4… or 8…', 'subs' => array(), 're' => '^([48][0-9AB]' . $base58 . '{93}|4[0-9AB]' . $base58 . '{104})$'), array('id' => 'btc', 'key' => 'btc', 'name' => 'Bitcoin', 'tick' => 'BTC', 'icon' => 'btc', 'timing' => 'batch', 'ph' => 'bc1…, 1… or 3…', 'subs' => array(), 're' => '^(bc1[02-9ac-hj-np-z]{11,71}|[13]' . $base58 . '{25,34})$'), array('id' => 'ltc', 'key' => 'ltc', 'name' => 'Litecoin', 'tick' => 'LTC', 'icon' => 'ltc', 'timing' => 'batch', 'ph' => 'ltc1…, L… or M…', 'subs' => array(), 're' => '^(ltc1[02-9ac-hj-np-z]{11,71}|[LM3]' . $base58 . '{26,33})$'), array('id' => 'sol', 'key' => 'sol', 'name' => 'Solana', 'tick' => 'SOL', 'icon' => 'sol', 'timing' => 'now', 'ph' => '', 'subs' => array(array('sol', 'SOL', true), array('usdc-solana', 'USDC', true), array('usdt-solana', 'USDT', false)), 're' => '^' . $base58 . '{32,44}$'), array('id' => 'tron', 'key' => 'trx', 'name' => 'TRON', 'tick' => 'TRX', 'icon' => 'trx', 'timing' => 'now', 'ph' => 'T…', 'subs' => array(array('usdt-tron', 'USDT', true), array('trx', 'TRX', false)), 're' => '^T' . $base58 . '{33}$'), array('id' => 'xrp', 'key' => 'xrp', 'name' => 'XRP', 'tick' => 'XRP', 'icon' => 'xrp', 'timing' => 'now', 'ph' => 'r…', 'subs' => array(), 're' => '^r' . $base58 . '{24,34}$'), ); } /** Asset ids a coin card controls: its sub-pills, or the coin itself. */ private static function coin_assets(array $coin) { if ($coin['subs']) { $ids = array(); foreach ($coin['subs'] as $sub) { $ids[] = $sub[0]; } return $ids; } return array($coin['id']); } /** Does $address look right for $coin? Same patterns the script uses (they are passed to it as data-re). */ public static function address_state(array $coin, $address) { $address = trim((string) $address); if ('' === $address) { return 'empty'; } return 1 === preg_match('/' . $coin['re'] . '/D', $address) ? 'valid' : 'invalid'; } // --------------------------------------------------------------------- // Small helpers // --------------------------------------------------------------------- private static function icon_url($file) { return plugins_url('assets/icons/' . $file, ONEPAYCX_PLUGIN_FILE); } /** Escaped translated text with %1$s-style slots filled by already-escaped HTML. */ private static function fmt($translated, array $html_args) { return vsprintf(esc_html($translated), $html_args); } private static function dom_id($prefix, $id) { return $prefix . preg_replace('/[^a-zA-Z0-9_-]/', '-', (string) $id); } private static function checked($on) { return $on ? ' checked' : ''; } private static function icon_svg($kind) { if ('ok' === $kind) { return ''; } if ('bad' === $kind) { return ''; } if ('send' === $kind) { return ''; } return ''; } /** A link to the Telegram channel, opened in a new tab. */ private static function support_link($url, $class, $inner_html) { return '' . $inner_html . ''; } private static function msg($class, $icon, $text_html, $extra_class = '') { return '
' . ('' === $icon ? '' : self::icon_svg($icon)) . '' . $text_html . '
'; } private static function timing_label($timing) { if ('xmr' === $timing) { return __('Sent once $10 builds up', '1pay-cx-payments'); } if ('batch' === $timing) { return __('Sent once $200 builds up', '1pay-cx-payments'); } return __('Sent right away', '1pay-cx-payments'); } private static function bad_address_message($coin_id) { switch ($coin_id) { case 'xmr': return __('That isn’t a Monero address. Monero addresses start with 4 or 8 and are 95 characters long.', '1pay-cx-payments'); case 'btc': return __('That isn’t a Bitcoin address. It should start with bc1, 1 or 3.', '1pay-cx-payments'); case 'ltc': return __('That isn’t a Litecoin address. It should start with ltc1, L or M.', '1pay-cx-payments'); case 'sol': return __('That isn’t a Solana address.', '1pay-cx-payments'); case 'tron': return __('That isn’t a TRON address. It starts with T and is 34 characters long.', '1pay-cx-payments'); default: return __('That isn’t an XRP address. It starts with r.', '1pay-cx-payments'); } } /** 0x1234…abcd */ public static function short_address($address) { $address = (string) $address; return substr($address, 0, 6) . '…' . substr($address, -4); } // --------------------------------------------------------------------- // Catalogue // --------------------------------------------------------------------- /** Valid fiat rows from the catalogue, popular eight first; null when the catalogue is unavailable. */ private static function fiat_rows($catalogue) { if (!is_array($catalogue) || empty($catalogue['fiat']) || !is_array($catalogue['fiat'])) { return null; } $rows = array(); foreach ($catalogue['fiat'] as $row) { if (is_array($row) && isset($row['id']) && is_string($row['id']) && preg_match(self::FIAT_ID_RE, $row['id']) && !isset($rows[$row['id']])) { $rows[$row['id']] = $row; } } $ordered = array(); foreach (self::POPULAR as $id) { if (isset($rows[$id])) { $ordered[] = $rows[$id]; unset($rows[$id]); } } return array_merge($ordered, array_values($rows)); } /** id => row for the coins in the catalogue; null when it is unavailable (then every known coin is offered). */ private static function crypto_index($catalogue) { if (!is_array($catalogue) || empty($catalogue['crypto']) || !is_array($catalogue['crypto'])) { return null; } $index = array(); foreach ($catalogue['crypto'] as $row) { if (is_array($row) && isset($row['id']) && is_string($row['id']) && preg_match(self::CRYPTO_ID_RE, $row['id'])) { $index[$row['id']] = $row; } } return $index ? $index : null; } private static function method_name(array $row) { $id = (string) $row['id']; $name = isset($row['name']) && is_string($row['name']) ? trim(sanitize_text_field($row['name'])) : ''; if ('' === $name || 0 === strcasecmp($name, $id)) { return 'card' === $id ? __('Visa / Mastercard', '1pay-cx-payments') : ucfirst($id); } return function_exists('mb_substr') ? mb_substr($name, 0, 60) : substr($name, 0, 60); } /** "Worldwide", "US buyers", "SE, NO buyers", "31 countries", then "min $15" (from $5) and "buyer signs in". */ private static function method_sub(array $row) { $parts = array(); $codes = array(); $countries = array_key_exists('countries', $row) ? $row['countries'] : null; if (is_array($countries)) { foreach ($countries as $code) { if (is_string($code) && preg_match('/^[A-Za-z]{2}$/', $code)) { $codes[] = strtoupper($code); } } } if (null === $countries) { $parts[] = __('Worldwide', '1pay-cx-payments'); } elseif (!$codes) { $parts[] = __('Selected countries', '1pay-cx-payments'); } elseif (count($codes) <= 2) { /* translators: %s: country codes, for example "US" or "SE, NO" */ $parts[] = sprintf(__('%s buyers', '1pay-cx-payments'), implode(', ', $codes)); } else { /* translators: %d: number of countries */ $parts[] = sprintf(_n('%d country', '%d countries', count($codes), '1pay-cx-payments'), count($codes)); } $min = (isset($row['minAmountUsd']) && is_numeric($row['minAmountUsd'])) ? round((float) $row['minAmountUsd'], 2) : 0.0; if ($min >= 5) { /* translators: %s: minimum order in US dollars, for example "15" */ $parts[] = sprintf(__('min $%s', '1pay-cx-payments'), floor($min) === $min ? (string) (int) $min : number_format($min, 2, '.', '')); } if (!empty($row['login'])) { $parts[] = __('buyer signs in', '1pay-cx-payments'); } return implode(' · ', $parts); } private static function method_icon($id, $name) { if (in_array($id, self::ICON_PNG, true)) { return ''; } if (in_array($id, self::ICON_SVG, true)) { return ''; } $initial = strtoupper(substr((string) preg_replace('/[^A-Za-z0-9]/', '', $name), 0, 1)); return ''; } // --------------------------------------------------------------------- // Sections // --------------------------------------------------------------------- private static function header(array $c) { $p = $c['prefix']; $html = '
'; $html .= ''; $html .= '
' . esc_html__('High Risk Card & Crypto Payment Gateway', '1pay-cx-payments') . '
'; $html .= '
' . esc_html__('by 1pay.cx · instant payouts to your own wallet', '1pay-cx-payments') . '
'; $html .= '
'; $html .= self::support_link($c['urls']['support'], 'op-help', self::icon_svg('send') . esc_html__('Help on Telegram', '1pay-cx-payments')); $html .= '' . esc_html__('Wallet only · no signup', '1pay-cx-payments') . ''; $html .= '' . esc_html__('Account · connected', '1pay-cx-payments') . ''; $html .= '' . esc_html__('Account · not connected', '1pay-cx-payments') . ''; $html .= '' . esc_html__('Test mode', '1pay-cx-payments') . '' . ''; $html .= '' . esc_html__('Enabled', '1pay-cx-payments') . '' . ''; $html .= '
'; return $html; } private static function mode_cards(array $c) { $p = $c['prefix']; $wallet = 'wallet' === $c['mode']; $html = '

' . esc_html__('How do you want to get paid?', '1pay-cx-payments') . '

'; $html .= '

' . esc_html__('You can switch any time. Your settings below stay the same.', '1pay-cx-payments') . '

'; $html .= ''; $html .= ''; $html .= '
'; return $html; } private static function wallet_card(array $c) { $p = $c['prefix']; $state = '' === trim($c['evm']) ? 'empty' : (OnePayCx_Gateway::is_evm_address(trim($c['evm'])) ? 'valid' : 'invalid'); $html = '
'; $html .= '

' . esc_html__('Your payout wallet', '1pay-cx-payments') . '

'; $html .= '

' . esc_html__('Card payments and EVM coins are paid out to this address.', '1pay-cx-payments') . '

'; $html .= ''; $html .= ''; $html .= self::msg('warn', 'warn', esc_html__('Add your wallet address to start accepting payments.', '1pay-cx-payments'), 'm-empty'); $html .= self::msg('ok', 'ok', esc_html__('Valid EVM address. The same address works on every network below.', '1pay-cx-payments'), 'm-valid'); $html .= self::msg('bad', 'bad', esc_html__('That isn’t an EVM address. It should be 0x followed by 40 letters and numbers.', '1pay-cx-payments'), 'm-invalid'); $html .= '
'; foreach (array('Polygon', 'Base', 'Arbitrum', 'BNB Chain', 'Ethereum') as $network) { $html .= '' . esc_html($network) . ''; } $html .= '
'; $html .= '
' . esc_html__('Use a wallet you control', '1pay-cx-payments') . '' . esc_html__(', like MetaMask, Trust Wallet or Rabby, not an exchange deposit address. Card payouts usually arrive as USDC on Polygon; sometimes as another coin or stablecoin (for example USDT on BNB Chain, ETH or POL) on Polygon, Base, Ethereum or BNB Chain, always to this same address. Some exchanges won\'t credit those.', '1pay-cx-payments') . '
'; $html .= '
'; return $html; } private static function account_card(array $c) { $p = $c['prefix']; $mark = ''; $html = ''; return $html; } private static function tile(array $row, $on, $locked, $extra, $blocked_title, $prefix) { $id = (string) $row['id']; $name = self::method_name($row); $input = self::dom_id('op-m-', $id); $html = '
'; // Ticked = switched off. A method the 1pay.cx dashboard has switched off is shown off and not posted. $html .= ''; $html .= '
' . self::method_icon($id, $name); $html .= '
' . esc_html($name) . '
' . ($locked ? esc_html__('Switched off in your 1pay.cx dashboard', '1pay-cx-payments') : esc_html(self::method_sub($row))) . '
'; $html .= ''; $html .= '
'; return $html; } private static function methods_card(array $c, $evm_ok) { $p = $c['prefix']; $rows = self::fiat_rows($c['catalogue']); $html = '

' . esc_html__('Card and wallet payments', '1pay-cx-payments') . '

'; $html .= '

' . esc_html__('Buyers only see the options that work in their country and on their device. These pay out to your EVM wallet.', '1pay-cx-payments') . '' . '

'; $disabled = array_flip($c['fiat_disabled']); $shown = array(); if (null === $rows) { $html .= self::msg('warn', 'warn', esc_html__('The list of payment methods could not be loaded. Reload this page in a moment. Your choices are kept.', '1pay-cx-payments')); } else { $locked_ids = array_flip($c['locked_fiat']); $blocked = $c['wallet'] && !$evm_ok; $title = $blocked ? __('Add your wallet first', '1pay-cx-payments') : ''; $popular = 0; $html .= '
'; $on_count = 0; foreach ($rows as $row) { $id = (string) $row['id']; $locked = isset($locked_ids[$id]); $on = !$locked && !isset($disabled[$id]); $extra = !in_array($id, self::POPULAR, true); $on_count += $on ? 1 : 0; $popular += $extra ? 0 : 1; $shown[$id] = true; $html .= self::tile($row, $on, $locked, $extra, $title, $p); } $html .= '
'; $extras = count($rows) - $popular; $html .= '
'; if ($extras > 0) { $html .= ' · '; } $html .= '' . self::fmt( /* translators: 1: number of methods switched on, 2: number of methods */ __('%1$s of %2$s on', '1pay-cx-payments'), array('' . (int) $on_count . '', (int) count($rows)) ) . ' · ' . esc_html__('new methods we add are switched on automatically', '1pay-cx-payments') . '
'; } // Blocked ids that are not listed (catalogue unavailable, or a method that went away) are kept as they are. $html .= ''; foreach (array_keys($disabled) as $id) { if (!isset($shown[$id])) { $html .= ''; } } $html .= '
'; return $html; } /** The set of asset ids switched on, given what was saved (null = never narrowed) and the mode. */ private static function accepted_set(array $c, $index) { if (is_array($c['crypto_accepted'])) { return array_flip($c['crypto_accepted']); } $on = array(); if (!$c['wallet']) { // Existing and connected accounts: everything the platform offers is on until narrowed. $ids = null !== $index ? array_keys($index) : array(); if (null === $index) { foreach (self::networks() as $n) { foreach ($n['coins'] as $coin) { $ids[] = $coin[0]; } } foreach (self::coins() as $coin) { $ids = array_merge($ids, self::coin_assets($coin)); } } foreach ($ids as $id) { $on[$id] = true; } return $on; } // A fresh wallet store: the stablecoins on the cheap networks. Coins that need their own address start off. foreach (self::networks() as $n) { foreach ($n['coins'] as $coin) { if ($coin[2]) { $on[$coin[0]] = true; } } } return $on; } private static function pill($asset, $label, $icon, $on, $prefix, $blockable, $locked, $default_on = false) { $input = self::dom_id('op-c-', $asset); return ''; } private static function coin_icon_for_label($label, $fallback) { $map = array('USDC' => 'usdc', 'USDT' => 'usdt', 'ETH' => 'eth', 'POL' => 'pol', 'BNB' => 'bnb'); return isset($map[$label]) ? $map[$label] : $fallback; } private static function networks_html(array $c, $index, array $on, $evm_ok) { $locked = array_flip($c['locked_crypto']); $html = '
'; foreach (self::networks() as $n) { $pills = ''; $min = 0; foreach ($n['coins'] as $coin) { if (null !== $index && !isset($index[$coin[0]])) { continue; // not offered by the platform right now } if (null !== $index && isset($index[$coin[0]]['minPaymentUsd']) && is_numeric($index[$coin[0]]['minPaymentUsd'])) { $min = max($min, (float) $index[$coin[0]]['minPaymentUsd']); } $pills .= self::pill($coin[0], $coin[1], self::coin_icon_for_label($coin[1], $n['icon']), isset($on[$coin[0]]), $c['prefix'], true, isset($locked[$coin[0]])); } if ('' === $pills) { continue; } if (null === $index) { $min = $n['min']; // catalogue unavailable: the known floor } $meta = ''; if ($min > 0) { /* translators: %s: smallest order in US dollars, for example "50" */ $meta .= '' . esc_html(sprintf(__('Min order $%s', '1pay-cx-payments'), floor($min) === (float) $min ? (string) (int) $min : number_format($min, 2, '.', ''))) . ''; } $meta .= '' . esc_html(self::timing_label('batch' === $n['timing'] ? 'batch' : 'now')) . ''; $html .= '
' . esc_html($n['name']) . '
' . '
' . $pills . '
' . $meta . '
'; } return $html . '
'; } private static function coins_html(array $c, $index, array $on) { $p = $c['prefix']; $locked = array_flip($c['locked_crypto']); $html = '
'; foreach (self::coins() as $coin) { $assets = array(); foreach (self::coin_assets($coin) as $asset) { if (null === $index || isset($index[$asset])) { $assets[] = $asset; } } if (!$assets) { continue; } $address = isset($c['addresses'][$coin['key']]) ? (string) $c['addresses'][$coin['key']] : ''; $state = self::address_state($coin, $address); $any_on = false; foreach ($assets as $asset) { $any_on = $any_on || isset($on[$asset]); } $is_locked = true; foreach ($assets as $asset) { $is_locked = $is_locked && isset($locked[$asset]); } $has_subs = (bool) $coin['subs']; $input = self::dom_id('op-coin-', $coin['id']); $html .= '
'; // One real checkbox per coin: the coin itself, or (Solana, TRON) an unnamed master switch for the token pills. if ($has_subs) { $html .= ''; } else { $html .= ''; } // data-saved: 1pay.cx holds an address for this coin. It can be replaced but never removed, so a blank field // is not "no address" (see the script's "kept" state). $html .= '
'; $html .= '
' . esc_attr($coin['tick']) . ''; $html .= '
' . esc_html($coin['name']); if ($has_subs) { $ticks = array(); foreach ($coin['subs'] as $sub) { $ticks[] = $sub[1]; } $html .= ' (' . esc_html(implode(', ', $ticks)) . ')'; } $html .= '
' . esc_html(self::timing_label($coin['timing'])) . '
'; $html .= '' . esc_html__('Accepted', '1pay-cx-payments') . '' . '' . esc_html__('Needs an address', '1pay-cx-payments') . '' . '' . esc_html__('Check the address', '1pay-cx-payments') . ''; $html .= '
'; $html .= '
'; if ($has_subs) { $html .= '
' . esc_html__('Accept:', '1pay-cx-payments') . ''; foreach ($coin['subs'] as $sub) { if (!in_array($sub[0], $assets, true)) { continue; } $html .= self::pill($sub[0], $sub[1], self::coin_icon_for_label($sub[1], $coin['icon']), isset($on[$sub[0]]), $p, false, isset($locked[$sub[0]]), $sub[2]); } $html .= '
'; } // Wallet mode: the address for this coin. $field = self::dom_id('onepaycx-addr-', $coin['id']); $html .= '
'; $html .= ''; $placeholder = 'sol' === $coin['id'] ? __('Your Solana address', '1pay-cx-payments') : $coin['ph']; $html .= ''; $html .= self::msg('warn', 'warn', esc_html(sprintf( /* translators: 1: coin ticker, 2: coin name */ __('Buyers can’t pay in %1$s until you add your %2$s address.', '1pay-cx-payments'), $coin['tick'], $coin['name'] )), 'a-empty'); $html .= self::msg('ok', 'ok', esc_html(sprintf( /* translators: 1: coin name, 2: when payouts are sent, for example "Sent right away" */ __('Valid %1$s address. %2$s.', '1pay-cx-payments'), $coin['name'], self::timing_label($coin['timing']) )), 'a-valid'); $html .= self::msg('bad', 'bad', esc_html(self::bad_address_message($coin['id'])), 'a-invalid'); if ('' !== trim($address)) { $html .= self::msg('muted', '', esc_html(sprintf( /* translators: %s: coin name, for example Bitcoin */ __('To stop accepting %s, switch it off. Addresses can be replaced, not removed.', '1pay-cx-payments'), $coin['name'] )), 'a-saved'); } if ('xrp' === $coin['id']) { $html .= self::msg('muted', '', esc_html__('Use your own XRP wallet. Exchange addresses that need a destination tag won’t work.', '1pay-cx-payments')); } $html .= '
'; // Account mode: payouts follow the dashboard. $html .= ''; $html .= '
'; } return $html . '
'; } private static function crypto_card(array $c, $evm_ok) { $p = $c['prefix']; $index = self::crypto_index($c['catalogue']); $on = self::accepted_set($c, $index); $html = '

' . esc_html__('Crypto payments', '1pay-cx-payments') . '

'; $html .= '

' . esc_html__('Buyers pay from their own crypto wallet. Each payment is sent on to you automatically.', '1pay-cx-payments') . '' . '

'; $html .= '
' . esc_html__('Paid to your EVM wallet', '1pay-cx-payments') . ' ' . '' . '' . esc_html__('add your wallet above first', '1pay-cx-payments') . '' . '' . self::fmt( /* translators: %s: the owner's shortened wallet address */ __('to %s', '1pay-cx-payments'), array('' . esc_html($evm_ok ? self::short_address(trim($c['evm'])) : '') . '') ) . '
'; $html .= self::networks_html($c, $index, $on, $evm_ok); $html .= '
' . esc_html__('Needs its own wallet address', '1pay-cx-payments') . ' ' . '' . esc_html__('turn a coin on, then paste your address for it', '1pay-cx-payments') . '
'; $html .= self::coins_html($c, $index, $on); // Always post the list (an empty entry among them), and keep coins this page does not list. $html .= ''; if (is_array($c['crypto_accepted'])) { $known = array(); foreach (self::networks() as $n) { foreach ($n['coins'] as $coin) { $known[$coin[0]] = true; } } foreach (self::coins() as $coin) { foreach (self::coin_assets($coin) as $asset) { $known[$asset] = true; } } foreach ($c['crypto_accepted'] as $asset) { if (!isset($known[$asset]) || (null !== $index && !isset($index[$asset]))) { $html .= ''; } } } $html .= '
'; return $html; } private static function checkout_card(array $c) { $p = $c['prefix']; $html = '

' . esc_html__('What buyers see at checkout', '1pay-cx-payments') . '

'; $html .= '
' . '
'; $html .= '
' . '
'; $html .= '
'; return $html; } private static function cta(array $c) { $html = '
' . esc_html__('Want swaps, statistics or a custom API?', '1pay-cx-payments') . '
'; $html .= '
' . esc_html__('Create a free 1pay.cx account. This store\'s sales history comes with you, and your settings stay as they are.', '1pay-cx-payments') . '
'; if (!empty($c['registered'])) { $html .= '' . esc_html__('Create free account', '1pay-cx-payments') . ''; } else { $html .= '' . esc_html__('Create free account', '1pay-cx-payments') . ''; } return $html . '
'; } /** Where to ask: wallet-only stores have no email or dashboard, so this is their way to reach us. */ private static function support(array $c) { $html = '
' . self::icon_svg('send') . ''; $html .= '
' . esc_html__('Questions or stuck?', '1pay-cx-payments') . '
'; $html .= '
' . esc_html__('Ask the 1pay.cx team in our Telegram channel.', '1pay-cx-payments') . '
'; return $html . self::support_link($c['urls']['support'], 'op-btn-outline', esc_html__('Open Telegram', '1pay-cx-payments')) . '
'; } // --------------------------------------------------------------------- // The whole panel // --------------------------------------------------------------------- /** The panel markup for $c (see OnePayCx_Gateway::panel_context()). */ public static function render(array $c) { $evm = trim((string) $c['evm']); $evm_ok = OnePayCx_Gateway::is_evm_address($evm); $classes = array('onepaycx-panel', $c['wallet'] ? 'is-wallet' : 'is-account'); if ($c['connected']) { $classes[] = 'is-connected'; } if (!$evm_ok) { $classes[] = 'evm-missing'; } $html = '

' . esc_html__('1pay.cx', '1pay-cx-payments') . '

'; $html .= '
'; $html .= self::header($c); $html .= self::mode_cards($c); $html .= self::wallet_card($c); $html .= self::account_card($c); $html .= self::methods_card($c, $evm_ok); $html .= self::crypto_card($c, $evm_ok); $html .= self::checkout_card($c); $html .= self::cta($c); $html .= self::support($c); $html .= '
' . esc_html__('Fees: cards 2.9% plus the card processor\'s 1–5% (about 4–8% all-in). Crypto 1% plus the network fee.', '1pay-cx-payments') . '
'; $html .= '
'; $html .= '

' . self::fmt( /* translators: 1: link to the Terms, 2: link to the Acceptable Use Policy */ __('By saving you agree to the %1$s and the %2$s.', '1pay-cx-payments'), array( '' . esc_html__('Terms', '1pay-cx-payments') . '', '' . esc_html__('Acceptable Use Policy', '1pay-cx-payments') . '', ) ) . '

'; $html .= '
'; return $html; } }