forked from landlogicit/gestpay-for-nopcommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGestPayHelper.cs
59 lines (54 loc) · 2.08 KB
/
GestPayHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Nop.Core.Domain.Payments;
namespace Nop.Plugin.Payments.GestPay
{
/// <summary>
/// Represents GestPay helper
/// </summary>
public class GestPayHelper
{
/// <summary>
/// Gets a payment status
/// </summary>
/// <param name="transactionResult">GestPay payment status</param>
/// <param name="pendingReason">GestPay pending reason</param>
/// <returns>Payment status</returns>
public static PaymentStatus GetPaymentStatus(string transactionResult, string pendingReason)
{
/*
* Risultato transazione:
* E' possibile interpretare l'esito di una transazione verificando
* il valore del campo: TransactionResult.
* I valori possibili sono:
* OK :Esito transazione positivo
* KO :Esito transazione negativo
* XX :Esito transazione sospeso (solo in caso di pagamento con bonifico)
*/
var result = PaymentStatus.Pending;
if (transactionResult == null)
transactionResult = string.Empty;
if (pendingReason == null)
pendingReason = string.Empty;
switch (transactionResult.ToLowerInvariant())
{
case "xx": //Pending Solo per bonifico
switch (pendingReason.ToLowerInvariant())
{
case "authorization":
result = PaymentStatus.Authorized;
break;
default:
result = PaymentStatus.Pending;
break;
}
break;
case "ok": //Esito transazione positivo
result = PaymentStatus.Paid;
break;
case "ko": //Esito transazione negativo
result = PaymentStatus.Voided;
break;
}
return result;
}
}
}