本文整理汇总了C#中Braintree.TransactionRequest类的典型用法代码示例。如果您正苦于以下问题:C# TransactionRequest类的具体用法?C# TransactionRequest怎么用?C# TransactionRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionRequest类属于Braintree命名空间,在下文中一共展示了TransactionRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakePaymentPaypal
public BraintreeResponse MakePaymentPaypal(string nonce)
{
BraintreeGateway braintreeGateway = GetGateway();
TransactionRequest request = new TransactionRequest
{
Amount = _cartModel.TotalToPay,
PaymentMethodNonce = nonce,
BillingAddress = GetBillingAddress(),
Options = new TransactionOptionsRequest
{
SubmitForSettlement = true
}
};
Result<Transaction> result = braintreeGateway.Transaction.Sale(request);
if (result.IsSuccess())
{
Order order = _orderPlacementService.PlaceOrder(_cartModel,
o =>
{
o.PaymentStatus = PaymentStatus.Paid;
o.CaptureTransactionId = result.Target.Id;
});
return new BraintreeResponse { Success = true, Order = order };
}
return new BraintreeResponse
{
Success = false,
Errors = new List<string> { result.Message }
};
}
示例2: Credit
public virtual Result<Transaction> Credit(TransactionRequest request)
{
request.Type = TransactionType.CREDIT;
XmlNode response = service.Post(service.MerchantPath() + "/transactions", request);
return new ResultImpl<Transaction>(new NodeWrapper(response), gateway);
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var gateway = new BraintreeGateway
{
Environment = Braintree.Environment.SANDBOX,
MerchantId = "78c2hsmmg73s6sdg",
PublicKey = "jsyrqbxq2fqv456k",
PrivateKey = "004b6691b796db322c57c71343ecf592"
};
if (!IsPostBack)
{
var clientToken = gateway.ClientToken.generate();
String clientTK = clientToken;
cTK.Value = clientToken;
}
else
{
var nonceFromTheClient = Request.Form["payment_method_nonce"];
var request = new TransactionRequest
{
Amount = 100.00M,
PaymentMethodNonce = nonceFromTheClient
};
Result<Transaction> result = gateway.Transaction.Sale(request);
var id = result.Transaction.Id;
var amount = result.Transaction.Amount;
var date = result.Transaction.UpdatedAt;
var status = result.Transaction.ProcessorResponseCode;
}
}
示例4: Sale
public virtual Result<Transaction> Sale(TransactionRequest request)
{
request.Type = TransactionType.SALE;
XmlNode response = Service.Post("/transactions", request);
return new Result<Transaction>(new NodeWrapper(response), Service);
}
示例5: ToXml_InludesPaymentMethodNonce
public void ToXml_InludesPaymentMethodNonce()
{
TransactionRequest request = new TransactionRequest();
request.PaymentMethodNonce = "1232131232";
Assert.IsTrue(request.ToXml().Contains("1232131232"));
}
示例6: ToXml_Includes_DeviceSessionId
public void ToXml_Includes_DeviceSessionId()
{
TransactionRequest request = new TransactionRequest();
request.DeviceSessionId = "my_dsid";
Assert.IsTrue(request.ToXml().Contains("my_dsid"));
}
示例7: ToXml_Includes_FraudMerchantId
public void ToXml_Includes_FraudMerchantId()
{
TransactionRequest request = new TransactionRequest();
request.FraudMerchantId = "my_fmid";
Assert.IsTrue(request.ToXml().Contains("my_fmid"));
}
示例8: CreateTransaction
public ActionResult CreateTransaction(FormCollection collection)
{
TransactionRequest request = new TransactionRequest
{
Amount = 1000.0M,
CreditCard = new TransactionCreditCardRequest
{
Number = collection["number"],
CVV = collection["cvv"],
ExpirationMonth = collection["month"],
ExpirationYear = collection["year"]
},
Options = new TransactionOptionsRequest
{
SubmitForSettlement = true
}
};
Result<Transaction> result = Constants.Gateway.Transaction.Sale(request);
if (result.IsSuccess())
{
Transaction transaction = result.Target;
ViewData["TransactionId"] = transaction.Id;
}
else
{
ViewData["Message"] = result.Message;
}
return View();
}
示例9: ProcessPayment
public PaymentResult ProcessPayment(ViewModels.CheckoutViewModel model)
{
var request = new TransactionRequest()
{
Amount = model.Total,
CreditCard = new TransactionCreditCardRequest()
{
Number = model.CardNumber,
CVV = model.Cvv,
ExpirationMonth = model.Month,
ExpirationYear = model.Year
},
Options = new TransactionOptionsRequest()
{
SubmitForSettlement = true
}
};
var result = _gateway.Transaction.Sale(request);
if (result.IsSuccess())
{
return new PaymentResult(result.Target.Id, true, null);
}
return new PaymentResult(null, false, result.Message);
}
示例10: Generate_ReturnsTransactionsSettledOnAGivenDay
public void Generate_ReturnsTransactionsSettledOnAGivenDay()
{
TransactionRequest request = new TransactionRequest
{
Amount = 1000M,
CreditCard = new TransactionCreditCardRequest
{
Number = "4111111111111111",
ExpirationDate = "05/2012",
CardholderName = "Tom Smith",
},
Options = new TransactionOptionsRequest
{
SubmitForSettlement = true
},
};
Transaction transaction = gateway.Transaction.Sale(request).Target;
Transaction settlementResult = gateway.TestTransaction.Settle(transaction.Id);
var settlementDate = settlementResult.SettlementBatchId.Substring(0,10);
transaction = gateway.Transaction.Find(transaction.Id);
var result = gateway.SettlementBatchSummary.Generate(System.DateTime.Parse(settlementDate));
var visas = new List<IDictionary<string,string>>();
foreach (var row in result.Target.Records)
{
if (Braintree.CreditCardCardType.VISA.ToString().Equals(row["card_type"]))
{
visas.Add(row);
}
}
Assert.AreEqual(1, visas.Count);
}
示例11: CancelRelease
public virtual Result<Transaction> CancelRelease(string id)
{
var request = new TransactionRequest();
XmlNode response = service.Put(service.MerchantPath() + "/transactions/" + id + "/cancel_release", request);
return new ResultImpl<Transaction>(new NodeWrapper(response), gateway);
}
示例12: HoldInEscrow
public virtual Result<Transaction> HoldInEscrow(string id)
{
var request = new TransactionRequest();
XmlNode response = service.Put(service.MerchantPath() + "/transactions/" + id + "/hold_in_escrow", request);
return new ResultImpl<Transaction>(new NodeWrapper(response), gateway);
}
示例13: ToXML_EscapesGeneratedXMLForString
public void ToXML_EscapesGeneratedXMLForString()
{
TransactionRequest request = new TransactionRequest
{
OrderId = "<>&\"'"
};
TestHelper.AssertIncludes("<order-id><>&"'</order-id>", request.ToXml());
}
示例14: Refund
public virtual Result<Transaction> Refund(String id, Decimal amount)
{
TransactionRequest request = new TransactionRequest
{
Amount = amount
};
XmlNode response = Service.Post("/transactions/" + id + "/refund", request);
return new Result<Transaction>(new NodeWrapper(response), Service);
}
示例15: ToXml_Includes_DeviceData
public void ToXml_Includes_DeviceData()
{
TransactionRequest request = new TransactionRequest();
request.DeviceData = "{\"device_session_id\":\"my_dsid\", \"fraud_merchant_id\":\"my_fmid\"}";
Assert.IsTrue(request.ToXml().Contains("device-data"));
Assert.IsTrue(request.ToXml().Contains("device_session_id"));
Assert.IsTrue(request.ToXml().Contains("my_dsid"));
Assert.IsTrue(request.ToXml().Contains("fraud_merchant_id"));
Assert.IsTrue(request.ToXml().Contains("my_fmid"));
}