/// <summary> /// Retrieves the payment configuration from persistence. /// </summary> /// <returns>The payment configuration.</returns> public async Task <PaymentConfiguration> RetrieveAsync() { var paymentConfiguration = await this.ApplicationDomain.CachingService .FetchAsync <PaymentConfiguration>(PaymentConfigurationRepository.PaymentConfigurationCacheKey); if (paymentConfiguration == null) { var paymentConfigurationBlob = await this.GetPaymentConfigurationBlob(); paymentConfiguration = new PaymentConfiguration(); if (await paymentConfigurationBlob.ExistsAsync()) { paymentConfiguration = JsonConvert.DeserializeObject <PaymentConfiguration>(await paymentConfigurationBlob.DownloadTextAsync()); await this.NormalizeAsync(paymentConfiguration); // cache the payment configuration await this.ApplicationDomain.CachingService.StoreAsync <PaymentConfiguration>( PaymentConfigurationRepository.PaymentConfigurationCacheKey, paymentConfiguration); } } return(paymentConfiguration); }
public RemovePaymentLinkInDotpayCommand(ILogger logger, BaseDbContext dbContext, EndpointConfig endpointConfig, PaymentConfiguration paymentConfiguration) : base(logger, dbContext) { _endpointConfig = endpointConfig; _paymentConfiguration = paymentConfiguration; }
public PurchaseTransactionResponse PerformPaymentTransaction(PurchaseTransactionRequest requestTx) { // Get URL from Config PaymentConfiguration paymentConfiguration = this.GetPaymentConfiguration(); requestTx.CO_ID = paymentConfiguration.CO_ID; requestTx.OUTLET = paymentConfiguration.OUTLET; MERCHANT_SECRET = paymentConfiguration.MERCHANT_SECRET_KEY; requestTx.Reference = BuildMerchantReference(requestTx); requestTx.Consistent = this.BuildConsistentKey(requestTx); // Persist request transaction requestTx = this.PersistPaymentRequest(requestTx); // Do Payment SetcomPurchase transactionProcessor = new SetcomPurchase(); PurchaseTransactionResponse purchaseTransactionResponse; purchaseTransactionResponse = transactionProcessor.DoPayment(requestTx, paymentConfiguration.PaymentGatewayURL); // persist response bool updateSuccessful = this.VerifyAndPersistPaymentResponse(requestTx, purchaseTransactionResponse); return(purchaseTransactionResponse); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { UINavigationController navigationController; PaymentConfiguration config; tableView.DeselectRow(indexPath, true); Demo example = (Demo)indexPath.Row; var theme = themeViewController.Theme.GetStripeTheme(); switch (example) { case Demo.PaymentCardTextField: var cardFieldViewContoller = new CardFieldViewController(); cardFieldViewContoller.Theme = theme; navigationController = new UINavigationController(cardFieldViewContoller); navigationController.NavigationBar.SetStripeTheme(theme); PresentViewController(navigationController, true, null); break; case Demo.AddCardViewController: config = new PaymentConfiguration(); config.RequiredBillingAddressFields = BillingAddressFields.Full; var viewController = new MockAddCardViewController(config, theme); viewController.Delegate = this; navigationController = new UINavigationController(viewController); navigationController.NavigationBar.SetStripeTheme(theme); PresentViewController(navigationController, true, null); break; case Demo.PaymentMethodsViewController: config = new PaymentConfiguration(); config.AdditionalPaymentMethods = PaymentMethodType.All; config.RequiredBillingAddressFields = BillingAddressFields.None; config.AppleMerchantIdentifier = "dummy-merchant-id"; var paymentMethodsViewController = new PaymentMethodsViewController(config, theme, customerContext, this); navigationController = new UINavigationController(paymentMethodsViewController); navigationController.NavigationBar.SetStripeTheme(theme); PresentViewController(navigationController, true, null); break; case Demo.ShippingInfoViewController: config = new PaymentConfiguration(); config.RequiredShippingAddressFields = PKAddressField.PostalAddress; var shippingAddressViewController = new ShippingAddressViewController(config, theme, "usd", null, null, null); shippingAddressViewController.Delegate = this; navigationController = new UINavigationController(shippingAddressViewController); navigationController.NavigationBar.SetStripeTheme(theme); PresentViewController(navigationController, true, null); break; case Demo.ChangeTheme: navigationController = new UINavigationController(themeViewController); PresentViewController(navigationController, true, null); break; default: throw new NotImplementedException(); } }
/// <summary> /// Retrieves the payment configuration from persistence. /// </summary> /// <returns>The payment configuration.</returns> public async Task <PaymentConfiguration> RetrieveAsync() { PaymentConfiguration paymentConfiguration = await ApplicationDomain.CachingService .FetchAsync <PaymentConfiguration>(PaymentConfigurationCacheKey).ConfigureAwait(false); if (paymentConfiguration == null) { CloudBlockBlob paymentConfigurationBlob = await GetPaymentConfigurationBlob().ConfigureAwait(false); paymentConfiguration = new PaymentConfiguration(); if (await paymentConfigurationBlob.ExistsAsync().ConfigureAwait(false)) { paymentConfiguration = JsonConvert.DeserializeObject <PaymentConfiguration>(await paymentConfigurationBlob.DownloadTextAsync().ConfigureAwait(false)); await NormalizeAsync(paymentConfiguration).ConfigureAwait(false); // cache the payment configuration await ApplicationDomain.CachingService.StoreAsync( PaymentConfigurationCacheKey, paymentConfiguration).ConfigureAwait(false); } } return(paymentConfiguration); }
public PaymentProcessor(HttpClient client, IOptions <PaymentConfiguration> paymentConfiguration, IHostingEnvironment hostingEnvironment, ILogger <PaymentProcessor> logger) { m_PaymentConfiguration = paymentConfiguration.Value; m_HttpClient = client; m_HostingEnvironment = hostingEnvironment; m_Logger = logger; }
/// <summary> /// Throws PartnerDomainException by parsing PayUMoney exception. /// </summary> /// <returns>return payment configuration</returns> private static async Task <PaymentConfiguration> GetAPaymentConfigAsync() { // Before getAPIContext ... set up PayUMoney configuration. This is an expensive call which can benefit from caching. PaymentConfiguration paymentConfig = await ApplicationDomain.Instance.PaymentConfigurationRepository.RetrieveAsync().ConfigureAwait(false); return(paymentConfig); }
private void InitWalletStripe() { try { var stripePublishableKey = ListUtils.SettingsSiteList?.StripeId ?? ""; if (!string.IsNullOrEmpty(stripePublishableKey)) { PaymentConfiguration.Init(stripePublishableKey); Stripe = new Stripe(this, stripePublishableKey); MPaymentsClient = WalletClass.GetPaymentsClient(this, new WalletClass.WalletOptions.Builder() .SetEnvironment(WalletConstants.EnvironmentTest) .SetTheme(WalletConstants.ThemeLight) .Build()); IsReadyToPay(); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_ErrorConnectionSystemStripe), ToastLength.Long).Show(); } } catch (Exception e) { Console.WriteLine(e); } }
public PaymentController(IHostingEnvironment hostingEnvironment, IOptions <PaymentConfiguration> paymentConfiguration, IPaymentProcessor paymentProcessor, ILogger <PaymentController> logger) { m_HostingEnvironment = hostingEnvironment; m_PaymentConfiguration = paymentConfiguration.Value; m_PaymentProcessor = paymentProcessor; m_Logger = logger; }
/// <summary> /// Retrieves the API Context for PayPal. /// </summary> /// <returns>PayPal APIContext</returns> private async Task <APIContext> GetAPIContextAsync() { //// The GetAccessToken() of the SDK Returns the currently cached access token. //// If no access token was previously cached, or if the current access token is expired, then a new one is generated and returned. //// See more - https://github.com/paypal/PayPal-NET-SDK/blob/develop/Source/SDK/Api/OAuthTokenCredential.cs // Before getAPIContext ... set up PayPal configuration. This is an expensive call which can benefit from caching. PaymentConfiguration paymentConfig = await ApplicationDomain.Instance.PaymentConfigurationRepository.RetrieveAsync().ConfigureAwait(false); Dictionary <string, string> configMap = new Dictionary <string, string> { { "clientId", paymentConfig.ClientId }, { "clientSecret", paymentConfig.ClientSecret }, { "mode", paymentConfig.AccountType }, { "WebExperienceProfileId", paymentConfig.WebExperienceProfileId }, { "connectionTimeout", "120000" } }; string accessToken = new OAuthTokenCredential(configMap).GetAccessToken(); APIContext apiContext = new APIContext(accessToken) { Config = configMap }; return(apiContext); }
public async Task <IActionResult> savePaymentConfig(Models.PaymentConfiguration model) { try { var obj = await db.PaymentConfiguration.FirstOrDefaultAsync(); if (obj == null) { obj = new PaymentConfiguration(); obj.Amount = model.Amount; obj.IsApplied = model.IsApplied; obj.Percentage = model.Percentage; db.PaymentConfiguration.Add(obj); db.SaveChanges(); } else { obj.Amount = model.Amount; obj.IsApplied = model.IsApplied; obj.Percentage = model.Percentage; db.SaveChanges(); } return(Ok()); } catch (Exception ex) { throw; } }
/// <summary> /// Action for EGiftCard Payment /// </summary> /// <returns></returns> public ActionResult EGiftPayment() { var UserId = Session["UserId"]; if (UserId != null) { PaymentConfiguration _paymentConfiguration = new PaymentConfiguration(); _paymentConfiguration.access_key = System.Configuration.ConfigurationManager.AppSettings["access_key"]; _paymentConfiguration.profile_id = System.Configuration.ConfigurationManager.AppSettings["profile_id"]; _paymentConfiguration.transaction_uuid = Guid.NewGuid().ToString(); _paymentConfiguration.signed_field_names = System.Configuration.ConfigurationManager.AppSettings["signed_field_names"]; _paymentConfiguration.unsigned_field_names = System.Configuration.ConfigurationManager.AppSettings["unsigned_field_names"]; _paymentConfiguration.signed_date_time = DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'"); _paymentConfiguration.locale = System.Configuration.ConfigurationManager.AppSettings["locale"]; _paymentConfiguration.transaction_type = System.Configuration.ConfigurationManager.AppSettings["transaction_type"]; _paymentConfiguration.currency = System.Configuration.ConfigurationManager.AppSettings["currency"]; _paymentConfiguration.reference_number = Convert.ToString(Session["eReferenceId"]); _paymentConfiguration.amount = Convert.ToDecimal(Session["eGiftAmt"]); Session.Remove("eGiftAmt"); Session.Remove("eReferenceId"); return(View(_paymentConfiguration)); } else { Session.Remove("eGiftAmt"); Session.Remove("eReferenceId"); return(RedirectToAction("Index", "Home")); } }
public ServiceConfiguration CreateInstance(PaymentConfiguration paymentConfiguration) { if (!this.HasData) { return(null); } return(new ServiceConfiguration(this.ServiceConfigurationID, this.InstanceID, paymentConfiguration ?? new PaymentConfiguration(this.PaymentConfigurationID), this.ExternalID, this.Name, this.Updated, this.Created)); }
public CreatePaymentLinkCommand(ILogger logger, BaseDbContext dbContext, EndpointConfig endpointConfig, GetExistingPaymentLinkQuery getExistingPaymentLinkQuery, PaymentConfiguration paymentConfiguration) : base(logger, dbContext) { _endpointConfig = endpointConfig; _paymentConfiguration = paymentConfiguration; _getExistingPaymentLinkQuery = getExistingPaymentLinkQuery; }
public async Task <ActionResult> DeleteConfirmed(int id) { PaymentConfiguration paymentConfiguration = await Task.Run(() => configService.Get(id)); await Task.Run(() => configService.Delete(paymentConfiguration)); return(RedirectToAction("Index")); }
public async Task <PaymentConfiguration> UpdatePaymentConfiguration(PaymentConfiguration paymentConfiguration) { // validate the payment configuration before saving. PayPalGateway.ValidateConfiguration(paymentConfiguration); PaymentConfiguration paymentConfig = await ApplicationDomain.Instance.PaymentConfigurationRepository.UpdateAsync(paymentConfiguration); return(paymentConfig); }
/// <summary> /// Initiate Refund. /// </summary> /// <param name="paymentId">The PaymentId.</param> /// <param name="amount">The Amount.</param> /// <returns>returns PayUMoneyRefundResponse.</returns> public static async Task <RefundResponse> RefundPayment(string paymentId, string amount) { PaymentConfiguration payconfig = await GetPaymentConfigAsync(); NameValueCollection header = new NameValueCollection(); header.Add("Authorization", payconfig.WebExperienceProfileId); RefundResponse response = await PostAsync <RefundResponse>(header, string.Format(Constant.PaymentRefundUrl, payconfig.ClientId, paymentId, amount)); return(await Task.FromResult(response)); }
/// <summary> /// Get Payment status. /// </summary> /// <param name="paymentId">The PaymentId.</param> /// <returns>returns transaction response.</returns> public static async Task <TransactionStatusResponse> GetPaymentStatus(string paymentId) { PaymentConfiguration payconfig = await GetPaymentConfigAsync(); NameValueCollection header = new NameValueCollection(); header.Add("Authorization", payconfig.WebExperienceProfileId); TransactionStatusResponse response = await PostAsync <TransactionStatusResponse>(header, string.Format(Constant.PaymentStatusUrl, payconfig.ClientId, paymentId)); return(await Task.FromResult(response)); }
public IActionResult CheckOut() { var service = new { Url = "https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5", MerchantId = "2000132", HashKey = "5294y06JbISpM5x9", HashIV = "v77hoKGq4kWxNNIS", ServerUrl = "https://test.com/api/payment/callback", ClientUrl = "https://test.com/payment/success" }; var transaction = new { No = "test00003", Description = "測試購物系統", Date = DateTime.Now, Method = EPaymentMethod.Credit, Items = new List <Item> { new Item { Name = "手機", Price = 14000, Quantity = 2 }, new Item { Name = "隨身碟", Price = 900, Quantity = 10 } } }; IPayment payment = new PaymentConfiguration() .Send.ToApi( url: service.Url) .Send.ToMerchant( service.MerchantId) .Send.UsingHash( key: service.HashKey, iv: service.HashIV) .Return.ToServer( url: service.ServerUrl) .Return.ToClient( url: service.ClientUrl) .Transaction.New( no: transaction.No, description: transaction.Description, date: transaction.Date) .Transaction.UseMethod( method: transaction.Method) .Transaction.WithItems( items: transaction.Items) .Generate(); return(View(payment)); }
public PaymentReturnConfiguration( PaymentConfiguration configuration, Action <string> setServerUrl, Action <string> setClientUrl, Action <string> setClientUrlWithExtraPaidInfo) { _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _setServerUrl = setServerUrl ?? throw new ArgumentNullException(nameof(setServerUrl)); _setClientUrl = setClientUrl ?? throw new ArgumentNullException(nameof(setClientUrl)); _setClientUrlWithExtraPaidInfo = setClientUrlWithExtraPaidInfo ?? throw new ArgumentNullException(nameof(setClientUrlWithExtraPaidInfo)); }
/// <summary> /// Get Payment status. /// </summary> /// <param name="paymentId">The PaymentId.</param> /// <returns>returns transaction response.</returns> public static async Task<TransactionStatusResponse> GetPaymentStatus(string paymentId) { PaymentConfiguration payconfig = await GetPaymentConfigAsync().ConfigureAwait(false); NameValueCollection header = new NameValueCollection { { "Authorization", payconfig.WebExperienceProfileId } }; TransactionStatusResponse response = await PostAsync<TransactionStatusResponse>(header, string.Format(CultureInfo.InvariantCulture, Constant.PaymentStatusUrl, payconfig.ClientId, paymentId)).ConfigureAwait(false); return response; }
/// <summary> /// Initiate Refund. /// </summary> /// <param name="paymentId">The PaymentId.</param> /// <param name="amount">The Amount.</param> /// <returns>returns PayUMoneyRefundResponse.</returns> public static async Task<RefundResponse> RefundPayment(string paymentId, string amount) { PaymentConfiguration payconfig = await GetPaymentConfigAsync().ConfigureAwait(false); NameValueCollection header = new NameValueCollection { { "Authorization", payconfig.WebExperienceProfileId } }; RefundResponse response = await PostAsync<RefundResponse>(header, string.Format(CultureInfo.InvariantCulture, Constant.PaymentRefundUrl, payconfig.ClientId, paymentId, amount)).ConfigureAwait(false); return response; }
public async Task <ActionResult> Create([Bind(Include = "Id,Secret")] PaymentConfiguration paymentConfiguration) { paymentConfiguration.DateCreated = DateTime.Now; paymentConfiguration.CreatedBy = User.Identity.Name; //paymentConfiguration.Secret = StringEncrypterDecrypter.StringCipher.Encrypt(paymentConfiguration.Secret, String.Format("{0}{1}{2}{3}{4}{5}{6}", User.Identity.Name, paymentConfiguration.DateCreated.Year, paymentConfiguration.DateCreated.Month, paymentConfiguration.DateCreated.Day, paymentConfiguration.DateCreated.Hour, paymentConfiguration.DateCreated.Minute, paymentConfiguration.DateCreated.Second, paymentConfiguration.DateCreated.Millisecond)); if (ModelState.IsValid) { configService.Insert(paymentConfiguration); return(RedirectToAction("Index")); } return(View(paymentConfiguration)); }
/// <summary> /// prepares Remote post by populate all the necessary fields to generate PayUMoney post request. /// </summary> /// <param name="order">order details.</param> /// <param name="returnUrl">return url.</param> /// <returns>return remote post.</returns> private async Task <RemotePost> PrepareRemotePost(OrderViewModel order, string returnUrl) { string fname = string.Empty; string phone = string.Empty; string email = string.Empty; CustomerRegistrationRepository customerRegistrationRepository = new CustomerRegistrationRepository(ApplicationDomain.Instance); CustomerViewModel customerRegistrationInfo = await customerRegistrationRepository.RetrieveAsync(order.CustomerId); fname = customerRegistrationInfo.FirstName; phone = customerRegistrationInfo.Phone; email = customerRegistrationInfo.Email; decimal paymentTotal = 0; StringBuilder productSubs = new StringBuilder(); StringBuilder prodQuants = new StringBuilder(); foreach (var subscriptionItem in order.Subscriptions) { productSubs.Append(":").Append(subscriptionItem.SubscriptionId); prodQuants.Append(":").Append(subscriptionItem.Quantity.ToString()); paymentTotal += Math.Round(subscriptionItem.Quantity * subscriptionItem.SeatPrice, Resources.Culture.NumberFormat.CurrencyDecimalDigits); } productSubs.Remove(0, 1); prodQuants.Remove(0, 1); System.Collections.Specialized.NameValueCollection inputs = new System.Collections.Specialized.NameValueCollection(); PaymentConfiguration payconfig = await this.GetAPaymentConfigAsync(); inputs.Add("key", payconfig.ClientId); inputs.Add("txnid", this.GenerateTransactionId()); inputs.Add("amount", paymentTotal.ToString()); inputs.Add("productinfo", productSubs.ToString()); inputs.Add("firstname", fname); inputs.Add("phone", phone); inputs.Add("email", email); inputs.Add("udf1", order.OperationType.ToString()); inputs.Add("udf2", prodQuants.ToString()); inputs.Add("surl", returnUrl + "&payment=success&PayerId=" + inputs.Get("txnid")); inputs.Add("furl", returnUrl + "&payment=failure&PayerId=" + inputs.Get("txnid")); inputs.Add("service_provider", Constant.PAYUPAISASERVICEPROVIDER); string hashString = inputs.Get("key") + "|" + inputs.Get("txnid") + "|" + inputs.Get("amount") + "|" + inputs.Get("productInfo") + "|" + inputs.Get("firstName") + "|" + inputs.Get("email") + "|" + inputs.Get("udf1") + "|" + inputs.Get("udf2") + "|||||||||" + payconfig.ClientSecret; // payconfig.ClientSecret; string hash = this.GenerateHash512(hashString); inputs.Add("hash", hash); RemotePost myremotepost = new RemotePost(); myremotepost.SetUrl(this.GetPaymentUrl(payconfig.AccountType)); myremotepost.SetInputs(inputs); return(myremotepost); }
// GET: PaymentConfigurations/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PaymentConfiguration paymentConfiguration = await Task.Run(() => configService.Get(id.Value)); if (paymentConfiguration == null) { return(HttpNotFound()); } return(View(paymentConfiguration)); }
private PaymentConfiguration GetPaymentConfiguration() { // Get Config PaymentConfiguration paymentConfiguration = new PaymentConfiguration(); var paymentConfigs = from pc in db.PaymentConfigurations where pc.Status == "A" orderby pc.PaymentConfigurationID descending select pc; foreach (var paymentConfig in paymentConfigs) { // get the most recent active config. paymentConfiguration = (PaymentConfiguration)paymentConfig; break; } return(paymentConfiguration); }
/// <summary> /// Applies business rules to <see cref="PaymentConfiguration"/> instances. /// </summary> /// <param name="paymentConfiguration">A payment configuration instance.</param> /// <returns>A task.</returns> private void Normalize(PaymentConfiguration paymentConfiguration) { paymentConfiguration.AssertNotNull(nameof(paymentConfiguration)); // Dont validate WebExperienceProfileId since it will break upgrade as existing deployments dont have this configuration. paymentConfiguration.ClientId.AssertNotEmpty("ClientId"); paymentConfiguration.ClientSecret.AssertNotEmpty("ClientSecret"); paymentConfiguration.AccountType.AssertNotEmpty("Mode"); if (!supportedPaymentModes.Contains(paymentConfiguration.AccountType)) { throw new PartnerDomainException(Resources.InvalidPaymentModeErrorMessage); } }
/// <summary> /// Updates the payment configuration. /// </summary> /// <param name="newPaymentConfiguration">The new payment configuration.</param> /// <returns>The updated payment configuration.</returns> public async Task <PaymentConfiguration> UpdateAsync(PaymentConfiguration newPaymentConfiguration) { newPaymentConfiguration.AssertNotNull(nameof(newPaymentConfiguration)); await this.NormalizeAsync(newPaymentConfiguration); var paymentConfigurationBlob = await this.GetPaymentConfigurationBlob(); await paymentConfigurationBlob.UploadTextAsync(JsonConvert.SerializeObject(newPaymentConfiguration)); // invalidate the cache, we do not update it to avoid race condition between web instances await this.ApplicationDomain.CachingService.ClearAsync(PaymentConfigurationRepository.PaymentConfigurationCacheKey); return(newPaymentConfiguration); }
/// <summary> /// Updates the payment configuration. /// </summary> /// <param name="newPaymentConfiguration">The new payment configuration.</param> /// <returns>The updated payment configuration.</returns> public async Task <PaymentConfiguration> UpdateAsync(PaymentConfiguration newPaymentConfiguration) { newPaymentConfiguration.AssertNotNull(nameof(newPaymentConfiguration)); await NormalizeAsync(newPaymentConfiguration).ConfigureAwait(false); CloudBlockBlob paymentConfigurationBlob = await GetPaymentConfigurationBlob().ConfigureAwait(false); await paymentConfigurationBlob.UploadTextAsync(JsonConvert.SerializeObject(newPaymentConfiguration)).ConfigureAwait(false); // invalidate the cache, we do not update it to avoid race condition between web instances await ApplicationDomain.CachingService.ClearAsync(PaymentConfigurationCacheKey).ConfigureAwait(false); return(newPaymentConfiguration); }
/// <summary> /// Applies business rules to <see cref="PaymentConfiguration"/> instances. /// </summary> /// <param name="paymentConfiguration">A payment configuration instance.</param> /// <returns>A task.</returns> private async Task NormalizeAsync(PaymentConfiguration paymentConfiguration) { paymentConfiguration.AssertNotNull(nameof(paymentConfiguration)); paymentConfiguration.ClientId.AssertNotEmpty("ClientId"); paymentConfiguration.ClientSecret.AssertNotEmpty("ClientSecret"); paymentConfiguration.AccountType.AssertNotEmpty("Mode"); if (!this.supportedPaymentModes.Contains(paymentConfiguration.AccountType)) { throw new PartnerDomainException("Payment mode is not supported"); } await Task.FromResult(0); }