public TokenInfo DoPayment(out string token) { token = ""; var result = new TokenInfo("-30000", GetDescription(1001, -30000), "", ""); try { var res = new TokensClient().MakeToken(Amount, MerchantId, OrderId, PeymentId, SpecialPeymentId, ReturnUrl, Description); if (!res.result) { return(result); } token = res.token; result.ActionType = "POST"; result.Action = PurchaseLink; result.Code = "0"; result.Result = res.message; result.Tokenitems.Add(new TokenInfo.TokenItems("Token", res.token)); result.Tokenitems.Add(new TokenInfo.TokenItems("MerchantId", MerchantId)); } catch (Exception) { return(result); } return(result); }
public virtual SubmitTransactionResult SubmitTransaction(SubmitTransactionParameter parameter) { TransactionalClient transactionalClient = new TransactionalClient(); TokensClient tokenClient = new TokensClient(); SubmitTransactionResult result = new SubmitTransactionResult(); if (parameter.PaymentProfileId != null) { UseTokenRequest cardRequest = this.GetCardRequestForToken(parameter); UseTokenResponse reply1 = tokenClient.UseToken(cardRequest); result.Success = reply1.Result == 0; result.ResponseNumber = reply1.AuthorizationNumber ?? string.Empty; result.ResponseToken = parameter.PaymentProfileId + "|" + reply1.ReferenceNumber ?? string.Empty; if (!result.Success) { result.ResponseMessages.Add(string.Format("Transaction Failed: {0} Reference: {1}", reply1.Message, reply1.ReferenceNumber)); } } else { // ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;//BUSA-669 : change Protocol to TLS v1.2 in CenPos calls ProcessCreditCardResponse reply = transactionalClient.ProcessCreditCard(this.GetCardRequest(parameter)); result.Success = reply.Result == 0; result.ResponseNumber = reply.AutorizationNumber ?? string.Empty; result.ResponseToken = ((ProcessRecurringSaleResponse)reply).RecurringSaleTokenId + "|" + reply.ReferenceNumber ?? string.Empty; this.recurringToken = ((ProcessRecurringSaleResponse)reply).RecurringSaleTokenId; if (!result.Success) { result.ResponseMessages.Add(string.Format("Transaction Failed: {0} Reference: {1}", reply.Message, reply.ReferenceNumber)); } } return(result); }
public async Task <PaymentResponse> PaymentRequestAsync(GatewayInformation gatewayInfo) { TokenService.TokensClient tokenClient = new TokensClient(); var response = await tokenClient.MakeTokenAsync("1000", "AA6E", "54545545", "662584852", "", "http://localhost:35521/verifypage.aspx", "Test Sample").ConfigureAwait(false); return(null); }
public string IranKishCallPayRequest(Transaction transaction, string merchantId, string requestAuthority) { var client = new TokensClient(); var afterCallBackUrl = Enums.Bank.IranKish.AfterCallBackUrl(transaction.Id, requestAuthority); var tokenResp = client.MakeToken(((uint)(transaction.Amount)).ToString(), merchantId, transaction.InvoiceId.ToString(), transaction.TrackYourOrderNum.ToString(), "", afterCallBackUrl, transaction.Description); var data = string.Format("{0}#{1}#", tokenResp.token, merchantId); transaction.AdditionalData = StringUtils.Encrypt(data); var radynCallPayRequestInRadyn = Enums.Bank.IranKish.CallBankUrl(transaction.Id, requestAuthority); return(!PaymentComponenets.Instance.TransactionFacade.Update(transaction) ? string.Empty : radynCallPayRequestInRadyn); }
public ActionResult RedirectToBank() { var client = new TokensClient(); long TotalPrice = 150000; var bankid = "Create Random Text To trace Invoice"; var tokenResp = client.MakeSpecialToken(TotalPrice.ToString(), "Your Merch Id", bankid, "", "", "Call back url", "Custom Text like Buy from IranKish", "", "", "", "ASANSHP;LC;3"); var datacollection = new Dictionary <string, object> { { "token", tokenResp.token }, { "merchantId", "Your Merch Id" }, { "Amount", TotalPrice }, { "invocreNo", bankid.ToString() } }; return(this.RedirectAndPost("https://ikc.shaparak.ir/TPayment/Payment/Index", datacollection)); }
protected virtual async Task <HttpClient> CreateHttpClientAsync(CancellationToken cancellationToken) { var accessToken = ContextService.AccessToken; if (string.IsNullOrWhiteSpace(accessToken)) { throw new TokenException("Unable to get local access token."); } var refreshToken = ContextService.RefreshToken; if (string.IsNullOrWhiteSpace(refreshToken)) { throw new TokenException("Unable to get local refresh token."); } var tokenExpiry = ContextService.TokenExpiryDateTime; var now = DateTime.Now; if (tokenExpiry <= now || tokenExpiry.Subtract(now).TotalMinutes < 5) { try { TokenDTO tokenDto = await TokensClient.RefreshAsync(new TokenRefreshDTO() { Client_id = "Client_id_value", Grant_type = "refresh_token", Refresh_token = refreshToken, }); SaveTokenInfo(tokenDto); } catch (Exception ex) { throw new TokenException("Unable to refresh the token", ex); } } var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ContextService.AccessToken); return(client); }
/// <summary> /// Instantiates a new instance of this class. /// </summary> /// <param name="httpClient">The HTTP client to be used.</param> /// <param name="connectionInfo">The connect details used when setting up a connection.</param> internal Mobius(HttpClient httpClient, MobiusConnectionInfo connectionInfo) { if (connectionInfo == null) { throw new ArgumentNullException(nameof(connectionInfo)); } HttpClient httpClientToUse; if (httpClient == null) { _localHttpClientInstance = new HttpClient(); httpClientToUse = _localHttpClientInstance; } else { _localHttpClientInstance = null; httpClientToUse = httpClient; } AppStore = new AppStoreClient(httpClientToUse, connectionInfo); Tokens = new TokensClient(httpClientToUse, connectionInfo); }
public LiquidAdapter PreparePaymentPageViewData() { var shaparakSetting = _settingService.GetSetting <ShaprakGateWaySetting>(); if (shaparakSetting is null) { throw new ArgumentException(nameof(ShaprakGateWaySetting)); } var orderId = GetCurrentUserPaymentProccessingOrderId(); var order = _orderDataService.Query.First(x => x.Id == orderId); var paymentAmount = Convert.ToInt32(order.OrderTotal).ToString(); TokensClient client = new TokensClient(); tokenResponse tokenResp = client.MakeToken(paymentAmount, shaparakSetting.MerchantId, order.Id.ToString(), order.PaymentTrackNumber, "", _urlHelper.Action("Index", "Payment", null, HttpContext.Current.Request.Url.Scheme), ""); return(new PaymentPageLiquidViewData() { ClientToken = tokenResp.token, MerchantId = shaparakSetting.MerchantId, PaymentId = order.PaymentTrackNumber }); }
/// <summary> /// Creates a new <see cref="CheckoutApi"/> instance and initializes each underlying API client. /// </summary> /// <param name="apiClient">The API client used to send API requests and handle responses.</param> /// <param name="configuration">A configuration object containing authentication and API specific information.</param> public CheckoutApi(IApiClient apiClient, CheckoutConfiguration configuration) { Payments = new PaymentsClient(apiClient, configuration); Sources = new SourcesClient(apiClient, configuration); Tokens = new TokensClient(apiClient, configuration); }