//generate url for newtransaction public void NewTransaction() { String sellerOrderId; Random rn = new Random(); sellerOrderId = rn.Next(1, 99999999).ToString(); String orderTotalAmount = this.Request.Form["orderTotalAmount"]; String orderTotalCurrencyCode = this.Request.Form["orderTotalCurrencyCode"]; String customInformation = this.Request.Form["customInformation"]; parameters = new Dictionary <string, string>(6); parameters.Add(PWAINConstants.SELLER_ORDER_ID, sellerOrderId); parameters.Add(PWAINConstants.ORDER_TOTAL_AMOUNT, orderTotalAmount); parameters.Add(PWAINConstants.ORDER_TOTAL_CURRENCY_CODE, orderTotalCurrencyCode); parameters.Add(PWAINConstants.REDIRECT_URL, "{{=it.returnUrl}}"); /*Set optional parameters*/ //For testing in Sandbox mode, "false" when going live parameters.Add(PWAINConstants.IS_SANDBOX, "true"); //Transaction timeout in seconds parameters.Add(PWAINConstants.TRANSACTION_TIMEOUT, "1000"); parameters.Add(PWAINConstants.CUSTOM_INFORMATION, customInformation); merchantConfiguration = new MerchantConfiguration.Builder().WithSellerIdValue(sellerId).WithAwsAccessKeyIdValue(accessKey).WithAwsSecretKeyIdValue(secretKey).build(); pwaInBackendSDK = new PWAINBackendSDK(merchantConfiguration); String url = pwaInBackendSDK.GetPaymentUrl(parameters); ViewBag.Message = url; Response.Redirect(url); }
protected override async Task <IPaymentRedirectResponse> PaymentRedirectChargeGenerator(ICharge charge) { try { MerchantConfiguration merchantConfiguration; PWAINBackendSDK pwainBackendSDK; Dictionary <String, String> parameters = new Dictionary <string, string>(); parameters.Add(PWAINConstants.SELLER_ORDER_ID, charge.TransactionId.ToString()); parameters.Add(PWAINConstants.ORDER_TOTAL_AMOUNT, charge.Amount.ToString()); parameters.Add(PWAINConstants.ORDER_TOTAL_CURRENCY_CODE, charge.Currency.ToUpper()); parameters.Add(PWAINConstants.REDIRECT_URL, _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.AmazonPay.ReturnUrl)); if (_settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.AmazonPay.IsSandbox).Equals("true")) { parameters.Add(PWAINConstants.IS_SANDBOX, "true"); } merchantConfiguration = new MerchantConfiguration.Builder().WithSellerIdValue(_settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.AmazonPay.MerchantId)).WithAwsAccessKeyIdValue(_settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.AmazonPay.AccessKey)).WithAwsSecretKeyIdValue(_settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.AmazonPay.SecretKey)).build(); pwainBackendSDK = new PWAINBackendSDK(merchantConfiguration); string chargeUrl = pwainBackendSDK.GetPaymentUrl(parameters); return(GetPaymentRedirectResponse(chargeUrl, "")); } catch (Exception ex) { _logger.Log(LogCategory.Error, new Exception("Failed to create redirect charge", ex)); return(GetPaymentRedirectResponse(null, ex.Message)); } }