Skip to content

Commit

Permalink
Fixed virtaul accounts, cards and added subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cleopatra27 committed Jan 12, 2020
1 parent 072da76 commit cf57c34
Show file tree
Hide file tree
Showing 28 changed files with 4,684 additions and 68 deletions.
1 change: 1 addition & 0 deletions Rave/Models/Charge/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using System.Threading.Tasks;
using Rave.api;
using Rave.Models.VirtualAccount;

namespace Rave.Models.Charge
{
Expand Down
30 changes: 17 additions & 13 deletions Rave/Models/Charge/CreateVirtualAccounts.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using System;using System.Collections.Generic;using System.Text;using System.Net.Http;using System.Threading.Tasks;using Rave.api;using Rave.config;using Newtonsoft.Json;
//using System;
//using System.Collections.Generic;
//using System.Text;
//using System.Net.Http;
//using System.Threading.Tasks;
//using Rave.api;
//using Rave.config;
//using Newtonsoft.Json;
//using Rave.Models.VirtualAccount;

namespace Rave.Models.Charge
{
public class CreateVirtualAccounts : Base<RaveResponse<Account.ResponseData>, Account.ResponseData>
{
public CreateVirtualAccounts(RaveConfig conf) : base(conf) { }
//namespace Rave.Models.Charge
//{
// public class CreateVirtualAccounts : Base<RaveResponse<Card.ResponseData>, Card.ResponseData>
// {
// public CreateVirtualAccounts(RaveConfig conf) : base(conf) { }

public override async Task<RaveResponse<Account.ResponseData>> Charge(IParams Params, bool isRecurring = false){
//if (Params.TxRef.Equals(null))
//{

//}
// public override async Task<RaveResponse<Card.ResponseData>> Create(VirtualAccountParams virtualaccountparams)
// {

var encryptedKey = PayDataEncrypt.GetEncryptionKey(Config.SecretKey);var encryptedData = PayDataEncrypt.EncryptData(encryptedKey, JsonConvert.SerializeObject(Params));var content = new StringContent(JsonConvert.SerializeObject(new { PBFPubKey = Params.PbfPubKey, client = encryptedData, alg = "3DES-24" }), Encoding.UTF8, "application/json");

 var requestMessage = new HttpRequestMessage(HttpMethod.Post, Endpoints.CreateaccountNumber) { Content = content };var result = await RaveRequest.Request(requestMessage);

 return result;}
}
}
// var content = new StringContent(JsonConvert.SerializeObject(new { virtualaccountparams }), Encoding.UTF8, "application/json");
// var requestMessage = new HttpRequestMessage(HttpMethod.Post, Endpoints.CreateaccountNumber) { Content = content };

// var result = await RaveRequest.Request(requestMessage);
// return result;
// }

// }
//}
30 changes: 30 additions & 0 deletions Rave/Models/Ebills/CreateOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using RestSharp;
using Newtonsoft.Json;
namespace Rave.Models.Ebills

{
public class CreateOrder
{
public CreateOrder()
{
}

public string doCreateOrder(EbillsCreateRequestParams ebillscreaterequestparams)
{

var client = new RestClient("https://api.ravepay.co/flwv3-pug/getpaidx/api/ebills/generateorder/");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", JsonConvert.SerializeObject(ebillscreaterequestparams), ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

return response.Content;

}


}
}
58 changes: 58 additions & 0 deletions Rave/Models/Ebills/EbillsCreateRequestParams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Text;
using Rave.Models.Charge;
using Newtonsoft.Json;

namespace Rave.Models.Ebills
{
public class EbillsCreateRequestParams
{
public EbillsCreateRequestParams( string currency, int numberofunits, string narration, string seckey, string email, int amount, string phonenumber, string txRef, string ip)
{
Country = "NG";
Currency = currency;
Numberofunits = numberofunits;
Narration = narration;
SECKEY = seckey;
Amount = amount;
Phonenumber = phonenumber;
Email = email;
TxRef = txRef;
IP = ip;

}


[JsonProperty("country")]
public string Country { get; set; }

[JsonProperty("currency")]
public string Currency { get; set; }

[JsonProperty("numberofunits")]
public int Numberofunits { get; set; }

[JsonProperty("narration")]
public string Narration { get; set; }

[JsonProperty("SECKEY")]
public string SECKEY { get; set; }

[JsonProperty("amount")]
public int Amount { get; set; }

[JsonProperty("phonenumber")]
public string Phonenumber { get; set; }

[JsonProperty("email")]
public string Email { get; set; }

[JsonProperty("txRef")]
public string TxRef { get; set; }

[JsonProperty("IP")]
public string IP { get; set; }

}
}
36 changes: 36 additions & 0 deletions Rave/Models/Ebills/EbillsUpdateRequestParams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Text;
using Rave.Models.Charge;
using Newtonsoft.Json;

namespace Rave.Models.Ebills
{
public class EbillsUpdateRequestParams
{
public EbillsUpdateRequestParams(string currency, string seckey, int amount, string reference)
{

Currency = currency;
SECKEY = seckey;
Amount = amount;
Reference = reference;

}


[JsonProperty("currency")]
public string Currency { get; set; }


[JsonProperty("SECKEY")]
public string SECKEY { get; set; }

[JsonProperty("amount")]
public int Amount { get; set; }


[JsonProperty("reference")]
public string Reference { get; set; }
}
}
28 changes: 28 additions & 0 deletions Rave/Models/Ebills/UpdateOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using RestSharp;
using Newtonsoft.Json;
namespace Rave.Models.Ebills
{
public class UpdateOrder
{
public UpdateOrder()
{
}

public string doUpdateOrder(EbillsUpdateRequestParams ebillsupdaterequestparams)
{

var client = new RestClient("https://api.ravepay.co/flwv3-pug/getpaidx/api/ebills/update/");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", JsonConvert.SerializeObject(ebillsupdaterequestparams), ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

return response.Content;

}

}
}
25 changes: 25 additions & 0 deletions Rave/Models/Subscriptions/ActivateSubscription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using RestSharp;
using Newtonsoft.Json;
namespace Rave.Models.Subscriptions
{
public class ActivateSubscription
{
public ActivateSubscription()
{
}

public string doActivateSubscription(SubscriptionRequestParams activatesubscriptionrequestparams)
{
var client = new RestClient("https://api.ravepay.co/v2/gpx/subscriptions/"+ activatesubscriptionrequestparams .Id+ "/activate?fetch_by_tx="+activatesubscriptionrequestparams.fetch_by_tx+"");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", JsonConvert.SerializeObject( new { activatesubscriptionrequestparams.Seckey }), ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

return response.Content;
}
}
}
26 changes: 26 additions & 0 deletions Rave/Models/Subscriptions/CancelSubscription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using RestSharp;
using Newtonsoft.Json;
namespace Rave.Models.Subscriptions
{
public class CancelSubscription
{
public CancelSubscription()
{
}

public string doCancelSubscription(SubscriptionRequestParams cancelsubscriptionrequestparams)
{

var client = new RestClient("https://api.ravepay.co/v2/gpx/subscriptions/"+ cancelsubscriptionrequestparams .Id+ "/cancel?fetch_by_tx="+ cancelsubscriptionrequestparams .fetch_by_tx+ "");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", JsonConvert.SerializeObject( new { cancelsubscriptionrequestparams.Seckey }), ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

return response.Content;
}
}
}
24 changes: 24 additions & 0 deletions Rave/Models/Subscriptions/FetchSubscription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using RestSharp;
using Newtonsoft.Json;
namespace Rave.Models.Subscriptions
{
public class FetchSubscription
{
public FetchSubscription()
{
}

public string doFetchSubscription(String seckey , String transactionid)
{
var client = new RestClient("https://api.ravepay.co/v2/gpx/subscriptions/query?seckey="+ seckey + "&transaction_id="+ transactionid + "");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

return response.Content;
}
}
}
23 changes: 23 additions & 0 deletions Rave/Models/Subscriptions/ListSubscriptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using RestSharp;
using Newtonsoft.Json;
namespace Rave.Models.Subscriptions
{
public class ListSubscriptions
{
public ListSubscriptions()
{
}

public string doListSubscriptions(String seckey)
{
var client = new RestClient("https://api.ravepay.co/v2/gpx/subscriptions/query?seckey="+ seckey + "");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/json");
IRestResponse response = client.Execute(request);

return response.Content;
}
}
}
32 changes: 32 additions & 0 deletions Rave/Models/Subscriptions/SubscriptionRequestParams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using Rave.Models.Charge;
using Newtonsoft.Json;
namespace Rave.Models.Subscriptions
{
public class SubscriptionRequestParams
{
public SubscriptionRequestParams(string id, string seckey, string fetch_by_tx)
{

Id = id;
Seckey = seckey;
fetch_by_tx = "1";

}


[JsonProperty("id")]
public string Id { get; set; }


[JsonProperty("seckey")]
public string Seckey { get; set; }

[JsonProperty("fetch_by_tx")]
public string fetch_by_tx { get; set; }


}
}
42 changes: 42 additions & 0 deletions Rave/Models/VirtualAccount/VirtualAccount.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,52 @@
using System;
using Newtonsoft.Json;
using RestSharp;

namespace Rave.Models.VirtualAccount
{
public class VirtualAccount
{
public VirtualAccount()
{
}

public String CreateStaticVirtualAccount(VirtualAccountParams virtualaccountparams)
{

var client = new RestClient("https://api.ravepay.co/v2/banktransfers/accountnumbers");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", JsonConvert.SerializeObject( new { virtualaccountparams.email, virtualaccountparams.Is_permanent, virtualaccountparams.seckey, virtualaccountparams.TxRef, virtualaccountparams.Narration }), ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
return response.Content;
}

public String CreateTransactionVirtualAccount(VirtualAccountParams virtualaccountparams)
{

var client = new RestClient("https://api.ravepay.co/v2/banktransfers/accountnumbers");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", JsonConvert.SerializeObject(new { virtualaccountparams.seckey, virtualaccountparams.Amount, virtualaccountparams.Narration, virtualaccountparams.email, virtualaccountparams .TxRef}), ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
return response.Content;
}

public String CreateDurationStaticVirtualAccount(VirtualAccountParams virtualaccountparams)
{

var client = new RestClient("https://api.ravepay.co/v2/banktransfers/accountnumbers");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", JsonConvert.SerializeObject(new { virtualaccountparams.email, virtualaccountparams.Frequency, virtualaccountparams.Narration, virtualaccountparams .Duration, virtualaccountparams .seckey, virtualaccountparams .TxRef}), ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
return response.Content;
}
}
}
Loading

0 comments on commit cf57c34

Please sign in to comment.