<div class="cart-box-row payment-item payment-item-{$payment.class.class|lower}">

   <label for="pay{$id}" class="delivery-content custom-radio custom-control">
      <input type="radio" name="payment_id" value="{$id}" id="pay{$id}" class="custom-control-input"
             {if $body.payment_id == $id or ($tpl_vars.delivery_collapsible and $payments|count == 1)}checked{/if}>
      <span class="custom-control-indicator"></span>
       {if $payment.photo}
          <span class="img">{photo photo=$payment.photo}</span>
       {/if}

      <span class="name">
          {$payment.name}
         <span data-reload="payment_exception_{$id}">
             {if $payment.exception}
                <span class="subtitle">{$payment.exception->getShortMessage()}</span>
             {/if}
         </span>
      </span>
      <span class="price">
         <span data-reload="payment_price_{$id}">
             {$paymentPrice = $view->getPaymentPrice($id)}
             {if $paymentPrice != null}
                 {if $paymentPrice.value_with_vat->isPositive()}
                     {$paymentPrice.value_with_vat|format_price}
                 {else}
                     {t}zdarma{/t}
                 {/if}
             {/if}
         </span>
      </span>
   </label>
   {$paypalPayment = $payment.class->getPayment()}
    {if $payment.cart_description}
       <div class="payment_description" id="payment_description_{$payment.id}" style="display:none">
           {$payment.cart_description nofilter}
           <div id="paypalplus" style="width: 100%"></div>
       </div>
    {/if}
</div>
<script type="application/javascript">
   wpj.onReady.push(function () {
      var ppp = PAYPAL.apps.PPP({
         "approvalUrl": "{$paypalPayment->getApprovalLink() nofilter}",
         "placeholder": "paypalplus",
         "showLoadingIndicator": true,
         "mode": "{$payment.class.config.mode}",
         "country": "{$ctrl.active_country}",
         "language": "{$ctrl.active_language_code}",
         "buttonLocation": "outside",
         "onContinue": function () {
            document.getElementsByName("OrderNext")[0].onclick = null;
            document.getElementsByName("OrderNext")[0].click();
         }
      });

      document.getElementsByName("OrderNext")[0].onclick = function (e) {
      if ($(".payment-item-paypalplus")[0].classList.contains('selected')){
         e.preventDefault();
         ppp.doContinue();
         return false;
      }
   };
   });

</script>
