| 1 |
<?php |
| 2 |
/** |
| 3 |
* Payment fields for seQura payment gateway. |
| 4 |
* |
| 5 |
* @package SeQura/WC |
| 6 |
* @var string $args The arguments. Must contain: |
| 7 |
* - description: string |
| 8 |
* - payment_methods: Payment_Method_Option[] |
| 9 |
* - cart_total: int The cart total in cents. |
| 10 |
*/ |
| 11 |
|
| 12 |
use SeQura\WC\Dto\Payment_Method_Option; |
| 13 |
|
| 14 |
defined( 'WPINC' ) || die; |
| 15 |
if ( ! isset( $args['description'], $args['payment_methods'], $args['cart_total'] ) ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
?> |
| 19 |
<span class="sequra-block__description"><?php echo wp_kses_post( wpautop( wptexturize( $args['description'] ) ) ); ?></span> |
| 20 |
<?php |
| 21 |
/** |
| 22 |
* Payment methods |
| 23 |
* |
| 24 |
* @var Payment_Method_Option $pm |
| 25 |
*/ |
| 26 |
foreach ( (array) $args['payment_methods'] as $key => $pm ) : |
| 27 |
if ( ! $pm instanceof Payment_Method_Option || ! $pm->is_valid() ) { |
| 28 |
continue; |
| 29 |
} |
| 30 |
|
| 31 |
$input_id = "sequra_payment_method_{$key}"; |
| 32 |
$more_info = ''; |
| 33 |
if ( $pm->should_show_more_info() ) { |
| 34 |
$more_info = sprintf( |
| 35 |
'<span class="sequra-educational-popup sequra_more_info" data-amount="%s" data-product="%s" data-campaign="%s" rel="sequra_invoice_popup_checkout" title="%s">%s</span>', |
| 36 |
esc_attr( (string) $args['cart_total'] ), |
| 37 |
esc_attr( (string) $pm->product ), |
| 38 |
esc_attr( (string) ( $pm->campaign ?? '' ) ), |
| 39 |
esc_attr__( 'More information', 'sequra' ), |
| 40 |
esc_html__( '+info', 'sequra' ) |
| 41 |
); |
| 42 |
} |
| 43 |
?> |
| 44 |
<div class="sequra-payment-method"> |
| 45 |
<input type="radio" name="sequra_payment_method_data" value="<?php echo esc_attr( $pm->encode_data() ); ?>" id="<?php echo esc_attr( $input_id ); ?>" class="sequra-payment-method__input wc-block-components-radio-control__input" /> |
| 46 |
<label for="<?php echo esc_attr( $input_id ); ?>"> |
| 47 |
<div class="sequra-payment-method__description"> |
| 48 |
<span class="sequra-payment-method__name" style="width:100%"><?php echo esc_html( (string) empty( $pm->long_title ) ? $pm->title : $pm->long_title ); ?></span> |
| 49 |
<span class="sequra-payment-method__claim" style="width:100%"><?php echo esc_html( (string) ( $pm->claim ?? '' ) ); ?> <?php echo wp_kses_post( $more_info ); ?></span> |
| 50 |
<?php if ( $pm->should_show_cost_description() ) : ?> |
| 51 |
<span class="sequra-payment-method__cost-desc" style="width:100%"><?php echo esc_html( (string) $pm->cost_description ); ?></span> |
| 52 |
<?php endif; ?> |
| 53 |
</div> |
| 54 |
<?php if ( $pm->icon ) : ?> |
| 55 |
<img src="data:image/svg+xml;base64,<?php echo esc_attr( base64_encode( (string) ( $pm->icon ?? '' ) ) ); ?>" height="40px" loading="lazy" alt="<?php echo esc_attr( $pm->title ); ?>" class="sequra-payment-method__icon" /> |
| 56 |
<?php endif; ?> |
| 57 |
</label> |
| 58 |
</div> |
| 59 |
<?php endforeach; ?> |