public async Task <IActionResult> Donate([FromServices] IPaymentProvider provider, int donation, string email) { var request = new PaymentInitializationRequest(); request.Initialize(new Dictionary <string, string> { [PAYSTACK_AMOUNT_KEY] = (donation * 100).ToString(), [PAYSTACK_INITIALIZATION_REFERENCE_KEY] = Guid.NewGuid().ToString(), [PAYSTACK_EMAIL_KEY] = email, [PAYSTACK_CALLBACK_URL_KEY] = Url.Action("confirm") }); var response = await provider.MakePayment(request); return(Json(response)); }
public async Task IsInitializePaymentParsingCorrect() { paystack.Caller = new TestPaystackCaller <PaymentInitializationResponse>(); const string expectedMessage = "Authorization URL created"; const string expectedStatus = "success"; var request = new PaymentInitializationRequest(); request.Initialize(new Dictionary <string, string> { [PAYSTACK_AMOUNT_KEY] = 500000.ToString(), [PAYSTACK_INITIALIZATION_REFERENCE_KEY] = "500", [PAYSTACK_EMAIL_KEY] = "[email protected]", [PAYSTACK_CALLBACK_URL_KEY] = "https://callback.test.com/endpoint" }); var response = await paystack.MakePayment(request); Assert.AreEqual(expectedMessage, response.Message); Assert.AreEqual(expectedStatus, response.Status); Assert.IsTrue(response.AuthorizationUrl != null); }