Exemple #1
0
        private static decimal CalculateShipping(SiteSetting settings, decimal subtotal)
        {
            var freeShippingThreshold = settings.FreeShippingThreshold ?? 0.0m;
            var flatShippingRate      = settings.FlatShippingRate ?? 0.0m;

            return(subtotal > freeShippingThreshold ? 0.0m : flatShippingRate);
        }
Exemple #2
0
 public PaymentRequest(Uri requestUri, SiteSetting settings, IList <CartView> cart, long invoiceNumber, bool isSandbox = true)
 {
     InitApiCredentialsForMode(settings, isSandbox);
     Init(settings, cart);
     ItemList      = GetItemListFrom(cart);
     InvoiceNumber = invoiceNumber.ToString();
     ReturnUrl     = ($"{requestUri}review").ToLower();
 }
Exemple #3
0
        private void Init(SiteSetting settings, IEnumerable <CartView> cart)
        {
            const decimal tax      = 0.00m;
            var           subTotal = CalculateSubTotal(cart);
            var           shipping = CalculateShipping(settings, subTotal);
            var           total    = subTotal + tax + shipping;

            Subtotal = subTotal.ToString(MoneyFormat);
            Total    = total.ToString(MoneyFormat);
            Shipping = shipping.ToString(MoneyFormat);
        }
 public PaymentRequestOptions(SiteProfile profile, SiteSetting settings, Uri requestUri, bool isSandbox = true)
 {
     FlatShippingRate      = profile.FlatShippingRate;
     FreeShippingThreshold = profile.FreeShippingThreshold;
     InvoiceNumber         = DateTime.Now.Ticks;
     IsSandbox             = isSandbox;
     PaypalClientId        = settings.PaypalClientId;
     PaypalClientSecret    = settings.PaypalClientSecret;
     PaypalSandBoxClientId = settings.PaypalClientId;
     PaypalSandBoxSecret   = settings.PaypalSandBoxSecret;
     RequestUri            = requestUri;
 }
Exemple #5
0
 private void InitApiCredentialsForMode(SiteSetting settings, bool isSandbox)
 {
     if (isSandbox)
     {
         Mode         = SandboxMode;
         ClientId     = settings.PaypalSandBoxClientId;
         ClientSecret = settings.PaypalSandBoxSecret;
     }
     else
     {
         Mode         = LiveMode;
         ClientId     = settings.PaypalClientId;
         ClientSecret = settings.PaypalClientSecret;
     }
 }