mirror of https://github.com/abpframework/eventhub
14 changed files with 283 additions and 87 deletions
@ -0,0 +1,17 @@ |
|||||
|
using JetBrains.Annotations; |
||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace Payment.PaymentRequests |
||||
|
{ |
||||
|
public class StartPaymentDto |
||||
|
{ |
||||
|
public Guid PaymentRequestId { get; set; } |
||||
|
|
||||
|
[NotNull] |
||||
|
[Required] |
||||
|
public string ReturnUrl { get; set; } |
||||
|
|
||||
|
public string CancelUrl { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Payment.PaymentRequests |
||||
|
{ |
||||
|
public class StartPaymentResultDto |
||||
|
{ |
||||
|
public string CheckoutLink { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -1,7 +1,9 @@ |
|||||
{ |
{ |
||||
"culture": "en", |
"culture": "en", |
||||
"texts": { |
"texts": { |
||||
"MyAccount": "My account", |
"MyAccount": "My account", |
||||
"SamplePageMessage": "A sample page for the Payment module" |
"SamplePageMessage": "A sample page for the Payment module", |
||||
|
"YourPaymentCompletedSuccessfully": "Your payment has been completed successfully!", |
||||
|
"YourPaymentFailed": "Your payment has been failed unfortunetely!" |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
namespace Payment.PayPal |
||||
|
{ |
||||
|
public static class PayPalConsts |
||||
|
{ |
||||
|
public const string OrderIdPropertyName = "OrderId"; |
||||
|
|
||||
|
public static class OrderStatus |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The order was created with the specified context.
|
||||
|
/// </summary>
|
||||
|
public const string Created = "CREATED"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The order was saved and persisted. The order status continues to be in progress until a capture is made with final_capture = true for all purchase units within the order.
|
||||
|
/// </summary>
|
||||
|
public const string Saved = "SAVED"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The customer approved the payment through the PayPal wallet or another form of guest or unbranded payment. For example, a card, bank account, or so on.
|
||||
|
/// </summary>
|
||||
|
public const string Approved = "APPROVED"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// All purchase units in the order are voided.
|
||||
|
/// </summary>
|
||||
|
public const string Voided = "VOIDED"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The payment was authorized or the authorized payment was captured for the order.
|
||||
|
/// </summary>
|
||||
|
public const string Completed = "COMPLETED"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// The order requires an action from the payer (e.g. 3DS authentication). Redirect the payer to the "rel":"payer-action" HATEOAS link returned as part of the response prior to authorizing or capturing the order.
|
||||
|
/// </summary>
|
||||
|
public const string PlayerActionRequired = "PAYER_ACTION_REQUIRED"; |
||||
|
} |
||||
|
|
||||
|
public static class Environment |
||||
|
{ |
||||
|
public const string Sandbox = "Sandbox"; |
||||
|
|
||||
|
public const string Live = "Live"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,18 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
|
||||
|
|
||||
namespace Payment.PayPal |
|
||||
{ |
|
||||
public static class PayPalConsts |
|
||||
{ |
|
||||
public static class Environment |
|
||||
{ |
|
||||
public const string Sandbox = "Sandbox"; |
|
||||
|
|
||||
public const string Live = "Live"; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,8 +1,35 @@ |
|||||
@page |
@page |
||||
@using Payment.Web.Pages.Payment |
@using Payment.Web.Pages.Payment |
||||
|
@using Payment.PaymentRequests |
||||
@inherits Payment.Web.Pages.PaymentPageBase |
@inherits Payment.Web.Pages.PaymentPageBase |
||||
@model Payment.Web.Pages.Payment.CheckoutCallbackModel |
@model Payment.Web.Pages.Payment.CheckoutCallbackModel |
||||
@{ |
@{ |
||||
PageLayout.Content.Title = L["Redirecting"]; |
PageLayout.Content.Title = L["PaymentResult"] + L["Enum:PaymentRequestState:" + Model.PaymentRequest.State]; |
||||
} |
} |
||||
<p>@L["Redirecting"]</p> |
|
||||
|
<abp-card> |
||||
|
<abp-card-header> |
||||
|
<h2>@L["PaymentResult"]</h2> |
||||
|
</abp-card-header> |
||||
|
|
||||
|
<abp-card-body> |
||||
|
|
||||
|
@if (Model.PaymentRequest.State == PaymentRequestState.Completed) |
||||
|
{ |
||||
|
<abp-alert alert-type="Success" dismissible="false"> |
||||
|
<h1><i class="bi-check-circle-fill"></i></h1> |
||||
|
@L["YourPaymentCompletedSuccessfully"] |
||||
|
</abp-alert> |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
<abp-alert alert-type="Danger" dismissible="false"> |
||||
|
<h1><i class="bi-check-circle-fill"></i></h1> |
||||
|
@L["YourPaymentFailed"] |
||||
|
</abp-alert> |
||||
|
|
||||
|
<abp-button text="@L["GoBack"]"/> |
||||
|
} |
||||
|
|
||||
|
</abp-card-body> |
||||
|
</abp-card> |
||||
@ -1,6 +1,53 @@ |
|||||
namespace Payment.Web.Pages.Payment |
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.Extensions.Options; |
||||
|
using Payment.PaymentRequests; |
||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Payment.Web.Pages.Payment |
||||
{ |
{ |
||||
public class CheckoutCallbackModel : PaymentPageModel |
public class CheckoutCallbackModel : PaymentPageModel |
||||
{ |
{ |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string Token { get; set; } |
||||
|
|
||||
|
public PaymentRequestDto PaymentRequest { get; protected set; } |
||||
|
|
||||
|
private readonly IPaymentRequestAppService _paymentRequestAppService; |
||||
|
private readonly PaymentWebOptions _paymentWebOptions; |
||||
|
|
||||
|
public CheckoutCallbackModel( |
||||
|
IPaymentRequestAppService appService, |
||||
|
IOptions<PaymentWebOptions> paymentWebOptions) |
||||
|
{ |
||||
|
_paymentRequestAppService = appService; |
||||
|
_paymentWebOptions = paymentWebOptions.Value; |
||||
|
} |
||||
|
|
||||
|
public async Task<IActionResult> OnGetAsync() |
||||
|
{ |
||||
|
if (Token.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
return BadRequest(); |
||||
|
} |
||||
|
|
||||
|
PaymentRequest = await _paymentRequestAppService.CompleteAsync(Token); |
||||
|
|
||||
|
if (PaymentRequest.State == PaymentRequestState.Completed |
||||
|
&& !_paymentWebOptions.PaymentSuccessfulCallbackUrl.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var callbackUrl = _paymentWebOptions.PaymentSuccessfulCallbackUrl + "?paymentRequestId=" + PaymentRequest.Id; |
||||
|
Response.Redirect(callbackUrl); |
||||
|
} |
||||
|
|
||||
|
if (PaymentRequest.State == PaymentRequestState.Failed |
||||
|
&& !_paymentWebOptions.PaymentFailureCallbackUrl.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var callbackUrl = _paymentWebOptions.PaymentFailureCallbackUrl + "?paymentRequestId=" + PaymentRequest.Id; |
||||
|
Response.Redirect(callbackUrl); |
||||
|
} |
||||
|
|
||||
|
return Page(); |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,8 @@ |
|||||
|
namespace Payment.Web |
||||
|
{ |
||||
|
public class PaymentWebOptions |
||||
|
{ |
||||
|
public string PaymentSuccessfulCallbackUrl { get; set; } |
||||
|
public string PaymentFailureCallbackUrl { get; set; } |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue