Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 24
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * Template displaying a table with the Bitcoin address, QR code, amount required, amount received, status, and the time
4 * last checked. CSS classes on each allow for JS to target the data for copying to the clipboard.
5 *
6 * @see \BrianHenryIE\WP_Bitcoin_Gateway\API_Interface::get_order_details()
7 *
8 * @var array{template_name:string, template_path:string, located:string, args:array} $action_args
9 * @var array<string, mixed> $args Associative array containing the result of `API_Interface::get_order_details()`, extracted into these variables:
10 *
11 * @var string $btc_logo_url // TODO
12 * @var string $payment_status 'Awaiting Payment'|'Partially Paid'|'Paid'.
13 * @var string $btc_address Destination payment address.
14 * @var string $btc_total Order total in BTC.
15 * @var string $btc_total_formatted Order total prefixed with "฿".
16 * @var string $btc_exchange_rate_formatted The Bitcoin exchange rate with friendly thousand separators.
17 * @var string $btc_amount_received Amount received at the destination address so far.
18 * @var string $btc_amount_received_formatted Amount received prefixed with "฿".
19 * @var string $last_checked_time_formatted The last time a blockchain service was queried for updates to the payment address.
20 *
21 * @package    brianhenryie/bh-wp-bitcoin-gateway
22 */
23
24use BrianHenryIE\WP_Bitcoin_Gateway\chillerlan\QRCode\QRCode;
25
26$bitcoin_href_address = 'bitcoin:' . $btc_address . '?amount=' . $btc_total;
27
28$btc_logo_url = BH_WP_BITCOIN_GATEWAY_URL . '/assets/bitcoin.png';
29?>
30
31<div class="bh-wp-bitcoin-gateway-details">
32
33    <?php // For scrolling to? ?>
34    <a id="bh_wp_bitcoin_gateway"></a>
35
36    <div class="bh_wp_bitcoin_gateway_logo_qr">
37    <img alt="Bitcoin logo" class="bh_wp_bitcoin_gateway_logo" src="<?php echo esc_attr( $btc_logo_url ); ?>">
38
39    <a href="<?php echo esc_url( $bitcoin_href_address, array( 'bitcoin' ) ); ?>">
40        <img src="<?php echo esc_attr( ( new QRCode() )->render( $bitcoin_href_address ) ); ?>" alt="<?php esc_attr_e( 'Payment QR Code', 'bh-wp-bitcoin-gateway' ); ?>" />
41    </a>
42    </div>
43
44    <table>
45        <tr>
46            <td><span class=""><?php esc_html_e( 'Payment Address:', 'bh-wp-bitcoin-gateway' ); ?></span></td>
47            <td><span class="bh_wp_bitcoin_gateway_address"><?php echo esc_html( $btc_address ); ?></span></td>
48        </tr>
49        <tr>
50            <td><span class=""><?php esc_html_e( 'Payment Total:', 'bh-wp-bitcoin-gateway' ); ?></span></td>
51            <td><span class="bh_wp_bitcoin_gateway_total"><?php echo esc_html( $btc_total_formatted ); ?></span></td>
52        </tr>
53        <tr>
54            <td><span class=""><?php esc_html_e( 'Amount Received:', 'bh-wp-bitcoin-gateway' ); ?></span></td>
55            <td><span class="bh_wp_bitcoin_gateway_amount_received bh_wp_bitcoin_gateway_updatable"><?php echo esc_html( $btc_amount_received_formatted ); ?></span></td>
56        </tr>
57        <tr>
58            <td><span class=""><?php esc_html_e( 'Status:', 'bh-wp-bitcoin-gateway' ); ?></span></td>
59            <td><span class="bh_wp_bitcoin_gateway_status bh_wp_bitcoin_gateway_updatable">
60            <?php
61            echo esc_html( $payment_status );
62            ?>
63            </span></td>
64        </tr>
65        <tr>
66            <td><span class=""><?php esc_html_e( 'Last Checked:', 'bh-wp-bitcoin-gateway' ); ?></span></td>
67            <td><span class="bh_wp_bitcoin_gateway_last_checked_time bh_wp_bitcoin_gateway_updatable">
68                <?php echo esc_html( $last_checked_time_formatted ); ?></span>
69            </td>
70        </tr>
71
72    </table>
73
74    <?php do_action( 'bh_wp_bitcoin_gateway_template_bitcoin_unpaid_after_table', $args['template'], $args ); ?>
75
76    <p>Exchange rate at time of order: 1 BTC = <?php echo wp_kses_post( $btc_exchange_rate_formatted ); ?></p>
77
78</div>
79