本文整理汇总了C#中IOrder.GetVat方法的典型用法代码示例。如果您正苦于以下问题:C# IOrder.GetVat方法的具体用法?C# IOrder.GetVat怎么用?C# IOrder.GetVat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrder
的用法示例。
在下文中一共展示了IOrder.GetVat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePayment
private Payment CreatePayment(IOrder order, string paymentType, string redirectUrl, CardDetails cardDetails)
{
//Create items for which you are taking payment
var items = order.OrderDetails.GetList().Select(product => new Item
{
name = product.Name,
currency = "GBP",
price = product.Price.ToString(CultureInfo.InvariantCulture),
quantity = product.Quantity.ToString(CultureInfo.InvariantCulture),
sku = product.Category
}).ToList();
// Create ItemList object
var itemList = new ItemList { items = items };
// Specify the details of your payment amount.
var subtotal = order.GetProductCost() - order.GetVat();
var details = new Details
{
shipping = order.DeliveryCharges.ToString(CultureInfo.InvariantCulture),
subtotal = subtotal.ToString(CultureInfo.InvariantCulture),
tax = order.GetVat().ToString(CultureInfo.InvariantCulture)
};
// Specify your total payment amount and assign the details object
var totalCost = order.GetProductCost() + order.DeliveryCharges;
var amount = new Amount
{
currency = "GBP",
total = totalCost.ToString(CultureInfo.InvariantCulture),
//details = details
};
// Now add transactions
var transactions = new List<Transaction>
{
new Transaction
{
amount = amount,
description = string.Format("Total amount = £{0}", order.GetProductCost() + order.DeliveryCharges),
//item_list = itemList,
//invoice_number = order.OrderNumber.ToString(CultureInfo.InvariantCulture)
}
};
Payer payer;
if (paymentType.Equals("payPal", StringComparison.OrdinalIgnoreCase))
{
payer = new Payer { payment_method = "paypal" };
}
else
{
//Address for the payment
var billingAddress = new Address
{
country_code = "GB",
line1 = cardDetails.Address,
postal_code = cardDetails.Postcode,
city = cardDetails.City
};
//Now Create an object of credit card and add above details to it
var creditCard = new CreditCard
{
billing_address = billingAddress,
cvv2 = cardDetails.CardVerificationCode.GetValueOrDefault().ToString(CultureInfo.InvariantCulture),
expire_month = cardDetails.ExpirationMonth.GetValueOrDefault(),
expire_year = cardDetails.ExpirationYear.GetValueOrDefault(),
first_name = cardDetails.FirstName,
last_name = cardDetails.LastName,
number = cardDetails.CardNumber.GetValueOrDefault().ToString(CultureInfo.InvariantCulture),
type = cardDetails.CardType.ToLower()
};
// Now we need to create the FundingInstrument object of the Payer
// for credit card payments, set the CreditCard which we made above
var fundInstrument = new FundingInstrument { credit_card = creditCard };
// The Payment creation API requires a list of FundingIntrument
var fundingInstrumentList = new List<FundingInstrument> { fundInstrument };
// Now create Payer object and assign the fundinginstrument list to the object
payer = new Payer
{
funding_instruments = fundingInstrumentList,
payment_method = "credit_card"
};
}
// Finally we need create the payment object and assign the payer object & transaction list to it
var payment = new Payment
{
intent = "sale",
payer = payer,
transactions = transactions
};
if (!string.IsNullOrEmpty(redirectUrl))
{
var redirUrls = new RedirectUrls
//.........这里部分代码省略.........