GoPay.NetStandard
1.1.14
dotnet add package GoPay.NetStandard --version 1.1.14
NuGet\Install-Package GoPay.NetStandard -Version 1.1.14
<PackageReference Include="GoPay.NetStandard" Version="1.1.14" />
paket add GoPay.NetStandard --version 1.1.14
#r "nuget: GoPay.NetStandard, 1.1.14"
// Install GoPay.NetStandard as a Cake Addin #addin nuget:?package=GoPay.NetStandard&version=1.1.14 // Install GoPay.NetStandard as a Cake Tool #tool nuget:?package=GoPay.NetStandard&version=1.1.14
GoPay .NET API
Detailed guide: https://doc.gopay.com
Requirements
- .NET 4.5+
NuGet
This library is avalaible from NuGet Package Manager
PM> Install-Package GOPAY.NET
Dependencies
- Newtonsoft.Json
- Restsharp
- Restsharp.Newtonsoft.Json
Namespace
using GoPay.Common;
using GoPay.Model;
using GoPay.Payment;
Basic usage
Creating an instance of GPConnector
var connector = new GPConnector(<API_URL>,<USER_SECRET>, <USER_ID>);
The connector provides methods for interacting with our gateway.
OAuth
To be able to communicate with our gateway it's required to create an auth token.
var connector = new GPConnector(<API_URL>,<USER_ID>, <USER_SECRET>);
connector.GetAppToken();
The token gets cached in an instance of GPConnector and its lifetime is 30 minutes. The method GetAppToken()
creates token in a scope "payment-create"
. If you would like to create a token in a different scope call method GetAppToken(<SCOPE>)
Once the token expires its required to obtain a new one by calling the method getAppToken again.
Avalaible methods
Create a payment <a id="create">
var payment = new BasePayment()
{
Currency = <Currency>,
Lang = "ENG",
OrderNumber = "789456167879",
Amount = 7500,
Target = new Target()
{
GoId = <GOID>,
Type = Target.TargetType.ACCOUNT
},
Callback = new Callback()
{
NotificationUrl = <NOTIFICATION_URL>,
ReturnUrl = <RETURN_URL>
},
Payer = new Payer()
{
Contact = new PayerContact()
{
Email = "test@test.gopay.cz"
},
DefaultPaymentInstrument = PaymentInstrument.PAYMENT_CARD
}
};
try {
var result = connector.CreatePayment(payment);
} catch (GPClientException e) {
//
}
Payment status <a id="status">
try {
var payment = connector.PaymentStatus(<PAYMENT_ID>);
} catch (GPClientException e) {
//
}
Payment refund <a id="refund">
try {
var result = connector.RefundPayment(<PAYMENT_ID>, <AMOUNT>);
} catch (GPClientException e) {
//
}
Create preauthorized payment
var payment = new BasePayment()
{
PreAuthorize = true,
...
};
try {
connector.CreatePayment(payment);
} catch (GPClientException ex) {
//
}
Void authorization <a id="voidauth">
try {
var result = connector.VoidAuthorization(<ID>);
} catch (GPClientException ex) {
//
}
Recurrent payment on demand <a id="createrecdem">
var recurrence = new NextPayment()
{
Amount = <Amount>,
Currency = <Currency>,
OrderNumber = <OrderNumber>
};
try {
connector.CreateRecurrentPayment(payment);
} catch {GPClientException e) {
//
}
Recurrent payment <a id="createrec">
var recurrence = new Recurrence()
{
Cycle = RecurrenceCycle.DAY,
DateTo = new DateTime(2020, 12, 12),
Period = 5
};
var payment = new BasePayment();
payment.Recurrence = recurrence;
try {
connector.CreatePayment(payment);
} catch {GPClientException e) {
//
}
Capture payment <a id="capt">
try {
var capture = connector.CapturePayment(<ID>);
} catch (GPClientException ex) {
//
}
Void recurrency <a id="voidrec">
try {
var voidRecurrency = connector.VoidRecurrency(<ID>);
} catch (GPClientException ex) {
//
}
All methods above throw checked exception GPClientException on a failure.
try {
connector.getAppToken().CreatePayment(payment);
} catch (GPClientException e) {
var err = exception.Error;
var date = err.DateIssued;
foreach (var element in err.ErrorMessages)
{
//
}
}
Contributing
Contributions from others would be very much appreciated! Send pull request/ issue. Thanks!
License
Copyright (c) 2016 GoPay.com. MIT Licensed, see LICENSE for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
- Newtonsoft.Json (>= 12.0.3)
- RestSharp (>= 106.11.7)
- RestSharp.Serializers.NewtonsoftJson (>= 106.11.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.14 | 43,539 | 12/29/2020 |
NetStandard support for official GoPay repo