Skip to content

Instantly share code, notes, and snippets.

@incarnate
Created October 13, 2016 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save incarnate/71669a34d5af4ff9548051fb9fdb89b3 to your computer and use it in GitHub Desktop.
Save incarnate/71669a34d5af4ff9548051fb9fdb89b3 to your computer and use it in GitHub Desktop.
eWAY Rapid VB.NET console app example
' Simple VB.NET Console application to perform a
' Rapid Direct Connection transaction and then query the
' Transaction ID.
'
' This example uses the eWAY Rapid .NET package from NuGet
' https://www.nuget.org/packages/eWAY.Rapid/
'
' eWAY: https://www.eway.com.au
Imports eWAY.Rapid
Imports eWAY.Rapid.Enums
Imports eWAY.Rapid.Models
Module Module1
Sub Main()
' Set credentials
Dim apiKey = "60CF3Ce97nRS1Z1Wp5m9kMmzHHEh8Rkuj31QCtVxjPWGYA9FymyqsK0Enm1P6mHJf0THbR"
Dim apiPass = "API-P4ss"
Dim apiEndpoint = "Sandbox"
' Create an eWAY Rapid Client
Dim client As IRapidClient = RapidClientFactory.NewRapidClient(apiKey, apiPass, apiEndpoint)
' Rapid Direct Connection transaction
Dim transaction As Transaction = New Transaction()
' Note: This should use client side encryption if the server is not
' PCI compliant.
' See https://eway.io/api-v3/#client-side-encryption
Dim cardDetails As New CardDetails()
cardDetails.Name = "John Smith"
cardDetails.Number = "4444333322221111"
cardDetails.ExpiryMonth = "11"
cardDetails.ExpiryYear = "22"
cardDetails.CVN = "222"
Dim customer As New Customer()
customer.CardDetails = cardDetails
transaction.Customer = customer
Dim paymentDetails As New PaymentDetails()
paymentDetails.TotalAmount = 1000 ' = $10.00
transaction.PaymentDetails = paymentDetails
transaction.TransactionType = TransactionTypes.Purchase
' Process transaction
Dim response As CreateTransactionResponse = client.Create(PaymentMethod.Direct, transaction)
If Not IsNothing(response.Errors) AndAlso response.Errors.Count > 0 Then
Console.WriteLine("An error occurred: " + String.Join(", ", response.Errors.ToArray()))
Else
If response.TransactionStatus.Status Then
Console.WriteLine("Payment successful! ID: " + response.TransactionStatus.TransactionID.ToString)
Else
Console.WriteLine("Payment failed! ID: " + response.TransactionStatus.TransactionID.ToString)
End If
End If
' Transaction Query
Dim query As QueryTransactionResponse = client.QueryTransaction(response.TransactionStatus.TransactionID)
Console.WriteLine("Queried Authorisation Code = " + query.TransactionStatus.ProcessingDetails.AuthorisationCode)
' Hold the console window open
Console.WriteLine("Press ESC to stop")
Do
While Not Console.KeyAvailable
End While
Loop While Console.ReadKey(True).Key <> ConsoleKey.Escape
End Sub
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment