Skip to content
Open

Main #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion ConsoleApp1/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
<package id="Newtonsoft.Json" version="13.0.4" targetFramework="net48" />
</packages>
10 changes: 2 additions & 8 deletions PayStackDotNetSDK.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2000
# Visual Studio Version 17
VisualStudioVersion = 17.14.36401.2 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PayStackDotNetSDK", "PayStackDotNetSDK\PayStackDotNetSDK.csproj", "{BA52829E-D8D3-47F6-B1F8-07582AE28A62}"
EndProject
Expand All @@ -14,8 +14,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester.Console", "Tester.Console\Tester.Console.csproj", "{AD1C115C-81CD-47DC-A00A-254D3C0BC50C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester.Web", "Tester.Web\Tester.Web.csproj", "{7350CA94-174B-4A46-9233-F0FE35899CBD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{679344EB-BD1B-4302-B002-0A3F6FD792C6}"
EndProject
Global
Expand All @@ -32,10 +30,6 @@ Global
{AD1C115C-81CD-47DC-A00A-254D3C0BC50C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD1C115C-81CD-47DC-A00A-254D3C0BC50C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD1C115C-81CD-47DC-A00A-254D3C0BC50C}.Release|Any CPU.Build.0 = Release|Any CPU
{7350CA94-174B-4A46-9233-F0FE35899CBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7350CA94-174B-4A46-9233-F0FE35899CBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7350CA94-174B-4A46-9233-F0FE35899CBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7350CA94-174B-4A46-9233-F0FE35899CBD}.Release|Any CPU.Build.0 = Release|Any CPU
{679344EB-BD1B-4302-B002-0A3F6FD792C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{679344EB-BD1B-4302-B002-0A3F6FD792C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{679344EB-BD1B-4302-B002-0A3F6FD792C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
58 changes: 58 additions & 0 deletions PayStackDotNetSDK/BuilderHelper/InitializeTransactionBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using PayStackDotNetSDK.Models;
using PayStackDotNetSDK.Models.Transactions;
using System;

namespace PayStackDotNetSDK.Builders
{
public class InitializeTransactionBuilder
{
private readonly TransactionRequestModel _request = new TransactionRequestModel();

public InitializeTransactionBuilder WithEmail(string email)
{
_request.email = email;
return this;
}

public InitializeTransactionBuilder WithAmount(int amount)
{
_request.amount = amount;
return this;
}

public InitializeTransactionBuilder WithReference(string reference)
{
_request.reference = reference;
return this;
}

public InitializeTransactionBuilder WithCurrency(string currency)
{
_request.currency = currency;
return this;
}

public InitializeTransactionBuilder WithCallbackUrl(string callbackUrl)
{
_request.callback_url = callbackUrl;
return this;
}

public InitializeTransactionBuilder WithMetadata(Action<MetadataBuilder> metadataBuilderAction)
{
var builder = new MetadataBuilder();
metadataBuilderAction(builder);
_request.metadata = builder.Build();
return this;
}

public TransactionRequestModel Build()
{
if (string.IsNullOrWhiteSpace(_request.email))
throw new InvalidOperationException("Email is required for a Paystack transaction.");
if (_request.amount <= 0)
throw new InvalidOperationException("Amount must be greater than zero.");
return _request;
}
}
}
26 changes: 26 additions & 0 deletions PayStackDotNetSDK/BuilderHelper/MetadataBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using PayStackDotNetSDK.Models;

namespace PayStackDotNetSDK.Builders
{
public class MetadataBuilder
{
private readonly Metadata _metadata = new Metadata();

public MetadataBuilder AddField(string key, object value)
{
_metadata.AdditionalData[key] = Newtonsoft.Json.Linq.JToken.FromObject(value);
return this;
}

public MetadataBuilder AddCustomField(string displayName, string variableName, string value)
{
// ✅ Correct usage of constructor
_metadata.CustomFields.Add(new CustomField(displayName, variableName, value));
return this;
}

public Metadata Build() => _metadata;
}

}
32 changes: 27 additions & 5 deletions PayStackDotNetSDK/Models/Metadata.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace PayStackDotNetSDK.Models
{
public class Metadata
{
public List<CustomField> custom_fields { get; set; } = null;
[JsonProperty("custom_fields")]
public List<CustomField> CustomFields { get; set; } = new List<CustomField>();

[JsonExtensionData]
public IDictionary<string, JToken> AdditionalData { get; set; } = new Dictionary<string, JToken>();
}

public class CustomField
{
public string display_name { get; set; } = null;
public string variable_name { get; set; } = null;
public string value { get; set; } = null;
[JsonProperty("display_name")]
public string DisplayName { get; set; }

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

[JsonProperty("value")]
public string Value { get; set; }
// ✅ Add this constructor

//public CustomField() { }

public CustomField(string displayName, string variableName, string value)
{
DisplayName = displayName;
VariableName = variableName;
Value = value;
}

}
}
79 changes: 18 additions & 61 deletions PayStackDotNetSDK/Models/Paystack.Net.Models.csproj
Original file line number Diff line number Diff line change
@@ -1,61 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F12518F2-AEEE-4A9B-89BF-D7E1D4E04209}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PayStackDotNetSDK.Models</RootNamespace>
<AssemblyName>PayStackDotNetSDK.Models</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Authorizations\RequestAuthorizationModel.cs" />
<Compile Include="BankListResponseModel.cs" />
<Compile Include="Customers\CustomerCreationResponse.cs" />
<Compile Include="Exports\ExportResponseModel.cs" />
<Compile Include="PaymentInitalizationResponseModel.cs" />
<Compile Include="Plans\PlansModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Subaccounts\CreateSubAccount\SubAccountModel.cs" />
<Compile Include="Subscription\SubscriptionModel.cs" />
<Compile Include="TransactionInitializationRequestModel.cs" />
<Compile Include="TransactionListViewModel.cs" />
<Compile Include="TransactionResponseModel.cs" />
<Compile Include="Transfers\Initiation\TransferInitiationModel.cs" />
<Compile Include="Transfers\Recipient\TransferRecipientModel.cs" />
<Compile Include="Transfers\TransferDetails\TransferDetailsModel.cs" />
<Compile Include="TransTotal\TransactionTotal.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>PayStackDotNetSDK.Models</RootNamespace>
<AssemblyName>PayStackDotNetSDK.Models</AssemblyName>
<LangVersion>latest</LangVersion>

<!-- Optional: Generate XML docs or enable nullable types -->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CreateRefundRequestModel
/// <summary>
/// amount(optional) : How much in kobo to be refunded to the customer.Amount is optional(defaults to original transaction amount) and cannot be more than the original transaction amount.
/// </summary>
public int amount { get; set; }
public long amount { get; set; }
/// <summary>
/// currency: Three-letter ISO currency
/// </summary>
Expand Down
23 changes: 2 additions & 21 deletions PayStackDotNetSDK/Models/Refunds/CreateRefundResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,7 @@ public class CreateRefundResponseModel
{
public bool status { get; set; }
public string message { get; set; }
public Data data { get; set; }
}
public class Data
{
public int dispute { get; set; }
public int transaction { get; set; }
public string currency { get; set; }
public int amount { get; set; }
public string channel { get; set; }
public string customer_note { get; set; }
public string merchant_note { get; set; }
public int integration { get; set; }
public string domain { get; set; }
public string status { get; set; }
public string refunded_by { get; set; }
public DateTime refunded_at { get; set; }
public DateTime expected_at { get; set; }
public bool fully_deducted { get; set; }
public int id { get; set; }
public DateTime createdAt { get; set; }
public DateTime updatedAt { get; set; }
public RefundData data { get; set; }
}

}
24 changes: 0 additions & 24 deletions PayStackDotNetSDK/Models/Refunds/FetchRefundResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,5 @@ public class FetchRefundResponseModel
public string message { get; set; }
public RefundData data { get; set; }
}
public class RefundData
{
public int integration { get; set; }
public int transaction { get; set; }
public int dispute { get; set; }
public object settlement { get; set; }
public string domain { get; set; }
public int amount { get; set; }
public object deducted_amount { get; set; }
public bool fully_deducted { get; set; }
public string currency { get; set; }
public string channel { get; set; }
public string status { get; set; }
public string refunded_by { get; set; }
public DateTime refunded_at { get; set; }
public DateTime expected_at { get; set; }
public string customer_note { get; set; }
public string merchant_note { get; set; }
public object bank_reference { get; set; }
public int id { get; set; }
public DateTime createdAt { get; set; }
public DateTime updatedAt { get; set; }
}


}
35 changes: 15 additions & 20 deletions PayStackDotNetSDK/Models/Refunds/ListRefundResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,36 @@ public class ListRefundResponseModel
{
public bool status { get; set; }
public string message { get; set; }
public List<Refund> data { get; set; }
public Meta meta { get; set; }
public List<RefundListData> data { get; set; }
public RefundListMeta meta { get; set; }
}
public class Refund

public class RefundListData
{
public int integration { get; set; }
public long integration { get; set; }
public long transaction { get; set; }
public object dispute { get; set; }
public object settlement { get; set; }
public long id { get; set; }
public string domain { get; set; }
public int transaction { get; set; }
public int dispute { get; set; }
public int amount { get; set; }
public string currency { get; set; }
public string channel { get; set; }
public object deducted_amount { get; set; }
public int fully_deducted { get; set; }
public long amount { get; set; }
public string status { get; set; }
public object refunded_at { get; set; }
public string refunded_by { get; set; }
public DateTime refunded_at { get; set; }
public DateTime expected_at { get; set; }
public object settlement { get; set; }
public string customer_note { get; set; }
public string merchant_note { get; set; }
public object bank_reference { get; set; }
public int id { get; set; }
public DateTime created_at { get; set; }
public DateTime updated_at { get; set; }
public int is_deleted { get; set; }
public int deducted_amount { get; set; }
public bool fully_deducted { get; set; }
public DateTime createdAt { get; set; }
}

public class Meta
public class RefundListMeta
{
public int total { get; set; }
public int skipped { get; set; }
public int perPage { get; set; }
public int page { get; set; }
public int pageCount { get; set; }
}

}
Loading