-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cleopatra douglas
authored
Jan 12, 2020
1 parent
52eb982
commit 1725c6f
Showing
1 changed file
with
223 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,152 +2,247 @@ | |
using System.Net.Http; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Rave; | ||
using Rave.Models; | ||
using Rave.Models.Account; | ||
using Rave.Models.Card; | ||
using Rave.Models.Charge; | ||
using Rave.Models.MobileMoney; | ||
using Rave.Models.Subaccount; | ||
using Rave.Models.Tokens; | ||
|
||
using Rave.Models; | ||
using Rave.Models.Account; | ||
using Rave.Models.VirtualCard; | ||
using Rave.Models.Card; | ||
using Rave.Models.Charge; | ||
using Rave.Models.MobileMoney; | ||
using Rave.Models.Subaccount; | ||
using Rave.Models.Tokens; | ||
using Rave.Models.Ebills; | ||
using Rave.Models.Subscriptions; | ||
using Rave.Models.VirtualAccount; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace RaveTests | ||
{ | ||
[TestClass] | ||
public class UnitTest1 | ||
{ | ||
|
||
string txRef = Environment.GetEnvironmentVariable("txRef"); | ||
string successfulFwRef = Environment.GetEnvironmentVariable("successfulFwRef"); | ||
string unCapturedFwRef = Environment.GetEnvironmentVariable("unCapturedFwRef"); | ||
string tranxRef = Environment.GetEnvironmentVariable("tranxRef"); | ||
string PbKey = Environment.GetEnvironmentVariable("PbKey"); | ||
string ScKey = Environment.GetEnvironmentVariable("ScKey"); | ||
|
||
|
||
{ | ||
|
||
string txRef = Environment.GetEnvironmentVariable("txRef"); | ||
string successfulFwRef = Environment.GetEnvironmentVariable("successfulFwRef"); | ||
string unCapturedFwRef = Environment.GetEnvironmentVariable("unCapturedFwRef"); | ||
string tranxRef = Environment.GetEnvironmentVariable("tranxRef"); | ||
string PbKey = Environment.GetEnvironmentVariable("PbKey"); | ||
string ScKey = Environment.GetEnvironmentVariable("ScKey"); | ||
|
||
|
||
[TestMethod] | ||
public void preauthTest() | ||
{ | ||
|
||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var preauthCard = new PreAuth(raveConfig); | ||
|
||
var card = new Card("5377283645077450", "09", "21", "789"); | ||
|
||
var preauthResponse = preauthCard.Preauthorize(new PreAuthParams(raveConfig.PbfPubKey, raveConfig.SecretKey, "Olufumi", "Obafumiso", "[email protected]", 120, "USD", card) { TxRef = txRef }).Result; | ||
|
||
|
||
try | ||
{ | ||
Assert.IsNotNull(preauthResponse.Data); | ||
Assert.AreEqual(preauthResponse.Status, "success"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
|
||
{ | ||
|
||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var preauthCard = new PreAuth(raveConfig); | ||
|
||
var card = new Card("5377283645077450", "09", "21", "789"); | ||
|
||
var preauthResponse = preauthCard.Preauthorize(new PreAuthParams(raveConfig.PbfPubKey, raveConfig.SecretKey, "Olufumi", "Obafumiso", "[email protected]", 120, "USD", card) { TxRef = txRef }).Result; | ||
|
||
|
||
try | ||
{ | ||
Assert.IsNotNull(preauthResponse.Data); | ||
Assert.AreEqual(preauthResponse.Status, "success"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
|
||
|
||
} | ||
|
||
[TestMethod] | ||
public void mobileMoneyTest() | ||
{ | ||
|
||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var mobilemoney = new ChargeMobileMoney(raveConfig); | ||
|
||
var Payload = new MobileMoneyParams(PbKey, ScKey, "Anonymous", "customer", "[email protected]", 1055, "GHS", "054709929220", "MTN", "GH", "mobilemoneygh", tranxRef); | ||
var cha = mobilemoney.Charge(Payload).Result; | ||
|
||
try | ||
{ | ||
Assert.IsNotNull(cha.Data); | ||
Console.WriteLine(cha.Data); | ||
Assert.AreEqual("success", cha.Status); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
} | ||
|
||
{ | ||
|
||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var mobilemoney = new ChargeMobileMoney(raveConfig); | ||
|
||
var Payload = new MobileMoneyParams(PbKey, ScKey, "Anonymous", "customer", "[email protected]", 1055, "GHS", "054709929220", "MTN", "GH", "mobilemoneygh", tranxRef); | ||
var cha = mobilemoney.Charge(Payload).Result; | ||
|
||
try | ||
{ | ||
Assert.IsNotNull(cha.Data); | ||
Console.WriteLine(cha.Data); | ||
Assert.AreEqual("success", cha.Status); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void accountTest() | ||
{ | ||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var accountc = new ChargeAccount(raveConfig); | ||
|
||
var Payload = new AccountParams(PbKey, ScKey, "customer", "customer", "[email protected]", "0690000031", 1000, "044", "NGN","MC-0292920"); | ||
var chargeResponse = accountc.Charge(Payload).Result; | ||
|
||
if (chargeResponse.Data.Status == "success-pending-validation") | ||
{ | ||
|
||
Payload.Otp = "12345"; | ||
chargeResponse = accountc.Charge(Payload).Result; | ||
} | ||
// ValidateAccountCharge(chargeResponse.Data.FlwRef); | ||
|
||
Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("success", chargeResponse.Status); | ||
} | ||
|
||
|
||
{ | ||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var accountc = new ChargeAccount(raveConfig); | ||
|
||
var Payload = new AccountParams(PbKey, ScKey, "customer", "customer", "[email protected]", "0690000031", 1000, "044", "NGN", "MC-0292920"); | ||
var chargeResponse = accountc.Charge(Payload).Result; | ||
|
||
if (chargeResponse.Data.Status == "success-pending-validation") | ||
{ | ||
|
||
Payload.Otp = "12345"; | ||
chargeResponse = accountc.Charge(Payload).Result; | ||
} | ||
// ValidateAccountCharge(chargeResponse.Data.FlwRef); | ||
|
||
Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("success", chargeResponse.Status); | ||
} | ||
|
||
|
||
[TestMethod] | ||
public void CreateSubAccountTest() | ||
{ | ||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var subacc = new CreateSubAccount(raveConfig); | ||
|
||
var payload = new SubAccountParams(ScKey, "0690000031", "0690000031", "TEST BUSINESS", "[email protected]", "0900000000", "0900000000"); | ||
var chargeResponse = subacc.Charge(payload).Result; | ||
|
||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("error", chargeResponse.Status); | ||
} | ||
|
||
{ | ||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var subacc = new CreateSubAccount(raveConfig); | ||
|
||
var payload = new SubAccountParams(ScKey, "0690000031", "0690000031", "TEST BUSINESS", "[email protected]", "0900000000", "0900000000"); | ||
var chargeResponse = subacc.Charge(payload).Result; | ||
|
||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("error", chargeResponse.Status); | ||
} | ||
|
||
[TestMethod] | ||
public void TokenTest() | ||
{ | ||
|
||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var tokenCard = new Tokenize(raveConfig); | ||
|
||
{ | ||
|
||
var raveConfig = new RaveConfig(PbKey, ScKey, false); | ||
var tokenCard = new Tokenize(raveConfig); | ||
|
||
var tokenparam = new TokensParams(raveConfig.SecretKey, "Olufumi", "Obafumiso", "[email protected]", tranxRef, 100, "NGN", "NG") | ||
{ | ||
Token = "flw-t1nf-139d69763063262928b77bc1f4fba199-m03k", | ||
Narration = "Test", | ||
}; | ||
var tokenResponse = tokenCard.Charge(tokenparam).Result; | ||
|
||
|
||
try | ||
{ | ||
Assert.IsNotNull(tokenResponse.Data); | ||
Assert.AreEqual(tokenResponse.Status, "success"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
|
||
|
||
} | ||
|
||
//[TestMethod] | ||
//public void CreateVirtualAccountTest() | ||
//{ | ||
// var raveConfig = new RaveConfig(PbKey, "FLWSECK-70a24fa0ffd673aef511b443dd49ff98-X", false); | ||
// var virtualacc = new CreateVirtualAccounts(raveConfig); | ||
|
||
// var payload = new VirtualAccountParams("FLWPUBK-0f39335476fd86517bb7a3f8281b63e4-X", "FLWSECK -70a24fa0ffd673aef511b443dd49ff98-X", "TEST-C-ACCOUNT", "[email protected]", "FALSE", "1", 100, "1", "TRF-SHDJß"); | ||
// var chargeResponse = virtualacc.Charge(payload).Result; | ||
|
||
// System.Console.WriteLine("chargeResponse:"+ chargeResponse.ToString()); | ||
|
||
// // Assert.IsNotNull(chargeResponse.Data); | ||
// Assert.AreEqual("success", chargeResponse.Status); | ||
//} | ||
|
||
} | ||
} | ||
}; | ||
var tokenResponse = tokenCard.Charge(tokenparam).Result; | ||
|
||
|
||
try | ||
{ | ||
Assert.IsNotNull(tokenResponse.Data); | ||
Assert.AreEqual(tokenResponse.Status, "success"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
|
||
|
||
} | ||
|
||
[TestMethod] | ||
public void VirtualStaticAccountTest() | ||
{ | ||
var virtuala = new VirtualAccount(); | ||
var virtualaccountparams = new VirtualAccountParams( "TEST-C-ACCOUNT", ScKey, "[email protected]", "TRF-SHDJß"); | ||
|
||
var chargeResponse = virtuala.CreateStaticVirtualAccount(virtualaccountparams); | ||
|
||
System.Console.WriteLine("chargeResponse:" + chargeResponse.ToString()); | ||
|
||
JObject json = JObject.Parse(chargeResponse); | ||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("success", (string)json.SelectToken("status")); | ||
} | ||
|
||
[TestMethod] | ||
public void VirtualTransactionAccountTest() | ||
{ | ||
var virtuala = new VirtualAccount(); | ||
var virtualaccountparams = new VirtualAccountParams("TEST-C-ACCOUNT", ScKey, "[email protected]", "TRF-SHDJß", "100"); | ||
|
||
var chargeResponse = virtuala.CreateTransactionVirtualAccount(virtualaccountparams); | ||
|
||
System.Console.WriteLine("chargeResponse:" + chargeResponse.ToString()); | ||
|
||
JObject json = JObject.Parse(chargeResponse); | ||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("success", (string)json.SelectToken("status")); | ||
} | ||
|
||
[TestMethod] | ||
public void VirtualDurationAccountTest() | ||
{ | ||
var virtuala = new VirtualAccount(); | ||
var virtualaccountparams = new VirtualAccountParams(1, 2, "TEST-C-ACCOUNT", ScKey, "[email protected]", "TRF-SHDJß", "100"); | ||
|
||
var chargeResponse = virtuala.CreateTransactionVirtualAccount(virtualaccountparams); | ||
|
||
System.Console.WriteLine("chargeResponse:" + chargeResponse.ToString()); | ||
|
||
JObject json = JObject.Parse(chargeResponse); | ||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("success", (string)json.SelectToken("status")); | ||
} | ||
|
||
[TestMethod] | ||
public void CreateEbillsTest() | ||
{ | ||
var ebillscreate = new CreateOrder(); | ||
var ebillscreateparams = new EbillsCreateRequestParams("NGN", 1, "TEST-C", ScKey, "[email protected]", 100, "09384747474", "773838837373", "127.9.0.7"); | ||
|
||
var chargeResponse = ebillscreate.doCreateOrder(ebillscreateparams); | ||
|
||
System.Console.WriteLine("chargeResponse:" + chargeResponse.ToString()); | ||
|
||
JObject json = JObject.Parse(chargeResponse); | ||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("success", (string)json.SelectToken("status")); | ||
} | ||
|
||
[TestMethod] | ||
public void UpdateEbillsTest() | ||
{ | ||
var ebillsupdate = new UpdateOrder(); | ||
var ebillsupdateparams = new EbillsUpdateRequestParams("NGN", ScKey, 500, "RVEBLS-DD2EB67752B9-36138"); | ||
|
||
var chargeResponse = ebillsupdate.doUpdateOrder(ebillsupdateparams); | ||
|
||
System.Console.WriteLine("chargeResponse:" + chargeResponse.ToString()); | ||
|
||
JObject json = JObject.Parse(chargeResponse); | ||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("success", (string)json.SelectToken("status")); | ||
} | ||
|
||
[TestMethod] | ||
public void ListSubscriptions() | ||
{ | ||
var listsubs = new ListSubscriptions(); | ||
|
||
var chargeResponse = listsubs.doListSubscriptions(ScKey); | ||
|
||
System.Console.WriteLine("chargeResponse:" + chargeResponse.ToString()); | ||
|
||
JObject json = JObject.Parse(chargeResponse); | ||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("success", (string)json.SelectToken("status")); | ||
} | ||
|
||
[TestMethod] | ||
public void CreateVirtualCard() | ||
{ | ||
var createvirtualcard = new VirtualCard(); | ||
|
||
var virtualcardparams = new VirtualCardParams(ScKey, "clopat", "NGN", "100", "lagos, lagos", "lagos", "lagos", "0000", "NG", "www.facebook.com"); | ||
var chargeResponse = createvirtualcard.doCreateVirtualCard(virtualcardparams); | ||
|
||
System.Console.WriteLine("chargeResponse:" + chargeResponse.ToString()); | ||
|
||
JObject json = JObject.Parse(chargeResponse); | ||
// Assert.IsNotNull(chargeResponse.Data); | ||
Assert.AreEqual("error", (string)json.SelectToken("status")); | ||
} | ||
|
||
} | ||
} |