/// <summary> /// Execute sale method /// </summary> /// <param name="transactionId"></param> public ProcessResult Sale(string transactionId) { if (string.IsNullOrEmpty(transactionId)) { throw new ArgumentNullException(nameof(transactionId)); } var response = _client.Process(_connection.MerchantId, _connection.Token, new ProcessRequest { Operation = "SALE", TransactionId = transactionId }); return(Create(response)); }
protected virtual bool ProcessOperation(string operation, string transactionId, out string message, PaymentMethod paymentMethod) { // Configuration values string merchantId = paymentMethod.DynamicProperty <string>().MerchantId; string password = paymentMethod.DynamicProperty <string>().Password; bool result; NetaxeptClient client = GetClient(paymentMethod); try { var response = client.Process(merchantId, password, new ProcessRequest { Operation = operation, TransactionId = transactionId }); message = response.ResponseText; result = response.ResponseCode.Equals("OK"); } catch (Exception ex) { message = ex.Message; result = false; } return(result); }
/// <summary> /// Processed the callback received from the payment provider. /// </summary> public override void ProcessCallback(Payment payment) { if (payment.PaymentStatus.PaymentStatusId != (int)PaymentStatusCode.PendingAuthorization) { return; } string transactionId = HttpContext.Current.Request["transactionId"]; string paymentResponseCode = HttpContext.Current.Request["responseCode"]; // Configuration values string cancelUrl = payment.PaymentMethod.DynamicProperty <string>().CancelUrl; string merchantId = payment.PaymentMethod.DynamicProperty <string>().MerchantId; string password = payment.PaymentMethod.DynamicProperty <string>().Password; string declineUrl = payment.PaymentMethod.DynamicProperty <string>().DeclineUrl; // Netaxept will return something other than OK if // the customer cancels at the remote end. if (!paymentResponseCode.Equals("OK")) { HttpContext.Current.Response.Redirect(new Uri(_absoluteUrlService.GetAbsoluteUrl(cancelUrl)) .AddOrderGuidParameter(payment.PurchaseOrder).ToString()); } bool authOK = false; NetaxeptClient client = GetClient(payment.PaymentMethod); try { //Authorization process var authResponse = client.Process(merchantId, password, new ProcessRequest { Operation = "AUTH", TransactionId = transactionId }); // PaymentClient.Process will cause an exception if something // goes wrong during auth. Thus authReponse will always // contain an "OK" value if execution continues to this // point. authOK = authResponse.ResponseCode == "OK"; if (authOK) { UpdatePaymentAndDisplayThankYouPage(payment, transactionId); } } catch (Exception ex) { _loggingService.Log <NetaxeptPaymentMethodService>(ex.Message); string uri = new Uri(_absoluteUrlService.GetAbsoluteUrl(declineUrl)) .AddOrderGuidParameter(payment.PurchaseOrder) .AddQueryStringParameter("exceptionMessage", ex.Message) .ToString(); HttpContext.Current.Response.Redirect(uri, false); } }