
<?php $__env->startSection('content2'); ?>

                 <div class="nk-content">
                        <div class="container-fluid">
                            <div class="nk-content-inner">
                    <br>
                        <div class="nk-block-head nk-block-head-xs text-center">
                            <h5 class="nk-block-title">Confirm Package</h5>
                            <div class="nk-block-text">
                                <div class="caption-text">You are about to make payment of <strong><?php echo e($basic->currency_sym); ?><?php echo e(number_format(App\Plan::whereId(Auth::user()->plan_id)->first()->price, $basic->decimal)); ?></strong>
                                  for the purchase of <?php echo e($pack->name); ?> Network Package<br><small> You will earn <?php echo e($pack->discount); ?>% for every purchase</small></div>

                            </div>
                        </div>
                        <div class="nk-block">
                            <div class="buysell-overview">
                                <ul class="buysell-overview-list">
                                    <li class="buysell-overview-item">
                                        <span class="pm-title">Package</span><span class="pm-currency"><em class="icon ni ni-$gate->val7}}"></em> <span>

                                        <?php echo e($pack->name); ?>.
                                         </span></span>
                                    </li>
                                    <li class="buysell-overview-item"><span class="pm-title">Price</span><span class="pm-currency"><?php echo e($basic->currency_sym); ?><?php echo e(number_format($pack->price, $basic->decimal)); ?></span></li>
                                </ul>

                            </div>





                           <!-- <div class="buysell-field form-action text-center">

                              <div class="nk-block nk-block-lg">
                                <div class="nk-block-head">
                                    <h5 class="nk-block-title">Package Matrix Details</h5>
                                </div>
                                <div class="card card-bordered">
                                    <table class="table table-iv-tnx">
                                        <thead class="thead-light">
                                            <tr>
                                                <th class="tb-col-type"><span class="overline-title">Level</span></th>
                                                <th class="tb-col-date"><span class="overline-title">Downlines</span></th>
                                                <th class="tb-col-date"><span class="overline-title">Commission</span></th>
                                                <th class="tb-col-time tb-col-end"><span class="overline-title">Total</span></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php $__currentLoopData = $plans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php $totalreturn = 0; ?>
                                        <?php $totalusers = 0; ?>
                                        <?php $__currentLoopData = $data->plan_level; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $lv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($key+1 <= $basic->matrix_height): ?>
                                            <tr>
                                                <td class="tb-col-type"><span class="sub-text"><?php echo e(app('translator')->getFromJson('Level'.$lv->level.' ')); ?></span></td>
                                                <td class="tb-col-date"><span class="sub-text"><?php echo e(pow($basic->matrix_width,$key+1)); ?> Users</span></td>
                                                <td class="tb-col-date"><span class="sub-text"><?php echo e($basic->currency_sym); ?> <?php echo e(number_format($lv->amount,2)); ?></span></td>
                                                <td class="tb-col-time tb-col-end"><span class="lead-text text-primary"> <?php echo e($basic->currency_sym); ?><?php $ret = $lv->amount*pow($basic->matrix_width,$key+1) ?> <?php echo e(number_format($ret, 2)); ?></span></td>
                                            </tr>
                                        <?php $totalreturn += $lv->amount*pow($basic->matrix_width,$key+1); ?>
                                        <?php $totalusers += 1*pow($basic->matrix_width,$key+1); ?>
                                        <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                                        </tbody>
                                    </table>


                                     <table class="table table-iv-tnx">
                                        <thead class="thead-light">
                                            <tr>
                                                <th class="tb-col-type"><span class="overline-title">Total Downlines</span></th>
                                                <th class="tb-col-date"><span class="overline-title">Total Earnings</span></th>
                                                <th class="tb-col-time tb-col-end"><span class="overline-title">Percentage Earning</span></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td class="tb-col-type"><span class="sub-text"><?php echo e($totalusers); ?> Downlines</span></td>
                                                <td class="tb-col-date"><span class="sub-text text-primary"> <?php echo e($basic->currency_sym); ?> <?php echo e(number_format($totalreturn,2)); ?></span></td>
                                                <td class="tb-col-time tb-col-end"><span class="lead-text text-info"><?php echo e(intval($totalreturn/$data->price*100)); ?>%</span></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div><!-- .card -->
                          


