public async Task <PlansModel> CreatePlan(string name, string description, int amount, string interval, bool send_invoices = false, bool send_sms = false, string currency = "NGN", int invoice_limit = 0) { var client = HttpConnection.CreateClient(this._secretKey); var bodyKeyValues = new List <KeyValuePair <string, string> >(); bodyKeyValues.Add(new KeyValuePair <string, string>("name", name)); bodyKeyValues.Add(new KeyValuePair <string, string>("description", description)); bodyKeyValues.Add(new KeyValuePair <string, string>("amount", amount.ToString())); bodyKeyValues.Add(new KeyValuePair <string, string>("interval", interval)); bodyKeyValues.Add(new KeyValuePair <string, string>("send_invoices", send_invoices.ToString())); bodyKeyValues.Add(new KeyValuePair <string, string>("send_sms", send_sms.ToString())); bodyKeyValues.Add(new KeyValuePair <string, string>("currency", currency)); if (invoice_limit > 0) { bodyKeyValues.Add(new KeyValuePair <string, string>("invoice_limit", invoice_limit.ToString())); } var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PostAsync("plan", formContent); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <PlansModel>(json)); }
public async Task <ChargeResponse> ChargeAuthorization(string amount, string email, string pin, string authorization_code, string display_name = null, string value = null, string variable_name = null) { var client = HttpConnection.CreateClient(secretKey); var model = new ChargeAuthorizationInput { AuthorizationCode = authorization_code, Amount = amount, Email = email, Pin = pin }; if (!string.IsNullOrWhiteSpace(display_name)) { _ = new ChargeMetadata { AuthCustomFields = new List <AuthCustomField> { new AuthCustomField { } } }; } var jsonObj = JsonConvert.SerializeObject(model); var content = new StringContent(jsonObj, Encoding.UTF8, BaseConstants.ContentTypeHeaderJson); content.Headers.ContentType = new MediaTypeHeaderValue(BaseConstants.ContentTypeHeaderJson); var response = await client.PostAsync("charge", content).ConfigureAwait(false); var json = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <ChargeResponse>(json); return(result); }
public async Task <TransferRecipientModel> CreateTransferRecipient(string type, string name, string account_number, string bank_code, string currency = "NGN", string description = null) { var client = HttpConnection.CreateClient(this._secretKey); var bodyKeyValues = new List <KeyValuePair <string, string> >(); bodyKeyValues.Add(new KeyValuePair <string, string>("type", type)); bodyKeyValues.Add(new KeyValuePair <string, string>("name", name)); bodyKeyValues.Add(new KeyValuePair <string, string>("account_number", account_number)); bodyKeyValues.Add(new KeyValuePair <string, string>("bank_code", bank_code)); bodyKeyValues.Add(new KeyValuePair <string, string>("currency", currency)); if (!string.IsNullOrWhiteSpace(description)) { bodyKeyValues.Add(new KeyValuePair <string, string>("description", description)); } var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PostAsync("transferrecipient", formContent); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TransferRecipientModel>(json)); }
public async Task <TransferInitiationModel> InitiateTransfer(int amount, string recipient_code, string source = "balance", string currency = "NGN", string reason = null) { var client = HttpConnection.CreateClient(this._secretKey); var bodyKeyValues = new List <KeyValuePair <string, string> >(); bodyKeyValues.Add(new KeyValuePair <string, string>("source", source)); bodyKeyValues.Add(new KeyValuePair <string, string>("amount", amount.ToString())); bodyKeyValues.Add(new KeyValuePair <string, string>("recipient_code", recipient_code)); bodyKeyValues.Add(new KeyValuePair <string, string>("currency", currency)); if (!string.IsNullOrWhiteSpace(reason)) { bodyKeyValues.Add(new KeyValuePair <string, string>("reason", reason)); } var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PostAsync("transfer", formContent); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TransferInitiationModel>(json)); }
public async Task <CustomerCreationResponse> FetchCustomer(int id) { var client = HttpConnection.CreateClient(this._secretKey); var response = await client.GetAsync($"customer/{id}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <CustomerCreationResponse>(json)); }
public async Task <TransactionResponseModel> FetchTransaction(int id) { var client = HttpConnection.CreateClient(this._secretKey); var response = await client.GetAsync($"transaction/{id}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TransactionResponseModel>(json)); }
public async Task <ChargeResponse> CheckPendingCharge(string reference) { var client = HttpConnection.CreateClient(secretKey); var response = await client.GetAsync($"charge/{reference}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ChargeResponse>(json)); }
public async Task <SubAccountList> ListSubAccounts() { var client = HttpConnection.CreateClient(secretKey); var response = await client.GetAsync("subaccount"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <SubAccountList>(json)); }
public async Task <SubAccount> FetchSubAccount(string subaccount_code) { var client = HttpConnection.CreateClient(secretKey); var response = await client.GetAsync($"subaccount/{subaccount_code}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <SubAccount>(json)); }
public async Task <FetchPlan> FetchPlans(string plan_code) { var client = HttpConnection.CreateClient(secretKey); var response = await client.GetAsync($"plan/{plan_code}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <FetchPlan>(json)); }
public async Task <TransferDetailList> ListTransfers() { var client = HttpConnection.CreateClient(secretKey); var response = await client.GetAsync("transfer"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TransferDetailList>(json)); }
public async Task <TransactionResponseModel> TransactionTimeline(string reference) { var client = HttpConnection.CreateClient(this._secretKey); var response = await client.GetAsync($"transaction/timeline/{reference}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TransactionResponseModel>(json)); }
public async Task <ExportResponseModel> ExportTransactions() { var client = HttpConnection.CreateClient(this._secretKey); var response = await client.GetAsync("transaction/export"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ExportResponseModel>(json)); }
public async Task <CustomerListResponse> ListCustomers() { var client = HttpConnection.CreateClient(this._secretKey); var response = await client.GetAsync("customer"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <CustomerListResponse>(json)); }
public async Task <TransactionListViewModel> ListTransactions() { var client = HttpConnection.CreateClient(_secretKey); var response = await client.GetAsync("transaction"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TransactionListViewModel>(json)); }
/// <summary> /// Verifies transaction by reference number /// </summary> /// <param name="reference"></param> /// <returns>TransactionVerificationResponseModel</returns> public async Task <TransactionResponses> VerifyTransaction(string reference) { var client = HttpConnection.CreateClient(secretKey); var response = await client.GetAsync($"transaction/verify/{reference}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TransactionResponses>(json)); }
public async Task <BVNVerificationResponseModel> ResolveBVN(string bvn) { var client = HttpConnection.CreateClient(_secretKey); var response = await client.GetAsync($"bank/resolve_bvn/{bvn}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <BVNVerificationResponseModel>(json)); }
public async Task <TransferDetailsModel> FetchTransfer(string transfer_code) { var client = HttpConnection.CreateClient(this._secretKey); var response = await client.GetAsync($"transfer/{transfer_code}"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TransferDetailsModel>(json)); }
public async Task <SubAccount> UpdateSubAccount(string subaccount_code, string business_name = null, string settlement_bank = null, string account_number = null, float percentage_charge = 0, string primary_contact_email = null, string primary_contact_name = null, string primary_contact_phone = null, string settlement_schedule = "auto") { var client = HttpConnection.CreateClient(secretKey); var bodyKeyValues = new List <KeyValuePair <string, string> >(); if (!string.IsNullOrWhiteSpace(business_name)) { bodyKeyValues.Add(new KeyValuePair <string, string>("business_name", business_name)); } if (!string.IsNullOrWhiteSpace(settlement_bank)) { bodyKeyValues.Add(new KeyValuePair <string, string>("settlement_bank", settlement_bank)); } if (!string.IsNullOrWhiteSpace(account_number)) { bodyKeyValues.Add(new KeyValuePair <string, string>("account_number", account_number)); } if (percentage_charge > 0) { bodyKeyValues.Add(new KeyValuePair <string, string>("percentage_charge", percentage_charge.ToString())); } if (!string.IsNullOrWhiteSpace(primary_contact_email)) { bodyKeyValues.Add(new KeyValuePair <string, string>("primary_contact_email", primary_contact_email)); } if (!string.IsNullOrWhiteSpace(primary_contact_name)) { bodyKeyValues.Add(new KeyValuePair <string, string>("primary_contact_name", primary_contact_name)); } if (!string.IsNullOrWhiteSpace(primary_contact_phone)) { bodyKeyValues.Add(new KeyValuePair <string, string>("primary_contact_phone", primary_contact_phone)); } if (!string.IsNullOrWhiteSpace(settlement_schedule)) { bodyKeyValues.Add(new KeyValuePair <string, string>("settlement_schedule", settlement_schedule)); } var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PutAsync($"subaccount/{subaccount_code}", formContent); var json = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <SubAccount>(json); return(result); }
public async Task <PlanListModel> ListPlans() { var client = HttpConnection.CreateClient(this._secretKey); var response = await client.GetAsync("plan"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <PlanListModel>(json)); }
public async Task <BankListResponseModel> ListBanks() { var client = HttpConnection.CreateClient(this._secretKey); var response = await client.GetAsync("https://api.paystack.co/bank"); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <BankListResponseModel>(json)); }
public async Task <ChargeResponse> ChargeAuthorization(ChargeAuthorizationInput model) { var client = HttpConnection.CreateClient(secretKey); var jsonObj = JsonConvert.SerializeObject(model); var content = new StringContent(jsonObj, Encoding.UTF8, BaseConstants.ContentTypeHeaderJson); content.Headers.ContentType = new MediaTypeHeaderValue(BaseConstants.ContentTypeHeaderJson); var response = await client.PostAsync("charge", content); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ChargeResponse>(json)); }
public async Task <SubAccountModel> UpdateSubAccount(Dictionary <string, string> parameters) { var client = HttpConnection.CreateClient(_secretKey); var bodyKeyValues = parameters.ToList(); var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PutAsync($"subaccount/{parameters["subaccount_code"]}", formContent); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <SubAccountModel>(json)); }
public async Task <ChargeResponseModel> ChargeCard(string email, string amount, string pin, string cvv, string expiry_month, string expiry_year, string number, string display_name = null, string value = null, string variable_name = null) { var client = HttpConnection.CreateClient(this._secretKey); var model = new ChargeCardInputModel() { amount = amount, card = new ChargeCard() { cvv = cvv, expiry_month = expiry_month, expiry_year = expiry_year, number = number }, email = email, pin = pin }; if (!string.IsNullOrWhiteSpace(display_name)) { var _metadata = new ChargeCardMetadata() { custom_fields = new List <Custom_Field>() { new Custom_Field() { display_name = display_name, value = value, variable_name = variable_name } } }; model.metadata = _metadata; } var jsonObj = JsonConvert.SerializeObject(model); var content = new StringContent(jsonObj, Encoding.UTF8, "application/json"); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await client.PostAsync("charge", content); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ChargeResponseModel>(json)); }
public async Task <SubAccountModel> CreateSubAccount(Dictionary <string, string> parameters) { var client = HttpConnection.CreateClient(_secretKey); var bodyKeyValues = parameters.ToList(); //ensure dictionary contains paystack required parameters and your own optional parameters. metadata should be converted to json string var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PostAsync("subaccount", formContent); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <SubAccountModel>(json)); }
public async Task <string> FinalizeTransfer(string transfer_code, string otp) { var client = HttpConnection.CreateClient(secretKey); var bodyKeyValues = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("transfer_code", transfer_code), new KeyValuePair <string, string>("otp", otp) }; var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PostAsync("finalize_transfer", formContent); var json = await response.Content.ReadAsStringAsync(); return(json); }
public async Task <ChargeResponse> SubmitOTP(string otp, string reference) { var client = HttpConnection.CreateClient(secretKey); var bodyKeyValues = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("otp", otp), new KeyValuePair <string, string>("reference", reference) }; var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PostAsync("charge/submit_otp", formContent); var json = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <ChargeResponse>(json); return(result); }
public async Task <ChargeResponse> ChargeCard(string email, string amount, string pin, string cvv, string expiry_month, string expiry_year, string number, string display_name = null, string value = null, string variable_name = null) { var client = HttpConnection.CreateClient(secretKey); var model = new ChargeCardInput { Amount = amount, Card = new ChargeCard { CVV = cvv, ExpiryMonth = expiry_month, ExpiryYear = expiry_year, Number = number }, Email = email, Pin = pin }; if (!string.IsNullOrWhiteSpace(display_name)) { var metaData = new CardMetadata { CustomFields = new List <Custom_Field> { new Custom_Field() { DisplayName = display_name, Value = value, VariableName = variable_name } } }; model.Metadata = metaData; } var jsonObj = JsonConvert.SerializeObject(model); var content = new StringContent(jsonObj, Encoding.UTF8, BaseConstants.ContentTypeHeaderJson); content.Headers.ContentType = new MediaTypeHeaderValue(BaseConstants.ContentTypeHeaderJson); var response = await client.PostAsync("charge", content); var json = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <ChargeResponse>(json); return(result); }
public async Task <ChargeResponseModel> SubmitPin(string pin, string reference) { var client = HttpConnection.CreateClient(this._secretKey); var bodyKeyValues = new List <KeyValuePair <string, string> >(); bodyKeyValues.Add(new KeyValuePair <string, string>("pin", pin)); bodyKeyValues.Add(new KeyValuePair <string, string>("reference", reference)); var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PostAsync("charge/submit_pin", formContent); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ChargeResponseModel>(json)); }
public async Task <RequestAuthorizationModel> RequestReAuthorization(string authorization_code, string email, int amount) { var client = HttpConnection.CreateClient(this._secretKey); var bodyKeyValues = new List <KeyValuePair <string, string> >(); bodyKeyValues.Add(new KeyValuePair <string, string>("authorization_code", authorization_code)); bodyKeyValues.Add(new KeyValuePair <string, string>("email", email)); bodyKeyValues.Add(new KeyValuePair <string, string>("amount", amount.ToString())); var formContent = new FormUrlEncodedContent(bodyKeyValues); var response = await client.PostAsync("transaction/request_reauthorization", formContent); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <RequestAuthorizationModel>(json)); }