当前位置: 首页>>代码示例>>C#>>正文


C# ProcessorArgumentCollection.Add方法代码示例

本文整理汇总了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");
        }
开发者ID:joelbhansen,项目名称:MerchelloQuickPayProvider,代码行数:54,代码来源:CallbackController.cs


注:本文中的ProcessorArgumentCollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。