コード例 #1
0
        private static decimal CalculateShipping(PaymentRequestOptions options, decimal subtotal)
        {
            var freeShippingThreshold = options.FreeShippingThreshold ?? 0.0m;
            var flatShippingRate      = options.FlatShippingRate ?? 0.0m;

            return(subtotal > freeShippingThreshold ? 0.0m : flatShippingRate);
        }
コード例 #2
0
 public PaymentRequest(IList <CartView> cart, PaymentRequestOptions options)
 {
     InitApiCredentialsForMode(options);
     Init(options, cart);
     ItemList      = GetItemListFrom(cart);
     InvoiceNumber = options.InvoiceNumber.ToString();
     ReturnUrl     = ($"{options.RequestUri}review").ToLower();
 }
コード例 #3
0
        private void Init(PaymentRequestOptions options, IEnumerable <CartView> cart)
        {
            const decimal tax      = 0.00m;
            var           subTotal = CalculateSubTotal(cart);
            var           shipping = CalculateShipping(options, subTotal);
            var           total    = subTotal + tax + shipping;

            Subtotal = subTotal.ToString(MoneyFormat);
            Total    = total.ToString(MoneyFormat);
            Shipping = shipping.ToString(MoneyFormat);
        }
コード例 #4
0
 private void InitApiCredentialsForMode(PaymentRequestOptions options)
 {
     if (options.IsSandbox)
     {
         Mode         = SandboxMode;
         ClientId     = options.PaypalSandBoxClientId;
         ClientSecret = options.PaypalSandBoxSecret;
     }
     else
     {
         Mode         = LiveMode;
         ClientId     = options.PaypalClientId;
         ClientSecret = options.PaypalClientSecret;
     }
 }