<?php
/**
 * Gratify Pay Checkout Instalments Display
 * @var WC_Gratify_Pay_Gateway $this
 */

# Process Region-based Assets $region_assets=include 'assets.php';

$checkout_page_cta=$region_assets['checkout_page_cta'];
$checkout_page_first_step=$region_assets['checkout_page_first_step'];
$checkout_page_footer=$region_assets['checkout_page_footer'];


if ($this->settings['testmode'] !='production') {
    ?><p class="gratifypay-test-mode-warning-text"><?php _e('TEST MODE ENABLED', 'gratify-pay');
    ?></p><?php
}

$order_button_text= !empty($this->order_button_text) ? $this->order_button_text : 'Place order';


?><?php // TODO: Move this to server side API call
// Absorb rounding error into first payment
$gratifyPayCartTotal=WC()->cart->get_total('float');
$schedule=$this->get_merchant_payment_schedule($gratifyPayCartTotal);

?>


<div id="gratify-checkout"></div>
<script>
       jQuery(function ($) {
            $(document).ready(function() {   
            const data = <?= json_encode($schedule); ?>;
            console.log(data)
            Gratify.setSchedule({formatted: data.schedule, meta: data.meta});
            Gratify.render('#gratify-checkout')
         })
    })    
    
</script>

