GoPay.NET
1.1.9
See the version list below for details.
dotnet add package GoPay.NET --version 1.1.9
NuGet\Install-Package GoPay.NET -Version 1.1.9
<PackageReference Include="GoPay.NET" Version="1.1.9" />
paket add GoPay.NET --version 1.1.9
#r "nuget: GoPay.NET, 1.1.9"
// Install GoPay.NET as a Cake Addin #addin nuget:?package=GoPay.NET&version=1.1.9 // Install GoPay.NET as a Cake Tool #tool nuget:?package=GoPay.NET&version=1.1.9
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 Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
- Newtonsoft.Json (>= 9.0.1)
- RestSharp (>= 105.2.3)
- RestSharp.Newtonsoft.Json (>= 1.0.0)
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.3.2 | 633 | 10/30/2024 |
1.3.1 | 743 | 9/24/2024 |
1.3.0 | 136 | 9/9/2024 |
1.2.8 | 142 | 9/3/2024 |
1.2.7 | 2,210 | 7/17/2024 |
1.2.6 | 22,077 | 9/25/2023 |
1.2.5 | 1,877 | 6/7/2023 |
1.2.2 | 5,163 | 1/26/2023 |
1.2.1 | 790 | 1/12/2023 |
1.2.0 | 10,534 | 11/11/2022 |
1.1.19 | 6,977 | 8/23/2022 |
1.1.18 | 961 | 8/11/2022 |
1.1.17 | 5,552 | 2/3/2022 |
1.1.16 | 1,352 | 11/2/2021 |
1.1.15 | 3,511 | 8/12/2021 |
1.1.14 | 4,644 | 7/3/2020 |
1.1.13 | 3,329 | 2/7/2020 |
1.1.12 | 1,340 | 11/22/2019 |
1.1.11 | 1,753 | 3/15/2019 |
1.1.10 | 1,404 | 12/19/2018 |
1.1.9 | 1,243 | 12/13/2018 |
1.1.8 | 2,636 | 4/26/2018 |
1.1.7 | 1,770 | 10/5/2017 |
1.1.6 | 2,088 | 8/28/2017 |
1.1.0 | 1,519 | 4/3/2017 |
1.0.1 | 2,886 | 12/16/2016 |
1.0.0 | 3,217 | 9/26/2016 |
Added Google pay payment instrument & new payment codes