public async Task Requesting_And_Verifying_Work() { const long expectedTrackingNumber = 1; const string expectedCallbackUrl = "http://www.mywebsite.com"; const string paymentPageUrl = "/virtual"; await GatewayTestHelpers.TestGatewayAsync( gateways => { var builder = gateways .AddParbadVirtual() .WithOptions(options => { options.GatewayPath = paymentPageUrl; }); return(builder); }, invoice => { invoice .SetTrackingNumber(expectedTrackingNumber) .SetAmount(ExpectedAmount) .SetCallbackUrl(expectedCallbackUrl) .UseParbadVirtual(); }, handler => { }, context => { context.Request.Scheme = "http"; context.Request.Host = new HostString("localhost", 5000); context.Request.Query = new QueryCollection(new Dictionary <string, StringValues> { { "result", "true" }, { "TransactionCode", ExpectedTransactionCode } }); }, result => GatewayOnResultHelper.OnRequestResult( result, ParbadVirtualGateway.Name, GatewayTransporterDescriptor.TransportType.Post, expectedPaymentPageUrl: $"http://localhost:5000{paymentPageUrl}", expectedForm: new Dictionary <string, string> { { "CommandType", "request" }, { "trackingNumber", expectedTrackingNumber.ToString() }, { "amount", ExpectedAmount.ToString() } }), result => GatewayOnResultHelper.OnFetchResult(result, expectedTrackingNumber, ExpectedAmount, ParbadVirtualGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, expectedTrackingNumber, ExpectedAmount, ParbadVirtualGateway.Name, ExpectedTransactionCode)); }
public async Task MobileGateway_Requesting_And_Verifying_Work() { await GatewayTestHelpers.TestGatewayAsync( gateways => { return(gateways .AddSaman() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.MerchantId = ExpectedMerchantId; account.Password = "******"; }); }) .WithOptions(options => { options.WebApiUrl = ApiUrl; options.WebApiTokenUrl = ApiUrl; options.WebPaymentPageUrl = PaymentPageUrl; options.MobileApiTokenUrl = ApiUrl; options.MobileApiVerificationUrl = ApiUrl; options.MobilePaymentPageUrl = ApiUrl; })); }, invoice => { invoice .SetTrackingNumber(ExpectedTrackingNumber) .SetAmount(ExpectedAmount) .SetCallbackUrl(ExpectedCallbackUrl) .EnableSamanMobileGateway() .UseSaman(); }, handler => { handler .Expect(ApiUrl) .WithHttpMethod(HttpMethod.Post) .WithJsonBody <SamanMobilePaymentTokenRequest>(model => { var isModelValid = model.Amount == ExpectedAmount && model.TerminalId == ExpectedMerchantId && model.ResNum == ExpectedTrackingNumber.ToString() && model.Action == "Token" && model.RedirectUrl != null && model.RedirectUrl.StartsWith(ExpectedCallbackUrl); return(isModelValid); }) .Respond(MediaTypes.Json, GetMobileGatewayTokenResponse()); handler .Expect(PaymentPageUrl) .WithPartialContent("verifyTransaction") .Respond(MediaTypes.Xml, GetVerificationResponse()); }, context => { context.Request.Query = new QueryCollection(new Dictionary <string, StringValues> { { "state", "OK" }, { "ResNum", ExpectedTransactionCode }, { "RefNum", "test" } }); }, result => GatewayOnResultHelper.OnRequestResult( result, SamanGateway.Name, GatewayTransporterDescriptor.TransportType.Post, expectedPaymentPageUrl: PaymentPageUrl, expectedForm: new Dictionary <string, string> { { "Token", "test" } }), result => GatewayOnResultHelper.OnFetchResult(result, ExpectedTrackingNumber, ExpectedAmount, SamanGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, ExpectedTrackingNumber, ExpectedAmount, SamanGateway.Name, ExpectedTransactionCode)); }
public async Task WebGateway_Requesting_And_Verifying_Work() { await GatewayTestHelpers.TestGatewayAsync( gateways => { return(gateways .AddSaman() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.MerchantId = ExpectedMerchantId; account.Password = "******"; }); }) .WithOptions(options => { options.WebApiUrl = ApiUrl; options.WebApiTokenUrl = ApiUrl; options.WebPaymentPageUrl = PaymentPageUrl; options.MobileApiTokenUrl = ApiUrl; options.MobileApiVerificationUrl = ApiUrl; options.MobilePaymentPageUrl = ApiUrl; })); }, invoice => { invoice .SetTrackingNumber(ExpectedTrackingNumber) .SetAmount(ExpectedAmount) .SetCallbackUrl(ExpectedCallbackUrl) .UseSaman(); }, handler => { handler .Expect(ApiUrl) .WithPartialContent("RequestToken") .WithPartialContent(ExpectedMerchantId) .Respond(MediaTypes.Xml, GetWebGatewayTokenResponse()); handler .Expect(ApiUrl) .WithPartialContent("verifyTransaction") .Respond(MediaTypes.Xml, GetVerificationResponse()); }, context => { context.Request.Query = new QueryCollection(new Dictionary <string, StringValues> { { "state", "OK" }, { "ResNum", ExpectedTransactionCode }, { "RefNum", "test" } }); }, result => GatewayOnResultHelper.OnRequestResult( result, SamanGateway.Name, GatewayTransporterDescriptor.TransportType.Post, expectedPaymentPageUrl: PaymentPageUrl, expectedForm: new Dictionary <string, string> { { "Token", "test" }, { FormRedirectUrlKey, ExpectedCallbackUrl } }), result => GatewayOnResultHelper.OnFetchResult(result, ExpectedTrackingNumber, ExpectedAmount, SamanGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, ExpectedTrackingNumber, ExpectedAmount, SamanGateway.Name, ExpectedTransactionCode)); }
public async Task Requesting_And_Verifying_Work() { const long expectedTrackingNumber = 1; const string expectedCallbackUrl = "http://www.mywebsite.com"; const string apiUrl = "http://localhost/"; const string paymentPageUrl = "http://localhost/"; await GatewayTestHelpers.TestGatewayAsync( gateways => { var builder = gateways .AddMellat() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.TerminalId = 1; account.UserName = "******"; account.UserPassword = "******"; }); }) .WithOptions(options => { options.ApiUrl = apiUrl; options.ApiTestUrl = apiUrl; options.PaymentPageUrl = paymentPageUrl; }); return(builder); }, invoice => { invoice .SetTrackingNumber(expectedTrackingNumber) .SetAmount(ExpectedAmount) .SetCallbackUrl(expectedCallbackUrl) .UseMellat(); }, handler => { handler .Expect(apiUrl) .WithPartialContent("bpPayRequest") .Respond(MediaTypes.Xml, GetRequestResponse()); handler .Expect(apiUrl) .WithPartialContent("bpVerifyRequest") .Respond(MediaTypes.Xml, GetVerificationResponse()); handler .Expect(apiUrl) .WithPartialContent("bpSettleRequest") .Respond(MediaTypes.Xml, GetSettleResponse()); }, context => { context.Request.Query = new QueryCollection(new Dictionary <string, StringValues> { { "ResCode", "0" }, { "RefId", "test" }, { "SaleReferenceId", ExpectedTransactionCode } }); context.Request.Form = new FormCollection(new Dictionary <string, StringValues> { { "RefId", ExpectedRefId } }); }, result => GatewayOnResultHelper.OnRequestResult( result, MellatGateway.Name, GatewayTransporterDescriptor.TransportType.Post, expectedPaymentPageUrl: paymentPageUrl, expectedForm: new Dictionary <string, string> { { "RefId", ExpectedRefId } }), result => GatewayOnResultHelper.OnFetchResult(result, expectedTrackingNumber, ExpectedAmount, MellatGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, expectedTrackingNumber, ExpectedAmount, MellatGateway.Name, expectedTransactionCode: ExpectedTransactionCode)); }
public async Task Requesting_And_Verifying_Work() { const string expectedRefId = "test"; const long expectedTrackingNumber = 1; const string expectedCallbackUrl = "http://www.mywebsite.com"; const string apiUrl = "http://localhost/"; const string paymentPageUrl = "http://localhost/"; await GatewayTestHelpers.TestGatewayAsync( gateways => { var builder = gateways .AddIranKish() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.MerchantId = ExpectedMerchantId; account.Sha1Key = "testkey"; }); }) .WithOptions(options => { options.ApiTokenUrl = apiUrl; options.ApiVerificationUrl = apiUrl; options.PaymentPageUrl = paymentPageUrl; }); return(builder); }, invoice => { invoice .SetTrackingNumber(expectedTrackingNumber) .SetAmount(ExpectedAmount) .SetCallbackUrl(expectedCallbackUrl) .UseIranKish(); }, handler => { handler .Expect(apiUrl) .WithPartialContent("MakeToken") .Respond(MediaTypes.Xml, GetRequestResponse()); handler .Expect(apiUrl) .WithPartialContent("KicccPaymentsVerification") .Respond(MediaTypes.Xml, GetVerificationResponse()); }, context => { context.Request.Query = new QueryCollection(new Dictionary <string, StringValues> { { "ResultCode", "100" }, { "Token", ExpectedToken }, { "MerchantId", ExpectedMerchantId }, { "InvoiceNumber", expectedTrackingNumber.ToString() }, { "ReferenceId", ExpectedTransactionCode } }); }, result => GatewayOnResultHelper.OnRequestResult( result, IranKishGateway.Name, GatewayTransporterDescriptor.TransportType.Post, expectedPaymentPageUrl: paymentPageUrl, expectedForm: new Dictionary <string, string> { { "merchantid", expectedRefId }, { "token", ExpectedToken } }), result => GatewayOnResultHelper.OnFetchResult(result, expectedTrackingNumber, ExpectedAmount, IranKishGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, expectedTrackingNumber, ExpectedAmount, IranKishGateway.Name, ExpectedTransactionCode)); }
public async Task Requesting_And_Verifying_Work() { const string expectedRefId = "test"; const long expectedTrackingNumber = 1; const string expectedCallbackUrl = "http://www.mywebsite.com"; const string apiUrl = "http://localhost/"; const string paymentPageUrl = "http://localhost/"; await GatewayTestHelpers.TestGatewayAsync( gateways => { var builder = gateways .AddAsanPardakht() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.UserName = "******"; account.Password = "******"; account.Key = "QWxsLWluLTEgdG9vbHMgb24gdGhlIEludGVybmV0"; account.IV = "QWxsLWluLTEgdG9vbHMgb24gdGhlIEludGVybmV0"; account.MerchantConfigurationId = "test"; }); }) .WithOptions(options => { options.ApiUrl = apiUrl; options.PaymentPageUrl = paymentPageUrl; }); builder.Services.RemoveAll <IAsanPardakhtCrypto>(); builder.Services.AddSingleton(_crypto); return(builder); }, invoice => { invoice .SetTrackingNumber(expectedTrackingNumber) .SetAmount(ExpectedAmount) .SetCallbackUrl(expectedCallbackUrl) .UseAsanPardakht(); }, handler => { handler .Expect(apiUrl) .WithPartialContent("RequestOperation") .Respond(MediaTypes.Xml, GetRequestResponse(expectedRefId)); handler .Expect(apiUrl) .WithPartialContent("RequestVerification") .Respond(MediaTypes.Xml, GetVerificationResponse()); handler .Expect(apiUrl) .WithPartialContent("RequestReconciliation") .Respond(MediaTypes.Xml, GetSettleResponse()); }, context => { context.Request.Form = new FormCollection(new Dictionary <string, StringValues> { { "ReturningParams", "test" } }); }, result => GatewayOnResultHelper.OnRequestResult( result, AsanPardakhtGateway.Name, GatewayTransporterDescriptor.TransportType.Post, expectedPaymentPageUrl: paymentPageUrl, expectedForm: new Dictionary <string, string> { { "RefId", expectedRefId } }), result => GatewayOnResultHelper.OnFetchResult(result, expectedTrackingNumber, ExpectedAmount, AsanPardakhtGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, expectedTrackingNumber, ExpectedAmount, AsanPardakhtGateway.Name)); }
public async Task Requesting_And_Verifying_Work() { const long expectedTrackingNumber = 1; const long expectedAmount = 1000; const string expectedCallbackUrl = "http://www.mywebsite.com"; const string apiRequestUrl = "http://localhost/request"; const string apiVerificationUrl = "http://localhost/verify"; const string paymentPageUrl = "http://localhost/"; await GatewayTestHelpers.TestGatewayAsync( gateways => { return(gateways.AddMelli() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.MerchantId = "test"; account.TerminalId = "test"; account.TerminalKey = "853f31351e51cd9c5222c28e408bf2a3"; }); }) .WithOptions(options => { options.ApiRequestUrl = apiRequestUrl; options.ApiVerificationUrl = apiVerificationUrl; options.PaymentPageUrl = paymentPageUrl; })); }, invoice => { invoice .SetTrackingNumber(expectedTrackingNumber) .SetAmount(expectedAmount) .SetCallbackUrl(expectedCallbackUrl) .UseMelli(); }, handler => { handler .Expect(apiRequestUrl) .Respond(MediaTypes.Json, JsonConvert.SerializeObject(new { ResCode = 0, Token = "test" })); handler .Expect(apiVerificationUrl) .Respond(MediaTypes.Json, JsonConvert.SerializeObject(new { ResCode = 0, Token = "test", Description = "good", RetrivalRefNo = Guid.NewGuid().ToString("N") })); }, context => { context.Request.Query = new QueryCollection(new Dictionary <string, StringValues> { { "ResCode", "0" }, { "Token", "test" }, { "OrderId", "1" } }); }, result => GatewayOnResultHelper.OnRequestResult( result, MelliGateway.Name, GatewayTransporterDescriptor.TransportType.Redirect, additionalChecks: () => { var uri = new Uri(result.GatewayTransporter.Descriptor.Url); var queries = QueryHelpers.ParseQuery(uri.Query); Assert.IsTrue(queries.ContainsKey("token")); Assert.AreEqual("test", (string)queries["token"]); }), result => GatewayOnResultHelper.OnFetchResult(result, expectedTrackingNumber, expectedAmount, MelliGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, expectedTrackingNumber, expectedAmount, MelliGateway.Name)); }
public async Task Requesting_And_Verifying_Work() { const long expectedTrackingNumber = 1; const long expectedAmount = 1000; const string expectedCallbackUrl = "http://www.mywebsite.com"; const string apiRequestUrl = "http://localhost/request"; const string apiVerificationUrl = "http://localhost/verify"; const string expectedTransactionCode = "test"; const string apiKey = "X-API-KEY"; await GatewayTestHelpers.TestGatewayAsync( gateways => { return(gateways.AddIdPay() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.Api = "test"; }); }) .WithOptions(options => { options.ApiRequestUrl = apiRequestUrl; options.ApiVerificationUrl = apiVerificationUrl; })); }, invoice => { invoice .SetTrackingNumber(expectedTrackingNumber) .SetAmount(expectedAmount) .SetCallbackUrl(expectedCallbackUrl) .UseIdPay(); }, handler => { handler .Expect(apiRequestUrl) .WithHeaders(apiKey, "test") .WithJsonBody <IdPayRequestModel>(model => { var isValid = model.Amount == expectedAmount && model.Callback.StartsWith(expectedCallbackUrl) && model.OrderId == expectedTrackingNumber; return(isValid); }) .Respond(MediaTypes.Json, JsonConvert.SerializeObject(new { Link = "test" })); handler .Expect(apiVerificationUrl) .WithHeaders(apiKey, "test") .WithJsonBody <IdPayVerifyModel>(model => { var isValid = model.Id == "test" && model.OrderId == expectedTrackingNumber; return(isValid); }) .Respond(MediaTypes.Json, JsonConvert.SerializeObject(new { Status = "100", track_id = expectedTransactionCode })); }, context => { context.Request.Query = new QueryCollection(new Dictionary <string, StringValues> { { "status", "10" }, { "id", "test" }, { "track_id", expectedTransactionCode }, { "order_id", expectedTrackingNumber.ToString() }, { "amount", expectedAmount.ToString() } }); }, result => GatewayOnResultHelper.OnRequestResult( result, IdPayGateway.Name, GatewayTransporterDescriptor.TransportType.Redirect, expectedPaymentPageUrl: "test"), result => GatewayOnResultHelper.OnFetchResult(result, expectedTrackingNumber, expectedAmount, IdPayGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, expectedTrackingNumber, expectedAmount, IdPayGateway.Name)); }
public async Task Requesting_And_Verifying_Work() { const string expectedCallbackUrl = "http://www.mywebsite.com"; const string apiCheckPaymentUrl = "http://localhost/CheckTransactionResult"; const string apiVerificationUrl = "http://localhost/VerifyPayment"; const string paymentPageUrl = "http://localhost/"; await GatewayTestHelpers.TestGatewayAsync( gateways => { var builder = gateways .AddPasargad() .WithAccounts(accounts => { accounts.AddInMemory(account => { account.PrivateKey = "test"; account.MerchantCode = ExpectedMerchantCode; account.TerminalCode = ExpectedTerminalCode; }); }) .WithOptions(options => { options.ApiCheckPaymentUrl = apiCheckPaymentUrl; options.ApiVerificationUrl = apiVerificationUrl; options.PaymentPageUrl = paymentPageUrl; }); builder.Services.RemoveAll <IPasargadCrypto>(); builder.Services.AddSingleton(_crypto); return(builder); }, invoice => { invoice .SetTrackingNumber(ExpectedTrackingNumber) .SetAmount(ExpectedAmount) .SetCallbackUrl(expectedCallbackUrl) .UsePasargad(); }, handler => { handler .When("*CheckTransactionResult") .Respond(MediaTypes.Xml, GetCheckCallbackResponse()); handler .When("*VerifyPayment") .Respond(MediaTypes.Xml, GetVerificationResponse()); }, context => { context.Request.Query = new QueryCollection(new Dictionary <string, StringValues> { { "iN", ExpectedTrackingNumber.ToString() }, { "iD", "test" }, { "tref", ExpectedTransactionCode }, { "result", "true" } }); }, result => GatewayOnResultHelper.OnRequestResult( result, PasargadGateway.Name, GatewayTransporterDescriptor.TransportType.Post, expectedPaymentPageUrl: paymentPageUrl, expectedForm: new Dictionary <string, string> { { "merchantCode", ExpectedMerchantCode }, { "terminalCode", ExpectedTerminalCode }, { "invoiceNumber", ExpectedTrackingNumber.ToString() }, { "amount", ExpectedAmount.ToString() }, { "redirectAddress", expectedCallbackUrl }, { "action", ExpectedActionNumber }, { "sign", ExpectedSignedValue } }), result => GatewayOnResultHelper.OnFetchResult(result, ExpectedTrackingNumber, ExpectedAmount, PasargadGateway.Name), result => GatewayOnResultHelper.OnVerifyResult(result, ExpectedTrackingNumber, ExpectedAmount, PasargadGateway.Name, expectedTransactionCode: ExpectedTransactionCode)); }