本文整理汇总了C#中ProcessorArgumentCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessorArgumentCollection.Add方法的具体用法?C# ProcessorArgumentCollection.Add怎么用?C# ProcessorArgumentCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProcessorArgumentCollection
的用法示例。
在下文中一共展示了ProcessorArgumentCollection.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Callback
public ActionResult Callback(string id)
{
var checkSum = Request.Headers["QuickPay-Checksum-SHA256"];
// Get the Payload data
var req = Request.InputStream;
req.Seek(0, SeekOrigin.Begin);
var json = new StreamReader(req).ReadToEnd();
LogHelper.Info<CallbackController>(() => "[BODY] : " + json);
var gateway = MerchelloContext.Current.Gateways.Payment.GetProviderByKey(Guid.Parse(Constants.ProviderId));
var gatewaySettings = gateway.ExtendedData.GetProviderSettings();
var compute = Sign(json, gatewaySettings.PrivateKey); // Private Key for the Payment Window! Not the API key.
if (!checkSum.Equals(compute)) {
LogHelper.Warn<CallbackController>("Checksum did not compute : " + checkSum + "\r\n" + json);
throw new Exception("MD5 Check does not compute");
}
QuickPayResponseModel callbackInput;
try {
callbackInput = JsonConvert.DeserializeObject<QuickPayResponseModel>(json);
} catch (Exception ex) {
LogHelper.Error<CallbackController>("Unable to deserialize json from QuickPay callback", ex);
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
if (!callbackInput.Accepted) {
LogHelper.Info<CallbackController>("Payment not accepted by QuickPay");
return Content("Payment not accepted by QuickPay");
}
if (callbackInput.Order_Id.StartsWith("test_")) {
LogHelper.Warn<CallbackController>("QuickPay is in test mode. The payment provider is unable to identify the invoice to apply the payment to, since the order_id was returned as " + callbackInput.Order_Id);
return Content("QuickPay Test Mode Detected");
}
var invoiceNumber = int.Parse(callbackInput.Order_Id);
var invoice = MerchelloContext.Current.Services.InvoiceService.GetByInvoiceNumber(invoiceNumber);
var paymentGatewayMethod = MerchelloContext.Current.Gateways.Payment.GetPaymentGatewayMethods().Single(x => x.PaymentMethod.ProviderKey == Guid.Parse(Constants.ProviderId));
var args = new ProcessorArgumentCollection();
args.Add(Constants.ExtendedDataKeys.PaymentCurrency, callbackInput.Currency);
args.Add(Constants.ExtendedDataKeys.PaymentAmount, callbackInput.Operations.Where(x => !x.Pending).Sum(x => x.Amount).ToString("F0"));
args.Add(Constants.ExtendedDataKeys.QuickpayPaymentId, callbackInput.Id.ToString("F0"));
var paymentResult = invoice.AuthorizePayment(paymentGatewayMethod, args);
Notification.Trigger("OrderConfirmation", paymentResult, new[] { invoice.BillToEmail });
return Content("Hello QuickPay");
}