Use NVP/SOAP Api from PayPal
This commit is contained in:
parent
ec6de91cf0
commit
e415e78aaa
33 changed files with 2382 additions and 631 deletions
|
|
@ -1,4 +1,7 @@
|
|||
@model HairCutQuery
|
||||
@section header {
|
||||
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
|
||||
}
|
||||
|
||||
@{
|
||||
ViewData["Title"] = @SR["Annuler votre commande"];
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
@{
|
||||
ViewData["Title"] = SR["Command confirmation"]+" "+ViewBag.Activity.Name;
|
||||
}
|
||||
@section header {
|
||||
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
|
||||
}
|
||||
|
||||
<h2>@ViewData["Title"]</h2>
|
||||
<div class="form-horizontal">
|
||||
<h4>@SR["Your book query"]</h4>
|
||||
|
|
@ -84,10 +88,9 @@
|
|||
|
||||
</environment>
|
||||
|
||||
|
||||
<dt>@Html.DisplayNameFor(m=>m.Regularisation)</dt>
|
||||
<dd>@Html.DisplayFor(m=>m.Regularisation,new {
|
||||
PaymentUrl = "/api/haircut/createpayment/"+Model.Id.ToString(),
|
||||
SuccessUrl = "/HairCutCommand/Details/"+Model.Id.ToString() })</dd>
|
||||
<dt>@Html.DisplayNameFor(m=>m.Regularisation)</dt>
|
||||
<dd> @Component.Invoke("PayPalButton", Model, "haircut", "HairCutCommand" )
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
@model HairCutQuery
|
||||
@section header {
|
||||
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
|
||||
}
|
||||
|
||||
@{
|
||||
ViewData["Title"] = @SR["Le detail de votre commande de prestation en coiffure à domicile"];
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@
|
|||
<a asp-action="CGV" class="btn btn-link">Conditions générales de vente</a> liées à cette commande de service.</label>
|
||||
</div>
|
||||
<input asp-for="ClientId" type="hidden" />
|
||||
|
||||
<img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png" alt="PayPal Acceptance">
|
||||
|
||||
<input type="submit" class="btn btn-success btn-submit" value="@SR["Validez ce choix, et prendre rendez-vous"] avec @Model.PerformerProfile.Performer.UserName"/>
|
||||
<environment names="Development">
|
||||
|
|
|
|||
8
Yavsc/Views/Manage/PaymentError.cshtml
Normal file
8
Yavsc/Views/Manage/PaymentError.cshtml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
|
||||
<dl>
|
||||
<dt> Le paiment @ViewData["id"] a échoué
|
||||
</dt>
|
||||
<dd> @ViewData["error"]
|
||||
</dd>
|
||||
</dl>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
@using PayPal.Api
|
||||
@model Payment
|
||||
|
||||
<dl>
|
||||
<dt> État du paiment
|
||||
</dt>
|
||||
<dd> @SR[Model.state] @Model.failure_reason
|
||||
</dd>
|
||||
<dt>
|
||||
</dt>
|
||||
<dd>@Model.payment_instruction
|
||||
</dd>
|
||||
</dl>
|
||||
@if (Model.state=="created") {
|
||||
<a href="@Model.GetApprovalUrl()">Autoriser le paiement</a>
|
||||
}
|
||||
@{ var refundUrl = Model.GetHateoasLink("refund"); }
|
||||
@if (refundUrl!=null) {
|
||||
<a href="@refundUrl">Rembourser ce paiement</a>
|
||||
}
|
||||
43
Yavsc/Views/Shared/Components/PayPalButton/Default.cshtml
Normal file
43
Yavsc/Views/Shared/Components/PayPalButton/Default.cshtml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
@model NominativeServiceCommand
|
||||
@inject IOptions<PayPalSettings> PayPalSettings
|
||||
@Model.PaymentId
|
||||
@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><a asp-controller="Manage" asp-action="PaymentInfo" asp-route-id="@Model.Regularisation.PaypalPaymentId">@Model.Regularisation.PaypalPaymentId</a>
|
||||
|
||||
} else {
|
||||
<div id="paypalzone"></div>
|
||||
<script>
|
||||
var CREATE_PAYMENT_URL = '@ViewBag.CreatePaymentUrl';
|
||||
var EXECUTE_PAYMENT_URL = '@ViewBag.ExecutePaymentUrl';
|
||||
var PAYPAL_ENV = '@PayPalSettings.Value.Mode';
|
||||
var APP_ID = '@PayPalSettings.Value.ApplicationId';
|
||||
|
||||
|
||||
paypal.checkout.setup(APP_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>
|
||||
}
|
||||
|
|
@ -21,7 +21,8 @@
|
|||
<dd>@Html.DisplayFor(m=>m.AdditionalInfo)
|
||||
</dd>
|
||||
<dt>@Html.DisplayNameFor(m=>m.Regularisation)</dt>
|
||||
<dd>@Html.DisplayFor(m=>m.Regularisation)
|
||||
<dd>
|
||||
@Component.Invoke("PayPalButton", Model, "haircut", "HairCutCommand" )
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
@model PaypalPayment
|
||||
@inject IOptions<PayPalSettings> PayPalSettings
|
||||
@if (Model!=null && Model.PaypalPaymentId!=null) {
|
||||
|
||||
@if (Model.Executor.Id == User.GetUserId()) {
|
||||
<text>
|
||||
Votre paiment
|
||||
</text>
|
||||
} else {
|
||||
<text>
|
||||
Le paiment de @Html.DisplayFor(m=>m.Executor.UserName)
|
||||
</text>
|
||||
}
|
||||
<text> :
|
||||
</text><a asp-controller="Manage" asp-action="PaymentInfo" asp-route-id="@Model.PaypalPaymentId">@Model.PaypalPaymentId</a>
|
||||
|
||||
} else {
|
||||
|
||||
<div id="paypal-button"></div>
|
||||
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
|
||||
<script>
|
||||
var CREATE_PAYMENT_URL = '@ViewBag.CreatePaymentUrl';
|
||||
var EXECUTE_PAYMENT_URL = '@ViewBag.ExecutePaymentUrl';
|
||||
var PAYPAL_ENV = '@PayPalSettings.Value.Mode';
|
||||
|
||||
paypal.Button.render({
|
||||
|
||||
env: PAYPAL_ENV, // 'production', Optional: specify 'sandbox' environment
|
||||
commit: true,
|
||||
payment: function(resolve, reject) {
|
||||
|
||||
return paypal.request.post(CREATE_PAYMENT_URL)
|
||||
.then(function(data) { resolve(data.id); })
|
||||
.catch(function(err) { reject(err); });
|
||||
},
|
||||
|
||||
onAuthorize: function(data) {
|
||||
|
||||
// Note: you can display a confirmation page before executing
|
||||
|
||||
return paypal.request.post(EXECUTE_PAYMENT_URL,
|
||||
{ paymentID: data.paymentID, payerID: data.payerID })
|
||||
|
||||
.then(function(data) {
|
||||
document.location = '@ViewBag.Urls.Details';
|
||||
/* Go to a success page */ })
|
||||
.catch(function(err) {
|
||||
document.location = '/Manage/PaymentInfo/'+data.paymentID;
|
||||
/* Go to an error page */ });
|
||||
}
|
||||
|
||||
}, '#paypal-button');
|
||||
</script>
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue