.NET SDK
Here are step-by-step instructions on how to install NuGet packages using different methods in a .NET environment:
1. Using Visual Studio
a. Package Manager UI
Open Your Project: Start Visual Studio and open your existing project or solution.
Manage NuGet Packages:
- Right-click on your project in the Solution Explorer.
- Select Manage NuGet Packages.
Browse for Packages:
- In the NuGet Package Manager window, go to the Browse tab.
- Search for your package (e.g., SmatPaySDK).
Install the Package:
- Select the package from the list.
- Click the Install button.
- Follow any prompts to accept licenses.
b. Package Manager Console
1. Open Package Manager Console:
- Go to Tools > NuGet Package Manager > Package Manager Console.
2. Install the Package:
- In the console, run the following command:
Install-Package SmatPaySDK
- Press Enter. Wait for the installation to complete.
2. Using .NET CLI
If you're using the .NET Core CLI, you can install packages directly from the command line.
1. Open Command Prompt or Terminal.
2. Navigate to Your Project Directory:
3. Install the Package:
- This command will add the specified package to your project.
3. Editing the Project File Manually
You can also manually add the package reference in your project file (.csproj).
1. Open Your Project File: Locate and open the .csproj file associated with your project.
2. Add Package Reference: Add the following line inside an ItemGroup tag:
4. Verifying Installation
After installing the package, you can verify it:
Check your Solution Explorer under the Dependencies node for the installed package.
You can also check your .csproj file to ensure the package reference was added.
5. Using the Package
Once the package is installed, you can start using it in your code by adding the necessary using directives. For example:
Feel free to reach out if you have any further questions or need additional details! Code smaples are included when you import the package
Imports System Imports System.Threading.Tasks Imports SmatPaySDKVB.SmatPaySDK.models Imports SmatPaySDKVB.SmatPaySDK.services
Module Program
Sub Main(args As String())
____MainAsync().GetAwaiter().GetResult()
End Sub
Private Async Function MainAsync() As Task
____' Initialize the service using a real base URL and authentication key
____Dim authSandBoxService As New AuthSandBoxAPIService(baseUrl)
____Dim merchant As New Merchant() With {
________.MerchantId = "311722504951049",
________.MerchantKey = "959d936d-c79a-4711-9528-2d0dc4399142",
________.MerchantApiKey = "V8S5M2C3L0nYPz8ZDVRhq"
____}
____Dim authObject As MerchantResponse = Await authSandBoxService.GetTokenAsync(merchant)
____authKey = authObject.Token
____Await CheckInnBucksStatus()
____Await CheckEcocashStatus()
____Await CheckZimSwitchStatus()
End Function
Private Async Function CheckInnBucksStatus() As Task
____' Create a request object
____Dim statusRequest As New PayInnbucksStatusRequest() With {
________.TransactionReference = "71454554123134",
________.TransactionCode = "701878860",
________.WalletName = "Innbucks"
____}
____Dim paymentStatusService As New DirectStatusSandBoxAPIService(baseUrl, authKey)
____Try
________' Call the SDK method
________Dim paymentStatuses As List(Of PaymentStatusResponse) = Await paymentStatusService.PayInnBucksStatusAsync(statusRequest)
________' Output the results to the console
________Console.WriteLine("Payment Status Response InnBucks:")
________For Each paymentStatus In paymentStatuses
____________Console.WriteLine($
"Status: {paymentStatus.Status}")
____________Console.WriteLine($
"Payment Reference: {paymentStatus.PaymentReference}")
____________Console.WriteLine($
"Payment Method: {paymentStatus.PaymentMethod}")
____________Console.WriteLine($
"Payment Date: {paymentStatus.PaymentDate}")
____________Console.WriteLine()
________Next
____Catch ex As Exception
________' Handle any errors
________Console.WriteLine($
"Error: {ex.Message}")
____End Try
End Function
Private Async Function CheckEcocashStatus() As Task
____' Create a request object
____Dim statusRequest As New PayEcocashStatusRequest() With {
________.TransactionReference = "INV-000-002",
________.WalletName = "Ecocash"
____}
____Dim paymentStatusService As New DirectStatusSandBoxAPIService(baseUrl, authKey)
____Try
________' Call the SDK method
________Dim paymentStatuses As List(Of PaymentStatusResponse) = Await paymentStatusService.PayEcocashStatusAsync(statusRequest)
________' Output the results to the console
________Console.WriteLine("Payment Status Response Ecocash:")
________For Each paymentStatus In paymentStatuses
____________Console.WriteLine($
"Status: {paymentStatus.Status}")
____________Console.WriteLine($
"Payment Reference: {paymentStatus.PaymentReference}")
____________Console.WriteLine($
"Payment Method: {paymentStatus.PaymentMethod}")
____________Console.WriteLine($
"Payment Date: {paymentStatus.PaymentDate}")
____________Console.WriteLine()
________Next
____Catch ex As Exception
________' Handle any errors
________Console.WriteLine($
"Error: {ex.Message}")
____End Try
End Function
Private Async Function CheckZimSwitchStatus() As Task
____' Create a request object
____Dim statusRequest As New PayZimSwitchStatusRequest() With {
________.TransactionReference = "3E71FD08FBA6CDAB6E1DCF890C60ED9B.uat01-vm-tx01",
________.WalletName = "ZimSwitch"
____}
____Dim paymentStatusService As New DirectStatusSandBoxAPIService(baseUrl, authKey)
____Try
________' Call the SDK method
________Dim paymentStatuses As List(Of PaymentStatusResponse) = Await paymentStatusService.PayZimSwitchStatusAsync(statusRequest)
________' Output the results to the console
________Console.WriteLine("Payment Status Response ZimSwitch:")
________For Each paymentStatus In paymentStatuses
____________Console.WriteLine($
"Status: {paymentStatus.Status}")
____________Console.WriteLine($
"Payment Reference: {paymentStatus.PaymentReference}")
____________Console.WriteLine($
"Payment Method: {paymentStatus.PaymentMethod}")
____________Console.WriteLine($
"Payment Date: {paymentStatus.PaymentDate}")
____________Console.WriteLine()
________Next
____Catch ex As Exception
________' Handle any errors
________Console.WriteLine($
"Error: {ex.Message}")
____End Try
End Function