GoPay.NetStandard 1.1.14

.NET Standard 2.1
Install-Package GoPay.NetStandard -Version 1.1.14
dotnet add package GoPay.NetStandard --version 1.1.14
<PackageReference Include="GoPay.NetStandard" Version="1.1.14" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GoPay.NetStandard --version 1.1.14
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GoPay.NetStandard, 1.1.14"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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

Method API Action
CreatePayment https://doc.gopay.com/en/#standard-payment
PaymentStatus https://doc.gopay.com/en/#status-of-the-payment
RefundPayment https://doc.gopay.com/en/#refund-of-the-payment-(cancelation)
CreateRecurrentPayment https://doc.gopay.com/en/#recurring-payment
CreateRecurrentPayment https://doc.gopay.com/en/#recurring-payment-on-demand
VoidRecurrency https://doc.gopay.com/en/#cancellation-of-the-recurring-payment
VoidAuthorization https://doc.gopay.com/en/#cancellation-of-the-pre-authorized-payment
CapturePayment https://doc.gopay.com/en/#charge-of-pre-authorized-payment
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
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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 10,038 12/29/2020

NetStandard support for official GoPay repo