<br>
<div class="pay-buttons"><div class="pay-button">

<?php if($gate->id == 100): ?>
<?php $__env->startSection('scripts'); ?>
<script src="https://api.ravepay.co/flwv3-pug/getpaidx/api/flwpbf-inline.js"></script>

    <script>
			const API_publicKey = "<?php echo e($gate->val1); ?>";
			function payWithRave() {
			var x = getpaidSetup({
			PBFPubKey: API_publicKey,
			customer_email: "<?php echo e(Auth::user()->email); ?>",
			amount: "<?php echo e(round(App\Plan::whereId(Auth::user()->plan_id)->first()->price, 2)); ?>",
			customer_phone: "<?php echo e(Auth::user()->mobile); ?>",
			currency: "NGN",
			txref: "rave-123456",
		    payment_options: "card",
			meta: [{
			metaname: "flightID",
			metavalue: "AP1234"
			}],
			onclose: function() {},
			callback: function(response) {
			var txref = response.tx.txRef; // collect txRef returned and pass to a 					server page to complete status check.
			console.log("This is the response returned after a charge", response);
			if (
			response.tx.chargeResponseCode == "00" ||
			response.tx.chargeResponseCode == "0"
			) {

			  swal("Payment successful",{

                closeOnClickOutside: false,
                title: 'Successful!',
                     icon: 'success',
                }).then(function() {
                   window.location='javascript: submitform()';
                });


			} else {
			// redirect to a failure page.
			}

			x.close(); // use this to close the modal immediately after payment.
			}
			});
			}
			</script>
<?php $__env->stopSection(); ?>

<badge  onClick="payWithRave()" class="btn btn-primary btn-lg">Buy Plan With Flutterwave<em class="ti ti-wallet"></em></badge>
<?php elseif($gate->id == 107): ?>

<badge onclick="payWithPaystack()" class="btn btn-primary btn-lg">Buy Plan With Paystack <em class="ti ti-wallet"></em></badge>

<?php $__env->startSection('scripts'); ?>
 <script>
						function payWithPaystack(){
						var handler = PaystackPop.setup({
						key: "<?php echo e($gate->val1); ?>",
						email: "<?php echo e(Auth::user()->email); ?>",
						amount: "<?php echo e(round(App\Plan::whereId(Auth::user()->plan_id)->first()->price, 2)*100); ?>",
						currency: "NGN",
						ref: ''+Math.floor((Math.random() * 1000000000) + 1), // generates a pseudo-unique reference. Please replace with a reference you generated. Or remove the line entirely so our API will generate one for you
						firstname: '',
						lastname: '',
						// label: "Optional string that replaces customer email"
						metadata: {
						custom_fields: [
						{
						display_name: "Mobile Number",
						variable_name: "",
						value: "+2348012345678"
						}
						]
						},
						callback: function(response){
						alert('Payment successful. transaction reference number is ' + response.reference);
						 document.getElementById("code").value = response.reference;
						window.location='javascript: submitform()';
						},
						onClose: function(){
						alert('window closed');
						}
						});
						handler.openIframe();
						}
						</script>



<script src="https://js.paystack.co/v1/inline.js"></script>
<?php $__env->stopSection(); ?>
                </div>
                </div>
                </div>
<?php endif; ?></div>
<br>
 <div class="sub-text-sm center">* Payment gateway may charge you . <a href="#">transaction fee</a></div>                           </div>
                        </div>
                    </div>
                </div>

 <script type="text/javascript">
			function submitform()
			{
			document.forms["myform"].submit();
			}
			</script>
			<form id="myform"  action="<?php echo e(route('activate-plan-pay')); ?>" method="post">
			<?php echo e(csrf_field()); ?>

			<input type="hidden" name="plan" value="<?php echo e($pack->id); ?>" />
			<input type="hidden" name="amount" value="<?php echo e($pack->price); ?>" />
			<input type="hidden" name="code" id="code" />
			</form>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('include.dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), array('__data', '__path')))->render(); ?>