Use NVP/SOAP Api from PayPal
This commit is contained in:
parent
ec6de91cf0
commit
e415e78aaa
33 changed files with 2382 additions and 631 deletions
|
|
@ -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