-
Notifications
You must be signed in to change notification settings - Fork 4
/
StripePaymentSettings.cs
56 lines (51 loc) · 1.43 KB
/
StripePaymentSettings.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
using Nop.Core.Configuration;
using Stripe;
using System;
namespace Nop.WebTail.Stripe
{
public class StripePaymentSettings : ISettings
{
public string LiveSecretKey { get; set; }
public string LivePublishableKey { get; set; }
public string TestSecretKey { get; set; }
public string TestPublishableKey { get; set; }
public bool UseSandbox { get; set; }
public decimal AdditionalFee { get; set; }
public bool AdditionalFeePercentage { get; set; }
public TransactionMode TransactionMode { get; set; }
public string GetApiKey()
{
if (this.UseSandbox)
{
return this.TestSecretKey;
}
else
{
return this.LiveSecretKey;
}
}
public string GetCustomerIdKey()
{
if (this.UseSandbox)
{
return StripePaymentDefaults.CustomerIdAttributeSandbox;
}
else
{
return StripePaymentDefaults.CustomerIdAttributeProduction;
}
}
public StripeClient GetStripeClient()
{
try
{
var stripeClient = new StripeClient(this.GetApiKey());
return stripeClient;
}
catch (Exception ex)
{
throw;
}
}
}
}