@model NominativeServiceCommand

@if (Model!=null && Model.PaymentId!=null) {
   
    @if (Model.Regularisation.Executor.Id == User.GetUserId()) {
        <text>
           Votre paiment
        </text>
    } else {
        <text>
           Le paiment de @Html.DisplayFor(m=>m.Regularisation.Executor.UserName) 
        </text>
    }
    <text> : 

    </text>
      <label>@Model.GetIsAcquitted()
      <input type="checkbox" checked="@Model.GetIsAcquitted()" disabled/> 
      <a asp-controller="Manage" asp-action="PaymentInfo" asp-route-id="@Model.Regularisation.CreationToken">@Model.Regularisation.CreationToken</a>
      </label>

} 

@if (!Model.GetIsAcquitted()) {
<div id="paypalzone"></div>
<script>
var CREATE_PAYMENT_URL = '@ViewBag.CreatePaymentUrl';
var EXECUTE_PAYMENT_URL = '@ViewBag.ExecutePaymentUrl';
var PAYPAL_ENV = '@ViewBag.PayPalSettings.Mode';
var MERCH_ID = '@ViewBag.PayPalSettings.MERCH_ID';


paypal.checkout.setup(MERCH_ID, {
  environment: PAYPAL_ENV,
  container: '#paypalzone',
  click: function () {
    paypal.checkout.initXO();
    var action = $.post(CREATE_PAYMENT_URL)
    .done(function (data) {
      paypal.checkout.startFlow(data.token)
    })
    .fail(function () {
      paypal.checkout.closeFlow()
    })
  }
});

</script>
}
