Documentation
¶
Overview ¶
Package paystack is a 3rd party client package for Paystack https://paystack.com. It allows for easy Integration of paystack services into your Go projects.
Index ¶
- Constants
- Variables
- func AddQueryParamsToUrl(url string, queries ...Query) string
- type ApplePayClient
- func (a ApplePayClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (a *ApplePayClient) All(ctx context.Context, response any, queries ...Query) error
- func (a *ApplePayClient) Register(ctx context.Context, domainName string, response any) error
- func (a *ApplePayClient) Unregister(ctx context.Context, domainName string, response any) error
- type BulkChargeClient
- func (a BulkChargeClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (b *BulkChargeClient) All(ctx context.Context, response any, queries ...Query) error
- func (b *BulkChargeClient) Charges(ctx context.Context, idOrCode string, response any, queries ...Query) error
- func (b *BulkChargeClient) FetchOne(ctx context.Context, idOrCode string, response any) error
- func (b *BulkChargeClient) Initiate(ctx context.Context, charges any, response any) error
- func (b *BulkChargeClient) Pause(ctx context.Context, idOrCode string, response any) error
- func (b *BulkChargeClient) Resume(ctx context.Context, idOrCode string, response any) error
- type ChargeClient
- func (a ChargeClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (c *ChargeClient) Create(ctx context.Context, email string, amount string, response any, ...) error
- func (c *ChargeClient) PendingCharge(ctx context.Context, reference string, response any) error
- func (c *ChargeClient) SubmitAddress(ctx context.Context, address string, reference string, city string, ...) error
- func (c *ChargeClient) SubmitBirthday(ctx context.Context, birthday string, reference string, response any) error
- func (c *ChargeClient) SubmitOtp(ctx context.Context, otp string, reference string, response any) error
- func (c *ChargeClient) SubmitPhone(ctx context.Context, phone string, reference string, response any) error
- func (c *ChargeClient) SubmitPin(ctx context.Context, pin string, reference string, response any) error
- type ClientOptions
- type CustomerClient
- func (a CustomerClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (c *CustomerClient) All(ctx context.Context, response any, queries ...Query) error
- func (c *CustomerClient) Create(ctx context.Context, email string, firstName string, lastName string, ...) error
- func (c *CustomerClient) Deactivate(ctx context.Context, authorizationCode string, response any) error
- func (c *CustomerClient) FetchOne(ctx context.Context, emailOrCode string, response any) error
- func (c *CustomerClient) Flag(ctx context.Context, emailOrCode string, response any, ...) error
- func (c *CustomerClient) Update(ctx context.Context, code string, response any, ...) error
- func (c *CustomerClient) Validate(ctx context.Context, code string, firstName string, lastName string, ...) error
- type DedicatedVirtualAccountClient
- func (a DedicatedVirtualAccountClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (d *DedicatedVirtualAccountClient) All(ctx context.Context, response any, queries ...Query) error
- func (d *DedicatedVirtualAccountClient) Assign(ctx context.Context, email string, firstName string, lastName string, ...) error
- func (d *DedicatedVirtualAccountClient) BankProviders(ctx context.Context, response any) error
- func (d *DedicatedVirtualAccountClient) Create(ctx context.Context, customerIdOrCode string, response any, ...) error
- func (d *DedicatedVirtualAccountClient) Deactivate(ctx context.Context, id string, response any) error
- func (d *DedicatedVirtualAccountClient) FetchOne(ctx context.Context, dedicatedAccountId string, response any) error
- func (d *DedicatedVirtualAccountClient) RemoveSplit(ctx context.Context, accountNumber string, response any) error
- func (d *DedicatedVirtualAccountClient) Requery(ctx context.Context, accountNumber, providerSlug string, response any, ...) error
- func (d *DedicatedVirtualAccountClient) Split(ctx context.Context, customerIdOrCode string, response any, ...) error
- type DisputeClient
- func (a DisputeClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (d *DisputeClient) AddEvidence(ctx context.Context, id string, customerEmail string, customerName string, ...) error
- func (d *DisputeClient) All(ctx context.Context, response any, queries ...Query) error
- func (d *DisputeClient) AllTransactionDisputes(ctx context.Context, transactionId string, response any) error
- func (d *DisputeClient) Export(ctx context.Context, response any, queries ...Query) error
- func (d *DisputeClient) FetchOne(ctx context.Context, id string, response any) error
- func (d *DisputeClient) Resolve(ctx context.Context, id string, resolution enum.Resolution, message string, ...) error
- func (d *DisputeClient) Update(ctx context.Context, id string, referenceAmount int, response any, ...) error
- func (d *DisputeClient) UploadUrl(ctx context.Context, id string, response any, queries ...Query) error
- type IntegrationClient
- type MiscellaneousClient
- func (a MiscellaneousClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (p *MiscellaneousClient) Banks(ctx context.Context, country enum.Country, response any, queries ...Query) error
- func (p *MiscellaneousClient) Countries(ctx context.Context, response any) error
- func (p *MiscellaneousClient) States(ctx context.Context, response any, queries ...Query) error
- type OptionalPayload
- type PaymentPageClient
- func (a PaymentPageClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (p *PaymentPageClient) AddProducts(ctx context.Context, id string, products []string, response any) error
- func (p *PaymentPageClient) All(ctx context.Context, response any, queries ...Query) error
- func (p *PaymentPageClient) CheckSlug(ctx context.Context, slug string, response any) error
- func (p *PaymentPageClient) Create(ctx context.Context, name string, response any, ...) error
- func (p *PaymentPageClient) FetchOne(ctx context.Context, idOrSlug string, response any) error
- func (p *PaymentPageClient) Update(ctx context.Context, idOrSlug string, name string, description string, ...) error
- type PaymentRequestClient
- func (a PaymentRequestClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (p *PaymentRequestClient) All(ctx context.Context, response any, queries ...Query) error
- func (p *PaymentRequestClient) Archive(ctx context.Context, idOrCode string, response any) error
- func (p *PaymentRequestClient) Create(ctx context.Context, customerIdOrCode string, amount int, response any, ...) error
- func (p *PaymentRequestClient) FetchOne(ctx context.Context, idOrCode string, response any) error
- func (p *PaymentRequestClient) Finalize(ctx context.Context, idOrCode string, sendNotification bool, response any) error
- func (p *PaymentRequestClient) SendNotification(ctx context.Context, idOrCode string, response any) error
- func (p *PaymentRequestClient) Total(ctx context.Context, response any) error
- func (p *PaymentRequestClient) Update(ctx context.Context, idOrCode string, customerIdOrCode string, amount int, ...) error
- func (p *PaymentRequestClient) Verify(ctx context.Context, code string, response any) error
- type PaystackClient
- type PlanClient
- func (a PlanClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (p *PlanClient) All(ctx context.Context, response any, queries ...Query) error
- func (p *PlanClient) Create(ctx context.Context, name string, amount int, interval enum.Interval, ...) error
- func (p *PlanClient) FetchOne(ctx context.Context, idOrCode string, response any) error
- func (p *PlanClient) Update(ctx context.Context, idOrCode string, name string, amount int, ...) error
- type ProductClient
- func (a ProductClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (p *ProductClient) All(ctx context.Context, response any, queries ...Query) error
- func (p *ProductClient) Create(ctx context.Context, name string, description string, price int, ...) error
- func (p *ProductClient) FetchOne(ctx context.Context, id string, response any) error
- func (p *ProductClient) Update(ctx context.Context, id string, name string, description string, price int, ...) error
- type Query
- type RefundClient
- func (a RefundClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (r *RefundClient) All(ctx context.Context, response any, queries ...Query) error
- func (r *RefundClient) Create(ctx context.Context, transaction string, response any, ...) error
- func (r *RefundClient) FetchOne(ctx context.Context, reference string, response any) error
- type SettlementClient
- func (a SettlementClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (s *SettlementClient) All(ctx context.Context, response any, queries ...Query) error
- func (s *SettlementClient) AllTransactions(ctx context.Context, settlementId string, response any, queries ...Query) error
- type SubAccountClient
- func (a SubAccountClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (s *SubAccountClient) All(ctx context.Context, response any, queries ...Query) error
- func (s *SubAccountClient) Create(ctx context.Context, businessName string, settlementBank string, ...) error
- func (s *SubAccountClient) FetchOne(ctx context.Context, idOrCode string, response any) error
- func (s *SubAccountClient) Update(ctx context.Context, idOrCode string, businessName string, ...) error
- type SubscriptionClient
- func (a SubscriptionClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (s *SubscriptionClient) All(ctx context.Context, response any, queries ...Query) error
- func (s *SubscriptionClient) Create(ctx context.Context, customer string, plan string, authorization string, ...) error
- func (s *SubscriptionClient) Disable(ctx context.Context, code string, token string, response any) error
- func (s *SubscriptionClient) Enable(ctx context.Context, code string, token string, response any) error
- func (s *SubscriptionClient) FetchOne(ctx context.Context, idOrCode string, response any) error
- func (s *SubscriptionClient) GenerateLink(ctx context.Context, code string, response any) error
- func (s *SubscriptionClient) SendLink(ctx context.Context, code string, response any) error
- type TerminalClient
- func (a TerminalClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (t *TerminalClient) All(ctx context.Context, response any, queries ...Query) error
- func (t *TerminalClient) Commission(ctx context.Context, serialNumber string, response any) error
- func (t *TerminalClient) Decommission(ctx context.Context, serialNumber string, response any) error
- func (t *TerminalClient) EventStatus(ctx context.Context, terminalId string, eventId string, response any) error
- func (t *TerminalClient) FetchOne(ctx context.Context, terminalId string, response any) error
- func (t *TerminalClient) SendEvent(ctx context.Context, terminalId string, eventType enum.TerminalEvent, ...) error
- func (t *TerminalClient) TerminalStatus(ctx context.Context, terminalId string, response any) error
- func (t *TerminalClient) Update(ctx context.Context, terminalId string, name string, address string, ...) error
- type TransactionClient
- func (a TransactionClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (t *TransactionClient) All(ctx context.Context, response any, queries ...Query) error
- func (t *TransactionClient) ChargeAuthorization(ctx context.Context, amount int, email string, authorizationCode string, ...) error
- func (t *TransactionClient) Export(ctx context.Context, response any, queries ...Query) error
- func (t *TransactionClient) FetchOne(ctx context.Context, id string, response any) error
- func (t *TransactionClient) Initialize(ctx context.Context, amount int, email string, response any, ...) error
- func (t *TransactionClient) PartialDebit(ctx context.Context, authorizationCode string, currency enum.Currency, ...) error
- func (t *TransactionClient) Timeline(ctx context.Context, idOrReference string, response any) error
- func (t *TransactionClient) Total(ctx context.Context, response any, queries ...Query) error
- func (t *TransactionClient) Verify(ctx context.Context, reference string, response any) error
- type TransactionSplitClient
- func (a TransactionSplitClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (t *TransactionSplitClient) Add(ctx context.Context, id string, subAccount string, share int, response any) error
- func (t *TransactionSplitClient) All(ctx context.Context, response any, queries ...Query) error
- func (t *TransactionSplitClient) Create(ctx context.Context, name string, transactionSplitType enum.Split, ...) error
- func (t *TransactionSplitClient) FetchOne(ctx context.Context, id string, response any) error
- func (t *TransactionSplitClient) Remove(ctx context.Context, id string, subAccount string, response any) error
- func (t *TransactionSplitClient) Update(ctx context.Context, id string, name string, active bool, response any, ...) error
- type TransferClient
- func (a TransferClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (t *TransferClient) All(ctx context.Context, response any, queries ...Query) error
- func (t *TransferClient) BulkInitiate(ctx context.Context, source string, transfers, response any) error
- func (t *TransferClient) FetchOne(ctx context.Context, idOrCode string, response any) error
- func (t *TransferClient) Finalize(ctx context.Context, transferCode string, otp string, response any) error
- func (t *TransferClient) Initiate(ctx context.Context, source string, amount int, recipient string, response any, ...) error
- func (t *TransferClient) Verify(ctx context.Context, reference string, response any) error
- type TransferControlClient
- func (a TransferControlClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (t *TransferControlClient) Balance(ctx context.Context, response any) error
- func (t *TransferControlClient) BalanceLedger(ctx context.Context, response any) error
- func (t *TransferControlClient) DisableOtp(ctx context.Context, response any) error
- func (t *TransferControlClient) EnableOtp(ctx context.Context, response any) error
- func (t *TransferControlClient) FinalizeDisableOtp(ctx context.Context, otp string, response any) error
- func (t *TransferControlClient) ResendOtp(ctx context.Context, transferCode string, reason enum.Reason, response any) error
- type TransferRecipientClient
- func (a TransferRecipientClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (t *TransferRecipientClient) All(ctx context.Context, response any, queries ...Query) error
- func (t *TransferRecipientClient) BulkCreate(ctx context.Context, batch, response any) error
- func (t *TransferRecipientClient) Create(ctx context.Context, recipientType enum.RecipientType, name string, ...) error
- func (t *TransferRecipientClient) Delete(ctx context.Context, idOrCode string, response any) error
- func (t *TransferRecipientClient) FetchOne(ctx context.Context, idOrCode string, response any) error
- func (t *TransferRecipientClient) Update(ctx context.Context, idOrCode string, name string, response any, ...) error
- type VerificationClient
- func (a VerificationClient) APICall(ctx context.Context, method string, endPointPath string, payload any, ...) error
- func (v *VerificationClient) ResolveAccount(ctx context.Context, response any, queries ...Query) error
- func (v *VerificationClient) ResolveBin(ctx context.Context, bin string, response any) error
- func (v *VerificationClient) ValidateAccount(ctx context.Context, accountName string, accountNumber string, ...) error
Constants ¶
const BaseUrl = "https://api.paystack.co"
const Version = "0.1.0"
Variables ¶
var ErrNoSecretKey = errors.New("Paystack secret key was not provided")
Functions ¶
func AddQueryParamsToUrl ¶
AddQueryParamsToUrl lets you add query parameters to a url
Types ¶
type ApplePayClient ¶
type ApplePayClient struct {
// contains filtered or unexported fields
}
ApplePayClient interacts with endpoints related to paystack Apple Pay resource that lets you register your application's top-level domain or subdomain.
func NewApplePayClient ¶
func NewApplePayClient(options ...ClientOptions) *ApplePayClient
NewApplePayClient creates a ApplePayClient
func (*ApplePayClient) All ¶
All retrieves all registered Apple Pay domains on your integration.
It returns an empty array if no domains have been added.
Default response: models.Response[models.ApplePayDomains]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.ApplePayDomains]
if err := client.ApplePay.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.ApplePay.All(context.TODO(), &response, p.WithQuery("use_cursor", "true"))
}
For supported query parameters, see: https://paystack.com/docs/api/apple-pay/
func (*ApplePayClient) Register ¶
Register lets you register a top-level domain or subdomain for your Apple Pay Integration.
Default: response models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.ApplePay.Register(context.TODO(),"<domainName>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*ApplePayClient) Unregister ¶
Unregister lets you unregister a top-level domain or subdomain previously used for your Apple Pay Integration.
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.ApplePay.Unregister(context.TODO(),"<domainName>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type BulkChargeClient ¶
type BulkChargeClient struct {
// contains filtered or unexported fields
}
BulkChargeClient interacts with endpoints related to paystack bulk Charges resource that lets you create and manage multiple recurring payments from your Customers.
func NewBulkChargeClient ¶
func NewBulkChargeClient(options ...ClientOptions) *BulkChargeClient
NewBulkChargeClient creates a BulkChargeClient
func (*BulkChargeClient) All ¶
All lets you retrieve all bulk charge batches created by the Integration.
Default response: models.Response[[]models.BulkCharge]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.BulkCharge]
if err := client.BulkCharges.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.BulkCharges.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/bulk-charge/
func (*BulkChargeClient) Charges ¶
func (b *BulkChargeClient) Charges(ctx context.Context, idOrCode string, response any, queries ...Query) error
Charges lets you retrieve the Charges associated with a specified batch code.
Default response: models.Response[[]models.BulkChargeUnitCharge]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.BulkChargeUnitCharge]
if err := client.BulkCharges.Charges(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.BulkCharges.Charges(context.TODO(),"<idOrCode>", &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/bulk-charge/
func (*BulkChargeClient) FetchOne ¶
FetchOne lets you retrieve a specific batch code. It also returns useful information on its progress by way of the `total_charges` and `pending_charges` attributes.
Default response: models.Response[models.BulkCharge]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.BulkCharge]
if err := client.BulkCharges.FetchOne(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*BulkChargeClient) Initiate ¶
Initiate lets you send an array of map with authorization codes and amount, using the supported currency format, so paystack can process Transactions as a batch.
Default response: models.Response[models.BulkCharge]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
charges := []map[string]any{
{"authorization": "AUTH_ncx8hews93", "amount": 2500, "reference": "dam1266638dhhd"},
{"authorization": "AUTH_xfuz7dy4b9", "amount": 1500, "reference": "dam1266638dhhe"},
}
var response models.Response[models.BulkCharge]
if err := client.BulkCharges.Initiate(context.TODO(),charges, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*BulkChargeClient) Pause ¶
Pause lets you pause a processing a batch
Default response: response models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.BulkCharges.Pause(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*BulkChargeClient) Resume ¶
Resume lets you resume a paused batch
Default response: response models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.BulkCharges.Resume(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type ChargeClient ¶
type ChargeClient struct {
// contains filtered or unexported fields
}
ChargeClient interacts with endpoints related to paystack charge resource that lets you configure a payment channel of your choice when initiating a payment.
func NewChargeClient ¶
func NewChargeClient(options ...ClientOptions) *ChargeClient
NewChargeClient creates a ChargeClient
func (*ChargeClient) Create ¶
func (c *ChargeClient) Create(ctx context.Context, email string, amount string, response any, optionalPayloads ...OptionalPayload) error
Create lets you initiate a payment by integrating the payment channel of your choice.
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Charges.Create(context.TODO(),"johndoe@example.com",100000, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Charges.Create(context.TODO(),"johndoe@example.com",100000, &response,p.WithOptionalPayload("authorization_code","AUTH_xxx"))
}
For supported optional parameters, see: https://paystack.com/docs/api/charge/
func (*ChargeClient) PendingCharge ¶
PendingCharge lets you check the status of a charge. When you get pending as a charge status or if there was an exception when calling any of the ChargeClient methods, wait 10 seconds or more, then make a check to see if its status has changed. Don't call too early as you may get a lot more pending than you should.
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Charges.PendingCharge(context.TODO(), "5bwib5v6anhe9xa", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*ChargeClient) SubmitAddress ¶
func (c *ChargeClient) SubmitAddress(ctx context.Context, address string, reference string, city string, state string, zipCode string, response any) error
SubmitAddress lets you submit address to continue a charge
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Charges.SubmitAddress(context.TODO(),"140 N 2ND ST", "7c7rpkqpc0tijs8", "Stroudsburg", "PA", "18360", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*ChargeClient) SubmitBirthday ¶
func (c *ChargeClient) SubmitBirthday(ctx context.Context, birthday string, reference string, response any) error
SubmitBirthday lets you submit a birthday when requested
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Charges.SubmitBirthday(context.TODO(),"2016-09-21", "5bwib5v6anhe9xa", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*ChargeClient) SubmitOtp ¶ added in v0.2.0
func (c *ChargeClient) SubmitOtp(ctx context.Context, otp string, reference string, response any) error
SubmitOtp lets you submit otp to complete a charge
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Charges.SubmitOpt(context.TODO(),"123456", "5bwib5v6anhe9xa", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*ChargeClient) SubmitPhone ¶
func (c *ChargeClient) SubmitPhone(ctx context.Context, phone string, reference string, response any) error
SubmitPhone lets you submit phone number when requested
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Charges.SubmitPhone(context.TODO(),"08012345678", "5bwib5v6anhe9xa", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*ChargeClient) SubmitPin ¶
func (c *ChargeClient) SubmitPin(ctx context.Context, pin string, reference string, response any) error
SubmitPin lets you submit pin to continue a charge
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Charges.SubmitPin(context.TODO(),"1234", "5bwib5v6anhe9xa", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type ClientOptions ¶
type ClientOptions = func(client *restClient)
ClientOptions is a type used to modify attributes of an APIClient. It can be passed into the NewAPIClient function while creating an APIClient
func WithBaseUrl ¶
func WithBaseUrl(baseUrl string) ClientOptions
WithBaseUrl lets you override paystack's base url for an APIClient. It should be used when creating an APIClient with the NewAPIClient function.
func WithSecretKey ¶
func WithSecretKey(secretKey string) ClientOptions
WithSecretKey lets you set the secret key of an APIClient. It should be used when creating an APIClient with the NewAPIClient function.
Example
import p "github.com/gray-adeyi/paystack"
client := p.NewAPIClient(p.WithSecretKey("<your-paystack-secret-key>"))
type CustomerClient ¶
type CustomerClient struct {
// contains filtered or unexported fields
}
CustomerClient interacts with endpoints related to paystack Customer resource that allows you to create and manage Customers on your Integration.
func NewCustomerClient ¶
func NewCustomerClient(options ...ClientOptions) *CustomerClient
NewCustomerClient creates a CustomerClient
func (*CustomerClient) All ¶
All lets you retrieve Customers available on your Integration.
Default response: models.Response[[]models.Customer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Customer]
if err := client.Customers.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Customers.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/customer/
func (*CustomerClient) Create ¶
func (c *CustomerClient) Create(ctx context.Context, email string, firstName string, lastName string, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a customer on your Integration
Default response: models.Response[models.Customer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Customer]
if err := client.Customers.Create(context.TODO(),"johndoe@example.com","John","Doe", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Customers.Create(context.TODO(),"johndoe@example.com","John","Doe", &response, p.WithOptionalPayload("phone","+2348123456789"))
}
For supported optional parameters, see: https://paystack.com/docs/api/customer/
func (*CustomerClient) Deactivate ¶
func (c *CustomerClient) Deactivate(ctx context.Context, authorizationCode string, response any) error
Deactivate lets you deactivate an authorization when the card needs to be forgotten
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.Customers.Deactivate(context.TODO(),"AUTH_72btv547", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*CustomerClient) FetchOne ¶
FetchOne lets you retrieve the details of a customer on your Integration
Default response: models.Response[models.Customer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Customer]
if err := client.Customers.FetchOne(context.TODO(),"<emailOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*CustomerClient) Flag ¶
func (c *CustomerClient) Flag(ctx context.Context, emailOrCode string, response any, optionalPayloads ...OptionalPayload) error
Flag lets you whitelist or blacklist a customer on your Integration
Default response: models.Response[models.Customer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Customer]
if err := client.Customers.Flag(context.TODO(),"CUS_xr58yrr2ujlft9k", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Customers.Flag(context.TODO(),"CUS_xr58yrr2ujlft9k", &response, p.WithOptionalPayload("risk_action","allow"))
}
For supported optional parameters, see: https://paystack.com/docs/api/customer/
func (*CustomerClient) Update ¶
func (c *CustomerClient) Update(ctx context.Context, code string, response any, optionalPayloads ...OptionalPayload) error
Update lets you update a customer's details on your Integration
Default response: models.Response[models.Customer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Customer]
if err := client.Customers.Update(context.TODO(),"<code>", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Customers.Update(context.TODO(),"<code>", &response, p.WithOptionalPayload("first_name","John"))
}
For supported optional parameters, see: https://paystack.com/docs/api/customer/
func (*CustomerClient) Validate ¶
func (c *CustomerClient) Validate(ctx context.Context, code string, firstName string, lastName string, identificationType string, value string, country enum.Country, bvn string, bankCode string, accountNumber string, response any, optionalPayloads ...OptionalPayload) error
Validate lets you validate a customer's identity
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.Customers.Validate(context.TODO(),"<code>", "Asta","Lavista","bank_account","",enum.CountryNigeria,"20012345677","007","0123456789", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Customers.Validate(context.TODO(),"<code>", "Asta","Lavista","bank_account","",enum.CountryNigeria,"20012345677","007","0123456789", &response, , p.WithOptionalPayload("middle_name","Doe"))
}
For supported optional parameters, see: https://paystack.com/docs/api/customer/
type DedicatedVirtualAccountClient ¶
type DedicatedVirtualAccountClient struct {
// contains filtered or unexported fields
}
DedicatedVirtualAccountClient interacts with endpoints related to paystack dedicated virtual account resource that enables Nigerian merchants to manage unique payment accounts of their Customers.
func NewDedicatedVirtualAccountClient ¶
func NewDedicatedVirtualAccountClient(options ...ClientOptions) *DedicatedVirtualAccountClient
NewDedicatedVirtualAccountClient creates a DedicatedVirtualAccountClient
func (*DedicatedVirtualAccountClient) All ¶
func (d *DedicatedVirtualAccountClient) All(ctx context.Context, response any, queries ...Query) error
All lets you retrieve dedicated virtual accounts available on your Integration.
Default response: models.Response[[]models.DedicatedAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.DedicatedAccount]
if err := client.DedicatedVirtualAccounts.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.DedicatedVirtualAccounts.All(context.TODO(), &response,p.WithQuery("active","true"), p.WithQuery("bank_id","035"))
}
For supported query parameters, see: https://paystack.com/docs/api/dedicated-virtual-account/
func (*DedicatedVirtualAccountClient) Assign ¶
func (d *DedicatedVirtualAccountClient) Assign(ctx context.Context, email string, firstName string, lastName string, phone string, preferredBank string, country enum.Country, response any, optionalPayloads ...OptionalPayload) error
Assign lets you can create a customer, validate the customer, and assign a DVA to the customer.
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DedicatedAccount]
if err := client.DedicatedVirtualAccounts.Assign(context.TODO(),"janedoe@test.com","Jane", "Doe","Karen", "+2348100000000", "test-bank", enum.CountryNigeria, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.DedicatedVirtualAccounts.Assign(context.TODO(),"janedoe@test.com","Jane", "Doe","Karen", "+2348100000000", "test-bank", enum.CountryNigeria, &response, p.WithOptionalPayload("account_number","5273681014"))
}
For supported optional parameters, see: https://paystack.com/docs/api/dedicated-virtual-account/
func (*DedicatedVirtualAccountClient) BankProviders ¶
func (d *DedicatedVirtualAccountClient) BankProviders(ctx context.Context, response any) error
BankProviders lets you retrieve available bank providers for a dedicated virtual account
Default response: models.Response[[]models.DedicatedAccountProvider]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.DedicatedAccountProvider]
if err := client.DedicatedVirtualAccounts.BankProviders(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*DedicatedVirtualAccountClient) Create ¶
func (d *DedicatedVirtualAccountClient) Create(ctx context.Context, customerIdOrCode string, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a dedicated virtual account for an existing customer
Default response: models.Response[models.DedicatedAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DedicatedAccount]
if err := client.DedicatedVirtualAccounts.Create(context.TODO(),"CUS_xr58yrr2ujlft9k", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.DedicatedVirtualAccounts.Create(context.TODO(),"CUS_xr58yrr2ujlft9k", &response, p.WithOptionalPayload("preferred_bank","wema-bank"))
}
For supported optional parameters, see: https://paystack.com/docs/api/dedicated-virtual-account/
func (*DedicatedVirtualAccountClient) Deactivate ¶
func (d *DedicatedVirtualAccountClient) Deactivate(ctx context.Context, id string, response any) error
Deactivate lets you deactivate a dedicated virtual account on your Integration.
Default response: models.Response[models.DedicatedAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DedicatedAccount]
if err := client.DedicatedVirtualAccounts.Deactivate(context.TODO(),"<dedicatedAccountId>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*DedicatedVirtualAccountClient) FetchOne ¶
func (d *DedicatedVirtualAccountClient) FetchOne(ctx context.Context, dedicatedAccountId string, response any) error
FetchOne lets you retrieve details of a dedicated virtual account on your Integration.
Default response: models.Response[models.DedicatedAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DedicatedAccount]
if err := client.DedicatedVirtualAccounts.FetchOne(context.TODO(),"<dedicatedAccountId>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*DedicatedVirtualAccountClient) RemoveSplit ¶
func (d *DedicatedVirtualAccountClient) RemoveSplit(ctx context.Context, accountNumber string, response any) error
RemoveSplit lets you remove a split payment for Transactions. If you've previously set up split payment for Transactions on a dedicated virtual account
Default response: models.Response[models.DedicatedAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DedicatedAccount]
if err := client.DedicatedVirtualAccounts.RemoveSplit(context.TODO(),"<accountNumber>",&response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*DedicatedVirtualAccountClient) Requery ¶
func (d *DedicatedVirtualAccountClient) Requery(ctx context.Context, accountNumber, providerSlug string, response any, queries ...Query) error
Requery lets you requery Dedicated Virtual Account for new Transactions
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.DedicatedAccount]
if err := client.DedicatedVirtualAccounts.Requery(context.TODO(),"1234567890","wema-bank", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.DedicatedVirtualAccounts.Requery(context.TODO(),"1234567890","wema-bank", &response,p.WithQuery("date","2025-06-20"))
}
For supported query parameters, see: https://paystack.com/docs/api/dedicated-virtual-account/
func (*DedicatedVirtualAccountClient) Split ¶
func (d *DedicatedVirtualAccountClient) Split(ctx context.Context, customerIdOrCode string, response any, optionalPayloads ...OptionalPayload) error
Split lets you split a dedicated virtual account transaction with one or more accounts
Default response: models.Response[models.DedicatedAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DedicatedAccount]
if err := client.DedicatedVirtualAccounts.Split(context.TODO(),"<customerIdOrCode>",&response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.DedicatedVirtualAccounts.Split(context.TODO(),"<customerIdOrCode>",p.WithOptionalPayload("preferred_bank","wema-bank"))
}
For supported optional parameters, see: https://paystack.com/docs/api/dedicated-virtual-account/
type DisputeClient ¶
type DisputeClient struct {
// contains filtered or unexported fields
}
DisputeClient interacts with endpoint related to paystack dispute resource that lets you manage transaction Disputes on your Integration.
func NewDisputeClient ¶
func NewDisputeClient(options ...ClientOptions) *DisputeClient
NewDisputeClient creates a DisputeClient
func (*DisputeClient) AddEvidence ¶
func (d *DisputeClient) AddEvidence(ctx context.Context, id string, customerEmail string, customerName string, customerPhone string, serviceDetails string, response any, optionalPayloads ...OptionalPayload) error
AddEvidence lets you provide evidence for a dispute
Default response: models.Response[models.DisputeEvidence]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DisputeEvidence]
if err := client.Disputes.AddEvidence(context.TODO(),"<id>", "johndoe@example.com", "John Doe", "5085072209", "claim for buying product", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Disputes.AddEvidence(context.TODO(),"<id>", "johndoe@example.com", "John Doe", "5085072209", "claim for buying product", &response,p.WithOptionalPayload("delivery_address", "3a ladoke street ogbomoso"))
}
For supported optional parameters, see: https://paystack.com/docs/api/dispute/
func (*DisputeClient) All ¶
All lets you retrieve Disputes filed against you
Default response: models.Response[[]models.Dispute]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Dispute]
if err := client.Disputes.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Disputes.All(context.TODO(), &response,p.WithQuery("from","2023-01-01"), p.WithQuery("to","2023-12-31"))
}
For supported query parameters, see: https://paystack.com/docs/api/dispute/
func (*DisputeClient) AllTransactionDisputes ¶
func (d *DisputeClient) AllTransactionDisputes(ctx context.Context, transactionId string, response any) error
AllTransactionDisputes lets you retrieve Disputes for a particular transaction
Default response: models.Response[[]models.Dispute]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Dispute]
if err := client.Disputes.AllTransactionDisputes(context.TODO(),<transactionId>, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*DisputeClient) Export ¶
Export lets you export Disputes available on your Integration
Default response: models.Response[models.DisputeExportInfo]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DisputeExportInfo]
if err := client.Disputes.Export(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Disputes.Export(context.TODO(), &response,p.WithQuery("from","2023-01-01"), p.WithQuery("to","2023-12-31"))
}
For supported query parameters, see: https://paystack.com/docs/api/dispute/
func (*DisputeClient) FetchOne ¶
FetchOne lets you retrieve more details about a dispute.
Default response: models.Response[models.Dispute]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Dispute]
if err := client.Disputes.FetchOne(context.TODO(),"<id>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*DisputeClient) Resolve ¶
func (d *DisputeClient) Resolve(ctx context.Context, id string, resolution enum.Resolution, message string, refundAmount int, uploadedFilename string, response any, optionalPayloads ...OptionalPayload) error
Resolve lets you resolve a dispute on your Integration
Default response: models.Response[models.Dispute]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Dispute]
if err := client.Disputes.Resolve(context.TODO(),enum.ResolutionMerchantAccepted,"Merchant accepted","qesp8a4df1xejihd9x5q",1002, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Disputes.Resolve(context.TODO(),enum.ResolutionMerchantAccepted,"Merchant accepted","qesp8a4df1xejihd9x5q",1002, &response,p.WithOptionalPayload("evidence", "<evidenceId>"))
}
For supported optional parameters, see: https://paystack.com/docs/api/dispute/
func (*DisputeClient) Update ¶
func (d *DisputeClient) Update(ctx context.Context, id string, referenceAmount int, response any, optionalPayloads ...OptionalPayload) error
Update lets you update the details of a dispute on your Integration
Default response: models.Response[models.Dispute]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Dispute]
if err := client.Disputes.Update(context.TODO(),"<id>","<referenceAmount>", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Disputes.Update(context.TODO(),"<id>","<referenceAmount>", &response,p.WithOptionalPayload("uploaded_filename","Disputes.pdf"))
}
For supported optional parameters, see: https://paystack.com/docs/api/dispute/
func (*DisputeClient) UploadUrl ¶ added in v0.2.0
func (d *DisputeClient) UploadUrl(ctx context.Context, id string, response any, queries ...Query) error
UploadUrl lets you retrieve Disputes for a particular transaction
Default response: models.Response[models.DisputeUploadInfo]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.DisputeUploadInfo]
if err := client.Disputes.UploadUrl(context.TODO(),"<disputeId>", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Disputes.UploadUrl(context.TODO(),"<disputeId>", &response,p.WithQuery("upload_filename","filename.pdf"))
}
For supported query parameters, see: https://paystack.com/docs/api/dispute/
type IntegrationClient ¶
type IntegrationClient struct {
// contains filtered or unexported fields
}
IntegrationClient interacts with endpoints related to paystack Integration resource that lets you manage some settings on your Integration.
func NewIntegrationClient ¶
func NewIntegrationClient(options ...ClientOptions) *IntegrationClient
NewIntegrationClient creates an IntegrationClient
func (*IntegrationClient) Timeout ¶
func (i *IntegrationClient) Timeout(ctx context.Context, response any) error
Timeout lets you retrieve the payment session timeout on your Integration
Default response: models.Response[models.IntegrationTimeout]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.IntegrationTimeout]
if err := client.Integration.Timeout(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*IntegrationClient) UpdateTimeout ¶
UpdateTimeout lets you update the payment session timeout on your Integration
Default response: models.Response[models.IntegrationTimeout]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.IntegrationTimeout]
if err := client.Integration.UpdateTimeout(context.TODO(),5, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type MiscellaneousClient ¶
type MiscellaneousClient struct {
// contains filtered or unexported fields
}
MiscellaneousClient interacts with endpoints related to paystack Miscellaneous resource that provides information that is relevant to other client methods
func NewMiscellaneousClient ¶
func NewMiscellaneousClient(options ...ClientOptions) *MiscellaneousClient
NewMiscellaneousClient creates a MiscellaneousClient
func (*MiscellaneousClient) Banks ¶
func (p *MiscellaneousClient) Banks(ctx context.Context, country enum.Country, response any, queries ...Query) error
Banks lets you retrieve a list of all supported banks and their properties
Default response: models.Response[[]models.Bank]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Bank]
if err := client.Miscellaneous.Banks(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Miscellaneous.Banks(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/miscellaneous/
func (*MiscellaneousClient) Countries ¶
func (p *MiscellaneousClient) Countries(ctx context.Context, response any) error
Countries let you retrieve a list of countries that Paystack currently supports
Default response: models.Response[[]models.PaystackSupportedCountry]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.PastackSupportedCountry]
if err := client.Miscellaneous.Countries(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*MiscellaneousClient) States ¶
States lets you retrieve a list of states for a country for address Verification
Default response: models.Response[[]models.State]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.State]
if err := client.Miscellaneous.States(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Miscellaneous.States(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/miscellaneous/
type OptionalPayload ¶ added in v0.2.0
OptionalPayload is a type for storing optional parameters used by some APIClient methods that needs to accept optional parameter.
func WithOptionalPayload ¶ added in v0.2.0
func WithOptionalPayload(key string, value any) OptionalPayload
WithOptionalPayload lets you add optional parameters when calling some client methods and you need to add optional parameters to your payload.
Example
import (
p "github.com/gray-adeyi/paystack"
"context"
)
client := p.NewAPIClient(p.WithSecretKey("<your-paystack-secret-key>"))
resp, err := client.DedicatedVirtualAccounts.Create(context.TODO(),"481193", p.WithOptionalPayload("preferred_bank","wema-bank"))
WithOptionalPayload is used to pass the `preferred_bank` optional parameter in the client method call
type PaymentPageClient ¶
type PaymentPageClient struct {
// contains filtered or unexported fields
}
PaymentPageClient interacts with endpoints related to paystack payment page resource that lets you provide a quick and secure way to collect payment for Products.
func NewPaymentPageClient ¶
func NewPaymentPageClient(options ...ClientOptions) *PaymentPageClient
NewPaymentPageClient creates a PaymentPageClient
func (*PaymentPageClient) AddProducts ¶
func (p *PaymentPageClient) AddProducts(ctx context.Context, id string, products []string, response any) error
AddProducts lets you add Products to a payment page
Default response: models.Response[models.PaymentPage]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentPage]
if err := client.PaymentPages.AddProducts(context.TODO(),"<id>", []string{4"73", "292"}, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PaymentPageClient) All ¶
All lets you retrieve payment pages available on your Integration
Default response: models.Response[[]models.PaymentPage]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.PaymentPage]
if err := client.PaymentPages.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.PaymentPages.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/page/
func (*PaymentPageClient) CheckSlug ¶
CheckSlug lets you check the availability of a slug for a payment page
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.PaymentPages.CheckSlug(context.TODO(),"<slug>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PaymentPageClient) Create ¶
func (p *PaymentPageClient) Create(ctx context.Context, name string, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a payment page on your Integration
Default response: models.Response[models.PaymentPage]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentPage]
if err := client.PaymentPages.Create(context.TODO(),"Buttercup Brunch", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.PaymentPages.Create(context.TODO(),"Buttercup Brunch", &response, p.WithOptionalPayload("amount",500000))
}
For supported optional parameters, see: https://paystack.com/docs/api/page/
func (*PaymentPageClient) FetchOne ¶
FetchOne lets you retrieve details of a payment page on your Integration
Default response: models.Response[models.PaymentPage]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentPage]
if err := client.PaymentPages.FetchOne(context.TODO(),"<idOrSlug>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PaymentPageClient) Update ¶
func (p *PaymentPageClient) Update(ctx context.Context, idOrSlug string, name string, description string, response any, optionalPayloads ...OptionalPayload) error
Update lets you update a payment page details on your Integration
Default response: models.Response[models.PaymentPage]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentPage]
if err := client.PaymentPages.Update(context.TODO(),"<idOrSlug>", "Buttercup Brunch", "description", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.PaymentPages.Update(context.TODO(), "Buttercup Brunch", "description", &response, p.WithOptionalPayload("amount",500000))
}
For supported optional parameters, see: https://paystack.com/docs/api/page/
type PaymentRequestClient ¶
type PaymentRequestClient struct {
// contains filtered or unexported fields
}
PaymentRequestClient interacts with endpoints related to paystack payment request resource that lets you manage requests for payment of goods and services.
func NewPaymentRequestClient ¶
func NewPaymentRequestClient(options ...ClientOptions) *PaymentRequestClient
NewPaymentRequestClient creates a PaymentRequestClient
func (*PaymentRequestClient) All ¶
Default response: models.Response[[]models.PaymentRequest]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.PaymentRequest]
if err := client.Customers.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.PaymentRequests.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/payment-request/
func (*PaymentRequestClient) Archive ¶
Archive lets you archive a payment request. A payment request will no longer be fetched on list or returned on verify
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.PaymentRequests.Archive(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PaymentRequestClient) Create ¶
func (p *PaymentRequestClient) Create(ctx context.Context, customerIdOrCode string, amount int, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a payment request for a transaction on your Integration
Default response: models.Response[models.PaymentRequest]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Customer]
if err := client.PaymentRequests.Create(context.TODO(),"CUS_xwaj0txjryg393b", 500000, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.PaymentRequests.Create(context.TODO(),"CUS_xwaj0txjryg393b", 500000, &response, p.WithOptionalPayload("due_date","2023-12-25"))
}
For supported optional parameters, see: https://paystack.com/docs/api/payment-request/
func (*PaymentRequestClient) FetchOne ¶
FetchOne lets you retrieve details of a payment request on your Integration
Default response: models.Response[models.PaymentRequest]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentRequest]
if err := client.PaymentRequests.FetchOne(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PaymentRequestClient) Finalize ¶
func (p *PaymentRequestClient) Finalize(ctx context.Context, idOrCode string, sendNotification bool, response any) error
Finalize lets you finalize a draft payment request
Default response: models.Response[models.PaymentRequest]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentRequest]
if err := client.PaymentRequests.Finalize(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PaymentRequestClient) SendNotification ¶
func (p *PaymentRequestClient) SendNotification(ctx context.Context, idOrCode string, response any) error
SendNotification lets you send notification of a payment request to your Customers
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.PaymentRequests.SendNotification(context.TODO(),"<code>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PaymentRequestClient) Total ¶
func (p *PaymentRequestClient) Total(ctx context.Context, response any) error
Total lets you retrieve payment requests metric
Default response: models.Response[models.PaymentRequestStat]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentRequestStat]
if err := client.PaymentRequests.Total(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PaymentRequestClient) Update ¶
func (p *PaymentRequestClient) Update(ctx context.Context, idOrCode string, customerIdOrCode string, amount int, response any, optionalPayloads ...OptionalPayload) error
Update lets you update a payment request details on your Integration
Default response: models.Response[models.PaymentRequest]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentRequest]
if err := client.PaymentRequests.Update(context.TODO(),"<idOrCode>", 50000, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.PaymentRequests.Update(context.TODO(),"<idOrCode>", 50000, &response, p.WithOptionalPayload("description","update description"))
}
For supported optional parameters, see: https://paystack.com/docs/api/payment-request/
func (*PaymentRequestClient) Verify ¶
Verify lets you verify the details of a payment request on your Integration
Default response: models.Response[models.PaymentRequest]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.PaymentRequest]
if err := client.PaymentRequests.Verify(context.TODO(),"<code>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type PaystackClient ¶ added in v0.2.0
type PaystackClient struct {
// Transactions let you interact with endpoints related to paystack Transaction resource
// that allows you to create and manage payments on your Integration.
Transactions *TransactionClient
// TransactionSplits lets you interact with endpoints related to paystack Transaction Split resource
// that allows you to split the settlement for a transaction across a payout account, and one or
// more subaccounts.
TransactionSplits *TransactionSplitClient
// Terminals let you interact with endpoints related to paystack Terminal resource that allows you to
// build delightful in-person payment experiences.
Terminals *TerminalClient
// Customers let you interact with endpoints related to paystack Customer resource
// that allows you to create and manage Customers on your Integration.
Customers *CustomerClient
// DedicatedVirtualAccounts lets you interact with endpoints related to paystack dedicated virtual account
// resource that enables Nigerian merchants to manage unique payment accounts of their Customers.
DedicatedVirtualAccounts *DedicatedVirtualAccountClient
// ApplePay lets you interact with endpoints related to paystack Apple Pay resource that
// lets you register your application's top-level domain or subdomain.
ApplePay *ApplePayClient
// SubAccounts lets you interact with endpoints related to paystack subaccount resource that lets you
// create and manage subaccounts on your Integration. Subaccounts can be used to split payment
// between two accounts (your main account and a subaccount).
SubAccounts *SubAccountClient
// Plans lets you interact with endpoints related to paystack plan resource that lets you
// create and manage installment payment options on your Integration.
Plans *PlanClient
// Subscriptions let you interact with endpoints related to paystack subscription resource that lets you
// create and manage recurring payment on your Integration.
Subscriptions *SubscriptionClient
// Products let you interact with endpoints related to paystack product resource that allows you to create and
// manage inventories on your Integration.
Products *ProductClient
// PaymentPages let you interact with endpoints related to paystack payment page resource
// that lets you provide a quick and secure way to collect payment for Products.
PaymentPages *PaymentPageClient
// PaymentRequests let you interacts with endpoints related to paystack payment request resource that lets you manage requests
// for payment of goods and services.
PaymentRequests *PaymentRequestClient
// Settlements let you interact with endpoints related to paystack settlement resource that lets you
// gain insights into payouts made by Paystack to your bank account.
Settlements *SettlementClient
// TransferRecipients let you interact with endpoints related to paystack transfer recipient resource
// that lets you create and manage beneficiaries that you send money to.
TransferRecipients *TransferRecipientClient
// Transfers let you interact with endpoints related to paystack transfer resource that lets you
// automate sending money to your Customers.
Transfers *TransferClient
// TransferControl let you interact with endpoints related to paystack transfer control resource that lets
// you manage settings of your Transfers.
TransferControl *TransferControlClient
// BulkCharges let you interact with endpoints related to paystack bulk Charges resource that lets
// you create and manage multiple recurring payments from your Customers.
BulkCharges *BulkChargeClient
// Integration let you interact with endpoints related to paystack Integration resource
// that lets you manage some settings on your Integration.
Integration *IntegrationClient
// Charge let you interact with endpoints related to paystack charge resource that
// lets you configure a payment channel of your choice when initiating a payment.
Charges *ChargeClient
// Disputes let you interact with endpoint related to paystack dispute resource that lets you
// manage transaction Disputes on your Integration.
Disputes *DisputeClient
// Refunds let you interact with endpoints related to paystack refund resource that lets you
// create and manage transaction Refunds.
Refunds *RefundClient
// Verification let you interact with endpoints related to paystack Verification resource
// that allows you to perform KYC processes.
Verification *VerificationClient
// Miscellaneous let you interact with endpoints related to paystack Miscellaneous resource that
// provides information that is relevant to other client methods
Miscellaneous *MiscellaneousClient
// contains filtered or unexported fields
}
PaystackClient is a struct that has other dedicated clients bound to it. This provides a convenience for interacting with all of paystack's endpoints in your Go project. It should not be instantiated directly but interacting but via the NewAPIClient function. As stated above, it has other dedicated clients bound to it as field, therefore, after creating an instance of the PaystackClient type. You can access the associated functions of each dedicated client via its field name.
Example
import (
p "github.com/gray-adeyi/paystack"
"context"
)
client := p.NewAPIClient(p.WithSecretKey("<your-paystack-secret-key>"))
resp, err := client.Transactions.Verify(context.TODO(),"<reference>")
func NewClient ¶ added in v0.2.0
func NewClient(options ...ClientOptions) *PaystackClient
NewClient lets you create an APIClient. it can accept zero to many client options
Example
import p "github.com/gray-adeyi/paystack"
client := p.NewClient(p.WithSecretKey("<your-paystack-secret-key>"))
type PlanClient ¶
type PlanClient struct {
// contains filtered or unexported fields
}
PlanClient interacts with endpoints related to paystack plan resource that lets you create and manage installment payment options on your Integration.
func NewPlanClient ¶
func NewPlanClient(options ...ClientOptions) *PlanClient
NewPlanClient creates a PlanClient
func (*PlanClient) All ¶
All lets you retrieve Plans available on your Integration
Default response: models.Response[[]models.Plan]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Plan]
if err := client.Plans.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Plans.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/plan/
func (*PlanClient) Create ¶
func (p *PlanClient) Create(ctx context.Context, name string, amount int, interval enum.Interval, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a plan on your Integration
Default response: models.Response[models.Plan]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Plan]
if err := client.Plans.Create(context.TODO(),"Monthly retainer", 500000, enum.IntervalMonthly, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Plans.Create(context.TODO(),"Monthly retainer", 500000, enum.IntervalMonthly, &response, p.WithOptionalPayload("description","a test description"))
}
For supported optional parameters, see: https://paystack.com/docs/api/plan/
func (*PlanClient) FetchOne ¶
FetchOne lets you retrieve details of a plan on your Integration
Default response: models.Response[models.Plan]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Plan]
if err := client.Plans.FetchOne(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*PlanClient) Update ¶
func (p *PlanClient) Update(ctx context.Context, idOrCode string, name string, amount int, interval enum.Interval, response any, optionalPayloads ...OptionalPayload) error
Update lets you update a plan details on your Integration
Default response: models.Response[models.Plan]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Plan]
if err := client.Plans.Update(context.TODO(),"<idOrCode>","Monthly retainer", 500000, enum.IntervalMonthly, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Plans.Update(context.TODO(),"<idOrCode>","Monthly retainer", 500000, enum.IntervalMonthly, &response, p.WithOptionalPayload("description","test description"))
}
For supported optional parameters, see: https://paystack.com/docs/api/plan/
type ProductClient ¶
type ProductClient struct {
// contains filtered or unexported fields
}
ProductClient interacts with endpoints related to paystack product resource that allows you to create and manage inventories on your Integration.
func NewProductClient ¶
func NewProductClient(options ...ClientOptions) *ProductClient
NewProductClient creates a ProductClient
func (*ProductClient) All ¶
All lets you retrieve Products available on your Integration
Default response: models.Response[[]models.Product]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Product]
if err := client.Products.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Products.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/product/
func (*ProductClient) Create ¶
func (p *ProductClient) Create(ctx context.Context, name string, description string, price int, currency enum.Currency, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a product on your Integration
Default response: models.Response[models.Product]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Product]
if err := client.Products.Create(context.TODO(),"Puff Puff", "Crispy flour ball with fluffy interior", 5000, enum.CurrencyNgn, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Products.Create(context.TODO(),"Puff Puff", "Crispy flour ball with fluffy interior", 5000, enum.CurrencyNgn, &response, p.WithOptionalPayload("unlimited","true"))
}
For supported optional parameters, see: https://paystack.com/docs/api/product/
func (*ProductClient) FetchOne ¶
FetchOne lets you Get details of a product on your Integration
Default response: models.Response[models.Product]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Product]
if err := client.Plans.FetchOne(context.TODO(),"<id>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*ProductClient) Update ¶
func (p *ProductClient) Update(ctx context.Context, id string, name string, description string, price int, currency enum.Currency, response any, optionalPayloads ...OptionalPayload) error
Update lets you update a product details on your Integration
Default response: models.Response[models.Product]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Plan]
if err := client.Products.Update(context.TODO(),"<id>", "Product Six", "Product Six Description",500000, enum.CurrencyUsd, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Products.Update(context.TODO(),"<id>", "Product Six", "Product Six Description",500000, enum.CurrencyUsd, &response, p.WithOptionalPayload("unlimited","true"))
}
type RefundClient ¶
type RefundClient struct {
// contains filtered or unexported fields
}
RefundClient interacts with endpoints related to paystack refund resource that lets you create and manage transaction Refunds.
func NewRefundClient ¶
func NewRefundClient(options ...ClientOptions) *RefundClient
NewRefundClient creates a RefundClient
func (*RefundClient) All ¶
All lets you retrieve Refunds available on your Integration
Default response: models.Response[[]models.Refund]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Refund]
if err := client.Refunds.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Refunds.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/refund/
func (*RefundClient) Create ¶
func (r *RefundClient) Create(ctx context.Context, transaction string, response any, optionalPayloads ...OptionalPayload) error
Create lets you create and manage transaction Refunds.
Default response: models.Response[models.Refund]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Refund]
if err := client.Refunds.Create(context.TODO(),"1641", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Refunds.Create(context.TODO(),"1641", &response, p.WithOptionalPayload("amount",500000))
}
For supported optional parameters, see: https://paystack.com/docs/api/refund/
func (*RefundClient) FetchOne ¶
FetchOne lets you retrieve the details of a refund on your Integration
Default response: models.Response[models.Refund]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Refund]
if err := client.Plans.FetchOne(context.TODO(),"<reference>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type SettlementClient ¶
type SettlementClient struct {
// contains filtered or unexported fields
}
SettlementClient interacts with endpoints related to paystack settlement resource that lets you gain insights into payouts made by Paystack to your bank account.
func NewSettlementClient ¶
func NewSettlementClient(options ...ClientOptions) *SettlementClient
NewSettlementClient creates a SettlementClient
func (*SettlementClient) All ¶
All lets you retrieve Settlements made to your settlement accounts
Default response: models.Response[[]models.Settlement]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Settlement]
if err := client.Settlements.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Settlements.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/settlement/
func (*SettlementClient) AllTransactions ¶
func (s *SettlementClient) AllTransactions(ctx context.Context, settlementId string, response any, queries ...Query) error
AllTransactions lets you retrieve the Transactions that make up a particular settlement
Default response: models.Response[[]models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Transaction]
if err := client.Settlements.AllTransactions(context.TODO(), "<settlementId>",&response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Settlements.AllTransactions(context.TODO(),"<settlementId>", &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/settlement/
type SubAccountClient ¶
type SubAccountClient struct {
// contains filtered or unexported fields
}
SubAccountClient interacts with endpoints related to paystack subaccount resource that lets you create and manage subaccounts on your Integration. Subaccounts can be used to split payment between two accounts (your main account and a subaccount).
func NewSubAccountClient ¶
func NewSubAccountClient(options ...ClientOptions) *SubAccountClient
NewSubAccountClient creates a SubAccountClient
func (*SubAccountClient) All ¶
All lets you retrieve subaccounts available on your Integration
Default response: models.Response[[]models.SubAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.SubAccount]
if err := client.SubAccounts.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.SubAccounts.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/subaccount/
func (*SubAccountClient) Create ¶
func (s *SubAccountClient) Create(ctx context.Context, businessName string, settlementBank string, accountNumber string, percentageCharge float32, description string, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a dedicated virtual account for an existing customer
Default response: models.Response[[]models.SubAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.SubAccount]
if err := client.SubAccounts.Create(context.TODO(), "Sunshine Studios", "044", "0193274682", 18.2,"",&response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.SubAccounts.Create(context.TODO(), "Sunshine Studios", "044", "0193274682", 18.2,"",&response,p.WithOptionalPayload("primary_contact_email","johndoe@example.com"))
}
For supported optional parameters, see: https://paystack.com/docs/api/subaccount/
func (*SubAccountClient) FetchOne ¶
FetchOne lets you retrieve details of a subaccount on your Integration
Default response: models.Response[models.SubAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.SubAccount]
if err := client.SubAccounts.FetchOne(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*SubAccountClient) Update ¶
func (s *SubAccountClient) Update(ctx context.Context, idOrCode string, businessName string, settlementBank string, response any, optionalPayloads ...OptionalPayload) error
Update lets you update a subaccount details on your Integration
Default response: models.Response[models.SubAccount]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Customer]
if err := client.SubAccounts.Update(context.TODO(),"<idOrCode>", "Sunshine Studios", "044", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.SubAccounts.Update(context.TODO(),"<idOrCode>", "Sunshine Studios", "044", &response, p.WithOptionalPayload("primary_contact_email","johndoe@example.com"))
}
For supported optional parameters, see: https://paystack.com/docs/api/subaccount/
type SubscriptionClient ¶
type SubscriptionClient struct {
// contains filtered or unexported fields
}
SubscriptionClient interacts with endpoints related to paystack subscription resource that lets you create and manage recurring payment on your Integration.
func NewSubscriptionClient ¶
func NewSubscriptionClient(options ...ClientOptions) *SubscriptionClient
NewSubscriptionClient create a SubscriptionClient
func (*SubscriptionClient) All ¶
All lets you retrieve Subscriptions available on your Integration
Default response: models.Response[[]models.Subscription]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Subscription]
if err := client.Subscriptions.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Subscriptions.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/subscription/
func (*SubscriptionClient) Create ¶
func (s *SubscriptionClient) Create(ctx context.Context, customer string, plan string, authorization string, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a subscription on your Integration
Default response: models.Response[models.Subscription]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Subscription]
if err := client.Subscriptions.Create(context.TODO(),"CUS_xnxdt6s1zg1f4nx", "PLN_gx2wn530m0i3w3m", "AUTH_xxx", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Subscriptions.Create(context.TODO(),"CUS_xnxdt6s1zg1f4nx", "PLN_gx2wn530m0i3w3m", "AUTH_xxx", &response, p.WithOptionalPayload("start_date","2023-10-16T00:30:13+01:00"))
}
For supported optional parameters, see: https://paystack.com/docs/api/subscription/
func (*SubscriptionClient) Disable ¶
func (s *SubscriptionClient) Disable(ctx context.Context, code string, token string, response any) error
Disable lets you disable a subscription on your Integration
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.Subscriptions.Disable(context.TODO(),"SUB_vsyqdmlzble3uii", "d7gofp6yppn3qz7", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*SubscriptionClient) Enable ¶
func (s *SubscriptionClient) Enable(ctx context.Context, code string, token string, response any) error
Enable lets you enable a subscription on your Integration
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.Subscriptions.Enable(context.TODO(),"SUB_vsyqdmlzble3uii", "d7gofp6yppn3qz7", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*SubscriptionClient) FetchOne ¶
FetchOne lets you retrieve details of a subscription on your Integration
Default response: models.Response[models.Subscription]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Subscription]
if err := client.Subscriptions.FetchOne(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*SubscriptionClient) GenerateLink ¶
GenerateLink lets you generate a link for updating the card on a subscription
Default response: models.Response[models.SubscriptionLink]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.SubscriptionLink]
if err := client.Subscriptions.GenerateLink(context.TODO(),"SUB_vsyqdmlzble3uii", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*SubscriptionClient) SendLink ¶
SendLink lets you email a customer a link for updating the card on their subscription
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.Subscriptions.SendLink(context.TODO(),"SUB_vsyqdmlzble3uii", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type TerminalClient ¶
type TerminalClient struct {
// contains filtered or unexported fields
}
TerminalClient interacts with endpoints related to paystack Terminal resource that allows you to build delightful in-person payment experiences.
func NewTerminalClient ¶
func NewTerminalClient(options ...ClientOptions) *TerminalClient
NewTerminalClient creates a TerminalClient
func (*TerminalClient) All ¶
All lets you retrieve the Terminals available on your Integration
Default response: models.Response[[]models.Terminal]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Terminal]
if err := client.Terminals.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Terminals.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/terminal/
func (*TerminalClient) Commission ¶
Commission lets you activate your debug device by linking it to your Integration
Default response: models.Response[struc{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.Terminals.Commission(context.TODO(),"<serialNumber>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TerminalClient) Decommission ¶
Decommission lets you unlink your debug device from your Integration
Default response: models.Response[struc{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.Terminals.Decommission(context.TODO(),"<serialNumber>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TerminalClient) EventStatus ¶
func (t *TerminalClient) EventStatus(ctx context.Context, terminalId string, eventId string, response any) error
EventStatus lets you check the status of an event sent to the Terminal
Default response: models.Response[models.TerminalEventStatusData]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TerminalEventStatusData]
if err := client.Terminals.EventStatus(context.TODO(),"30","616d721e8c5cd40a0cdd54a6", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TerminalClient) FetchOne ¶
FetchOne lets you get the details of a Terminal
Default response: models.Response[models.Terminal]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Terminal]
if err := client.Terminals.FetchOne(context.TODO(),"<terminalId>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TerminalClient) SendEvent ¶
func (t *TerminalClient) SendEvent(ctx context.Context, terminalId string, eventType enum.TerminalEvent, action enum.TerminalEventAction, data, response any) error
SendEvent lets you send an event from your application to the Paystack Terminal
Default response: models.Response[models.TerminalEventData]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TerminalEventData]
data := map[string]any{"id": 7895939, "reference": 4634337895939}
if err := client.Terminals.SendEvent(context.TODO(),"30",event.TerminalEventInvoice,enum.TerminalEventActionProcess,data, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TerminalClient) TerminalStatus ¶
TerminalStatus lets you check the availability of a Terminal before sending an event to it
Default response: models.Response[models.TerminalStatusData]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TerminalStatusData]
if err := client.Terminals.EventStatus(context.TODO(),"30", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TerminalClient) Update ¶
func (t *TerminalClient) Update(ctx context.Context, terminalId string, name string, address string, response any) error
Update lets you update the details of a Terminal
Default response: models.Response[struc{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.Terminals.Update(context.TODO(),"<terminalId>", "New Terminal","somewhere on earth", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type TransactionClient ¶
type TransactionClient struct {
// contains filtered or unexported fields
}
TransactionClient interacts with endpoints related to paystack Transaction resource that allows you to create and manage payments on your Integration.
func NewTransactionClient ¶
func NewTransactionClient(options ...ClientOptions) *TransactionClient
NewTransactionClient creates a TransactionClient
func (*TransactionClient) All ¶
All lets you list Transactions carried out on your Integration
Default response: models.Response[[]models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Transaction]
if err := client.Transactions.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Transactions.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/transaction/
func (*TransactionClient) ChargeAuthorization ¶
func (t *TransactionClient) ChargeAuthorization(ctx context.Context, amount int, email string, authorizationCode string, response any, optionalPayloads ...OptionalPayload) error
ChargeAuthorization lets you charge authorizations that are marked as reusable
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Transactions.ChargeAuthorization(context.TODO(),200000,"johndoe@example.com","AUTH_xxx", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Transactions.ChargeAuthorization(context.TODO(),200000,"johndoe@example.com","AUTH_xxx", &response, p.WithOptionalPayload("channel","bank"))
}
For supported optional parameters, see: https://paystack.com/docs/api/transaction/
func (*TransactionClient) Export ¶
Export lets you export a list of Transactions carried out on your Integration
Default response: models.Response[[]models.TransactionExport]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.TransactionExport]
if err := client.Transactions.Export(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Transactions.Export(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/transaction/
func (*TransactionClient) FetchOne ¶
FetchOne lets you get the details of a transaction carried out on your Integration
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Transactions.FetchOne(context.TODO(),"<id>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransactionClient) Initialize ¶
func (t *TransactionClient) Initialize(ctx context.Context, amount int, email string, response any, optionalPayloads ...OptionalPayload) error
Initialize lets you initialize a transaction from your backend
Default response: models.Response[models.InitTransaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.InitTransaction]
if err := client.Transactions.Initialize(context.TODO(),200000, "johndoe@example.com", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Transactions.Initialize(context.TODO(),200000, "johndoe@example.com", &response, p.WithOptionalPayload("currency", string(enum.CurrencyNgn)))
}
For supported optional parameters, see: https://paystack.com/docs/api/transaction/
func (*TransactionClient) PartialDebit ¶
func (t *TransactionClient) PartialDebit(ctx context.Context, authorizationCode string, currency enum.Currency, amount string, email string, response any, optionalPayloads ...OptionalPayload) error
PartialDebit lets you retrieve part of a payment from a customer
Default response: models.Response[[]models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Transaction]
if err := client.Transactions.PartialDebit(context.TODO(),"AUTH_xxx",enum.CurrencyNgn,"200000", "johndoe@example.com", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Transactions.PartialDebit(context.TODO(), "AUTH_xxx",enum.CurrencyNgn,"200000", "johndoe@example.com", &response,p.WithOptionalPayload("at_least",100000))
}
For supported query parameters, see: https://paystack.com/docs/api/transaction/
func (*TransactionClient) Timeline ¶
Timeline lets you view the timeline of a transaction
Default response: models.Response[models.TransactionLog]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TransactionLog]
if err := client.Transactions.Timeline(context.TODO(),"<idOrReference>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransactionClient) Total ¶
Total lets you retrieve the total amount received on your account
Default response: models.Response[[]models.TransactionTotal]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.TransactionTotal]
if err := client.Transactions.Total(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Transactions.Total(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/transaction/
func (*TransactionClient) Verify ¶
Verify lets you confirm the status of a transaction
Default response: models.Response[models.Transaction]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transaction]
if err := client.Transactions.Verify(context.TODO(),"<reference>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type TransactionSplitClient ¶
type TransactionSplitClient struct {
// contains filtered or unexported fields
}
TransactionSplitClient interacts with endpoints related to paystack Transaction Split resource that allows you to split the settlement for a transaction across a payout account, and one or more subaccounts.
func NewTransactionSplitClient ¶
func NewTransactionSplitClient(options ...ClientOptions) *TransactionSplitClient
NewTransactionSplitClient creates a TransactionSplitClient
func (*TransactionSplitClient) Add ¶
func (t *TransactionSplitClient) Add(ctx context.Context, id string, subAccount string, share int, response any) error
Add lets you add a Subaccount to a Transaction Split, or update the share of an existing Subaccount in a Transaction Split
Default response: models.Response[models.TransactionSplit]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TransactionSplit]
if err := client.TransactionSplits.Add(context.TODO(),"ACCT_hdl8abxl8drhrl3", 15, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransactionSplitClient) All ¶
All let you list the transaction splits available on your Integration
Default response: models.Response[[]models.TransactionSplit]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.TransactionSplit]
if err := client.TransactionSplits.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.TransfersSplits.All(context.TODO(), &response,p.WithQuery("name","co-founders account"))
}
For supported query parameters, see: https://paystack.com/docs/api/split/
func (*TransactionSplitClient) Create ¶
func (t *TransactionSplitClient) Create(ctx context.Context, name string, transactionSplitType enum.Split, currency enum.Currency, subaccounts, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a split payment on your Integration
Default response: models.Response[models.TransactionSplit]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
subaccounts := []map[string]any{
{"subaccount": "ACCT_z3x6z3nbo14xsil", "share": 20},
{"subaccount": "ACCT_pwwualwty4nhq9d", "share": 80},
}
var response models.Response[models.TransactionSplit]
if err := client.TransactionSplits.Create(context.TODO(),"co-founders account",enum.SplitPercentage,enum.CurrencyNgn,subaccounts, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Customers.Create(context.TODO(),"co-founders account",enum.SplitPercentage,enum.CurrencyNgn,subaccounts, &response, p.WithOptionalPayload("bearer_type","all"))
}
For supported optional parameters, see: https://paystack.com/docs/api/split/
func (*TransactionSplitClient) FetchOne ¶
FetchOne lets you get the details of a split on your Integration
Default response: models.Response[models.TransactionSplit]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TransactionSplit]
if err := client.TransactionSplits.FetchOne(context.TODO(),"<id>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransactionSplitClient) Remove ¶
func (t *TransactionSplitClient) Remove(ctx context.Context, id string, subAccount string, response any) error
Remove lets you remove a subaccount from a transaction split
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.TransactionSplits.Remove(context.TODO(),"143","ACCT_hdl8abxl8drhrl3", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransactionSplitClient) Update ¶
func (t *TransactionSplitClient) Update(ctx context.Context, id string, name string, active bool, response any, optionalPayloads ...OptionalPayload) error
Update lets you update a transaction split details on your Integration
Default response: models.Response[models.TransactionSplit]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TransactionSplit]
if err := client.TransactionSplits.Update(context.TODO(), "143", "co-authors account", true,&response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.TransfersSplits.Update(context.TODO(),"143", "co-authors account", true, &response,p.WithOptionalPayload("bearer_type","all"))
}
For supported optional parameters, see: https://paystack.com/docs/api/split/
type TransferClient ¶
type TransferClient struct {
// contains filtered or unexported fields
}
TransferClient interacts with endpoints related to paystack transfer resource that lets you automate sending money to your Customers.
func NewTransferClient ¶
func NewTransferClient(options ...ClientOptions) *TransferClient
NewTransferClient creates a TransferClient
func (*TransferClient) All ¶
All lets you retrieve all the Transfers made on your Integration.
Default response: models.Response[[]models.Transfer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.Transfer]
if err := client.Transfers.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.Transfers.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/transfer/
func (*TransferClient) BulkInitiate ¶
func (t *TransferClient) BulkInitiate(ctx context.Context, source string, transfers, response any) error
BulkInitiate lets you initiate multiple Transfers in a single request. You need to disable the Transfers OTP requirement to use this endpoint.
Default response: models.Response[[]models.BulkTransferItem]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
transfers := []map[string]any{
{"amount": 20000,"reference": "588YtfftReF355894J","reason": "Why not?","recipient":"RCP_2tn9clt23s7qr28"},
{"amount": 30000,"reference": "YunoTReF35e0r4J","reason": "Because I can","recipient":"RCP_1a25w1h3n0xctjg"},
{"amount": 40000,"reason": "Coming right up","recipient": "RCP_aps2aibr69caua7"},
}
var response models.Response[[]models.BulkTransferItem]
if err := client.Transfers.BulkInitiate(context.TODO(),"balance",transfers, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferClient) FetchOne ¶
FetchOne lets you retrieve the details of a transfer on your Integration.
Default response: models.Response[models.Transfer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transfer]
if err := client.Transfers.FetchOne(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferClient) Finalize ¶
func (t *TransferClient) Finalize(ctx context.Context, transferCode string, otp string, response any) error
Finalize lets you finalize an initiated transfer
Default response: models.Response[models.Transfer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transfer]
if err := client.Transfers.Finalize(context.TODO(),"TRF_vsyqdmlzble3uii","928783", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferClient) Initiate ¶
func (t *TransferClient) Initiate(ctx context.Context, source string, amount int, recipient string, response any, optionalPayloads ...OptionalPayload) error
Initiate lets you send money to your Customers. Status of a transfer object returned will be pending if OTP is disabled. In the event that an OTP is required, status will read otp.
Default response: models.Response[models.Transfer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transfer]
if err := client.Transfers.Initiate(context.TODO(),"balance",500000,"RCP_gx2wn530m0i3w3m", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Transfers.Initiate(context.TODO(),"balance",500000,"RCP_gx2wn530m0i3w3m", &response, p.WithOptionalPayload("reason","Discount Refund"))
}
For supported optional parameters, see: https://paystack.com/docs/api/transfer/
func (*TransferClient) Verify ¶
Verify lets you verify the status of a transfer on your Integration.
Default response: models.Response[models.Transfer]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.Transfer]
if err := client.Transfers.Verify(context.TODO(),"<reference>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type TransferControlClient ¶
type TransferControlClient struct {
// contains filtered or unexported fields
}
TransferControlClient interacts with endpoints related to paystack transfer control resource that lets you manage settings of your Transfers.
func NewTransferControlClient ¶
func NewTransferControlClient(options ...ClientOptions) *TransferControlClient
NewTransferControlClient creates a TransferControlClient
func (*TransferControlClient) Balance ¶
func (t *TransferControlClient) Balance(ctx context.Context, response any) error
Balance lets you retrieve the available balance on your Integration
Default response: models.Response[[]models.IntegrationBalance]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.IntegrationBalance]
if err := client.TransferControl.Balance(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferControlClient) BalanceLedger ¶
func (t *TransferControlClient) BalanceLedger(ctx context.Context, response any) error
BalanceLedger lets you retrieve all pay-ins and pay-outs that occurred on your Integration
Default response: models.Response[[]models.BalanceLedgerItem]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.BalanceLedgerItem]
if err := client.TransferControl.BalanceLedger(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferControlClient) DisableOtp ¶ added in v0.2.0
func (t *TransferControlClient) DisableOtp(ctx context.Context, response any) error
DisableOtp lets you complete Transfers without use of OTPs. You will get an OTP to complete the request.
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.TransferControl.DisableOtp(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferControlClient) EnableOtp ¶ added in v0.2.0
func (t *TransferControlClient) EnableOtp(ctx context.Context, response any) error
EnableOtp lets you turn OTP requirement back on.
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.TransferControl.EnableOtp(context.TODO(),"<otp>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferControlClient) FinalizeDisableOtp ¶ added in v0.2.0
func (t *TransferControlClient) FinalizeDisableOtp(ctx context.Context, otp string, response any) error
FinalizeDisableOtp lets you finalize the request to disable OTP on your Transfers.
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.TransferControl.FinalizeDisableOtp(context.TODO(),"<otp>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferControlClient) ResendOtp ¶ added in v0.2.0
func (t *TransferControlClient) ResendOtp(ctx context.Context, transferCode string, reason enum.Reason, response any) error
ResendOtp lets you generate a new OTP and sends to customer in the event they are having trouble receiving one.
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.TransferControl.ResendOtp(context.TODO(),"TRF_vsyqdmlzble3uii",enum.ReasonResendOtp, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
type TransferRecipientClient ¶
type TransferRecipientClient struct {
// contains filtered or unexported fields
}
TransferRecipientClient interacts with endpoints related to paystack transfer recipient resource that lets you create and manage beneficiaries that you send money to.
func NewTransferRecipientClient ¶
func NewTransferRecipientClient(options ...ClientOptions) *TransferRecipientClient
NewTransferRecipientClient creates a TransferRecipientClient
func (*TransferRecipientClient) All ¶
All lets you retrieve transfer recipients available on your Integration
Default response: models.Response[[]models.TransferRecipient]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[[]models.TransferRecipient]
if err := client.TranferRecipients.All(context.TODO(), &response); err != nil {
panic(err)
}
fmt.Println(response)
// With query parameters
// err := client.TransferRecipients.All(context.TODO(), &response,p.WithQuery("perPage","50"), p.WithQuery("page","2"))
}
For supported query parameters, see: https://paystack.com/docs/api/transfer-recipient/
func (*TransferRecipientClient) BulkCreate ¶
func (t *TransferRecipientClient) BulkCreate(ctx context.Context, batch, response any) error
BulkCreate lets you create multiple transfer recipients in batches. A duplicate account number will lead to the retrieval of the existing record.
Default response: models.Response[models.TransferRecipientBulkCreateData]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
batch := []map[string]any{
{"type":"nuban", "name" : "Habenero Mundane", "account_number": "0123456789","bank_code":"033","currency": "NGN"},
{"type":"nuban","name" : "Soft Merry","account_number": "98765432310","bank_code": "50211","currency": "NGN"},
}
var response models.Response[models.TransferRecipientBulkCreateData]
if err := client.TransferRecipients.BulkCreate(context.TODO(),batch, &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferRecipientClient) Create ¶
func (t *TransferRecipientClient) Create(ctx context.Context, recipientType enum.RecipientType, name string, accountNumber string, bankCode string, response any, optionalPayloads ...OptionalPayload) error
Create lets you create a new recipient. A duplicate account number will lead to the retrieval of the existing record.
Default response: models.Response[models.TransferRecipient]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TransferRecipient]
if err := client.TransferRecipients.Create(context.TODO(),enum.RecipientTypeNuban,"Tolu Robert","01000000010", "058", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.TransferRecipients.Create(context.TODO(),enum.RecipientTypeNuban,"Tolu Robert","01000000010", "058", &response, p.WithOptionalPayload("currency","NGN"))
}
For supported optional parameters, see: https://paystack.com/docs/api/transfer-recipient/
func (*TransferRecipientClient) Delete ¶
Delete lets you delete a transfer recipient (sets the transfer recipient to inactive)
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.TransferRecipients.Delete(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferRecipientClient) FetchOne ¶
func (t *TransferRecipientClient) FetchOne(ctx context.Context, idOrCode string, response any) error
FetchOne lets you retrieve the details of a transfer recipient
Default response: models.Response[models.TranferRecipient]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.TransferRecipient]
if err := client.TransferRecipients.FetchOne(context.TODO(),"<idOrCode>", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*TransferRecipientClient) Update ¶
func (t *TransferRecipientClient) Update(ctx context.Context, idOrCode string, name string, response any, optionalPayloads ...OptionalPayload) error
Update lets you update transfer recipients available on your Integration
Default response: models.Response[struct{}]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
"github.com/gray-adeyi/paystack/enum"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[struct{}]
if err := client.TransferRecipients.Update(context.TODO(),"<idOrCode>", "Rick Sanchez", &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.TransferRecipients.Update(context.TODO(),"<idOrCode>", "Rick Sanchez", &response, p.WithOptionalPayload("email","johndoe@example.com"))
}
For supported optional parameters, see: https://paystack.com/docs/api/transfer-recipient/
type VerificationClient ¶
type VerificationClient struct {
// contains filtered or unexported fields
}
VerificationClient interacts with endpoints related to paystack Verification resource that allows you to perform KYC processes.
func NewVerificationClient ¶
func NewVerificationClient(options ...ClientOptions) *VerificationClient
NewVerificationClient creates a VerificationClient
Example
import p "github.com/gray-adeyi/paystack"
vClient := p.NewVerificationClient(p.WithSecretKey("<paystack-secret-key>"))
func (*VerificationClient) ResolveAccount ¶
func (v *VerificationClient) ResolveAccount(ctx context.Context, response any, queries ...Query) error
ResolveAccount lets you confirm an account belongs to the right customer
Default response: models.Response[models.BankAccountInfo]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.BankAccountInfo]
if err := client.Verification.ResolveAccount(context.TODO(), &response,p.WithQuery("account_number","0022728151"),p.WithQuery("bank_code","063")); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*VerificationClient) ResolveBin ¶ added in v0.2.0
ResolveBin lets you retrieve more information about a customer's card
Default response: models.Response[models.CardBin]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.CardBin]
if err := client.Verification.ResolveBin(context.TODO(),"539983", &response); err != nil {
panic(err)
}
fmt.Println(response)
}
func (*VerificationClient) ValidateAccount ¶
func (v *VerificationClient) ValidateAccount(ctx context.Context, accountName string, accountNumber string, accountType enum.AccountType, bankCode string, countryCode enum.Country, documentType enum.Document, response any, optionalPayloads ...OptionalPayload) error
ValidateAccount lets you confirm the authenticity of a customer's account number before sending money
Default response: models.Response[models.AccountVerificationInfo]
Example:
import (
"context"
"fmt"
p "github.com/gray-adeyi/paystack"
"github.com/gray-adeyi/paystack/models"
)
func main() {
client := p.NewClient(p.WithSecretKey("<paystack-secret-key>"))
var response models.Response[models.AccountVerificationInfo]
if err := client.Verification.ValidateAccount(context.TODO(),"Ann Bron","0123456789",enum.AccountTypePersonal,"632005",enum.CountrySouthAfrica,enum.DocumentIdentityNumber, &response); err != nil {
panic(err)
}
fmt.Println(response)
// With optional parameters
// err := client.Verification.ValidateAccount(context.TODO(),"Ann Bron","0123456789",enum.AccountTypePersonal,"632005",enum.CountrySouthAfrica,enum.DocumentIdentityNumber, &response, p.WithOptionalPayload("document_number","1234567890123"))
}
For supported optional parameters, see: https://paystack.com/docs/api/verification/
Source Files
¶
- api_client.go
- apple_pay_client.go
- bulk_charges_client.go
- charge_client.go
- customer_client.go
- dedicated_virtual_account_client.go
- dispute_client.go
- doc.go
- integration_client.go
- miscellaneous_client.go
- optional_payloads.go
- payment_pages_client.go
- payment_request_client.go
- plan_client.go
- product_client.go
- queries.go
- refund_client.go
- rest_client.go
- settlement_client.go
- sub_account_client.go
- subscription_client.go
- terminal_client.go
- transaction_client.go
- transaction_split_client.go
- transfer_client.go
- transfer_control_client.go
- transfer_recipient.go
- verification_client.go