Documentation
¶
Overview ¶
Package paystacksdkgo provides a comprehensive and robust Go client for the Paystack API.
This SDK covers all major Paystack services including Transactions, Customers, Plans, Subscriptions, Transfers, and more. It is designed to be idiomatic, context-aware, and easy to use.
Initialization ¶
import (
"os"
paystack "github.com/samaasi/paystack-sdk-go/v2"
)
func main() {
apiKey := os.Getenv("PAYSTACK_SECRET_KEY")
client := paystack.NewClient(apiKey)
// Use client to interact with Paystack API...
}
Services ¶
The client provides access to various services via fields:
client.Transactions.Initialize(...) client.Customers.Create(...)
See individual service documentation for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Transaction service for handling transaction-related operations
Transactions transactions.Service
// Transfer service for handling transfer-related operations
Transfers transfers.Service
// ApplePay service for handling Apple Pay-related operations
ApplePay applepay.Service
// BulkCharges service for handling bulk charge operations
BulkCharges bulkcharges.Service
// Charges service for handling charge operations
Charges charges.Service
// PaymentPages service for handling payment page operations
PaymentPages paymentPages.Service
// PaymentRequests service for handling payment request operations
PaymentRequests paymentRequests.Service
// Customers service for handling customer operations
Customers customers.Service
// Disputes service for handling dispute operations
Disputes disputes.Service
// Integration service for handling integration operations
Integration integration.Service
// Plans service for handling plans
Plans plans.Service
// Products service for handling products
Products products.Service
// Refunds service for handling refunds
Refunds refunds.Service
// Settlements service for handling settlements
Settlements settlements.Service
// Splits service for handling splits
Splits splits.Service
// Status service for handling status
Status status.Service
// Subaccounts service for handling subaccounts
Subaccounts subaccounts.Service
// Subscriptions service for handling subscriptions
Subscriptions subscriptions.Service
// Terminal service for handling terminal
Terminal terminal.Service
// Verification service for handling verification
Verification verification.Service
// VirtualAccounts service for handling virtual accounts
VirtualAccounts virtualAccounts.Service
// TransferControl service for handling transfer control
TransferControl transferControl.Service
// TransferRecipients service for handling transfer recipients
TransferRecipients transferRecipients.Service
// Misc service for handling miscellaneous operations
Misc misc.Service
// contains filtered or unexported fields
}
Client is the main entry point for the Paystack SDK.
func NewClient ¶
func NewClient(secretKey string, opts ...ClientOption) *Client
NewClient creates a new Paystack client with the given secret key. You can pass the secret key from your environment variables or any other source.
Example:
client := paystack.NewClient(os.Getenv("PAYSTACK_SECRET_KEY"))
type ClientOption ¶
type ClientOption = backend.ClientOption
ClientOption is a function that configures the Client.
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL allows you to override the default Paystack API base URL.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ClientOption
WithHTTPClient allows you to provide a custom HTTP client. This is useful for testing or if you need to configure proxies, timeouts, etc.
func WithMaxRetries ¶
func WithMaxRetries(retries int) ClientOption
WithMaxRetries sets the maximum number of retries for failed requests. Default is 3. Set to 0 to disable retries.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets the timeout for HTTP requests. Default is 30 seconds.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
charge_returning_customer
command
Example: charge a returning customer using a saved authorization code.
|
Example: charge a returning customer using a saved authorization code. |
|
initialize_transaction
command
Example: initialize a transaction and redirect the user to the checkout URL.
|
Example: initialize a transaction and redirect the user to the checkout URL. |
|
pagination
command
Example: iterate over all transactions using the built-in Iterator.
|
Example: iterate over all transactions using the built-in Iterator. |
|
verify_webhook
command
Example: verify an incoming Paystack webhook and dispatch on event type.
|
Example: verify an incoming Paystack webhook and dispatch on event type. |
|
internal
|
|
|
service
|
|
|
apple-pay
Package applepay provides methods for interacting with the Paystack API for apple-pay.
|
Package applepay provides methods for interacting with the Paystack API for apple-pay. |
|
bulk-charges
Package bulkcharges provides methods for interacting with the Paystack API for bulk-charges.
|
Package bulkcharges provides methods for interacting with the Paystack API for bulk-charges. |
|
charges
Package charges provides methods for interacting with the Paystack API for charges.
|
Package charges provides methods for interacting with the Paystack API for charges. |
|
customers
Package customers provides methods for interacting with the Paystack API for customers.
|
Package customers provides methods for interacting with the Paystack API for customers. |
|
disputes
Package disputes provides methods for interacting with the Paystack API for disputes.
|
Package disputes provides methods for interacting with the Paystack API for disputes. |
|
integration
Package integration provides methods for interacting with the Paystack API for integration.
|
Package integration provides methods for interacting with the Paystack API for integration. |
|
misc
Package misc provides methods for interacting with the Paystack API for misc.
|
Package misc provides methods for interacting with the Paystack API for misc. |
|
payment-pages
Package paymentpages provides methods for interacting with the Paystack API for payment-pages.
|
Package paymentpages provides methods for interacting with the Paystack API for payment-pages. |
|
payment-requests
Package paymentrequests provides methods for interacting with the Paystack API for payment-requests.
|
Package paymentrequests provides methods for interacting with the Paystack API for payment-requests. |
|
plans
Package plans provides methods for interacting with the Paystack API for plans.
|
Package plans provides methods for interacting with the Paystack API for plans. |
|
products
Package products provides methods for interacting with the Paystack API for products.
|
Package products provides methods for interacting with the Paystack API for products. |
|
refunds
Package refunds provides methods for interacting with the Paystack API for refunds.
|
Package refunds provides methods for interacting with the Paystack API for refunds. |
|
settlements
Package settlements provides methods for interacting with the Paystack API for settlements.
|
Package settlements provides methods for interacting with the Paystack API for settlements. |
|
splits
Package splits provides methods for interacting with the Paystack API for splits.
|
Package splits provides methods for interacting with the Paystack API for splits. |
|
status
Package status provides methods for interacting with the Paystack API for status.
|
Package status provides methods for interacting with the Paystack API for status. |
|
subaccounts
Package subaccounts provides methods for interacting with the Paystack API for subaccounts.
|
Package subaccounts provides methods for interacting with the Paystack API for subaccounts. |
|
subscriptions
Package subscriptions provides methods for interacting with the Paystack API for subscriptions.
|
Package subscriptions provides methods for interacting with the Paystack API for subscriptions. |
|
terminal
Package terminal provides methods for interacting with the Paystack API for terminal.
|
Package terminal provides methods for interacting with the Paystack API for terminal. |
|
transactions
Package transactions provides methods for interacting with the Paystack API for transactions.
|
Package transactions provides methods for interacting with the Paystack API for transactions. |
|
transfer-control
Package transferControl provides methods for interacting with the Paystack API for transfer-control.
|
Package transferControl provides methods for interacting with the Paystack API for transfer-control. |
|
transfer-recipients
Package transferRecipients provides methods for interacting with the Paystack API for transfer-recipients.
|
Package transferRecipients provides methods for interacting with the Paystack API for transfer-recipients. |
|
transfers
Package transfers provides methods for interacting with the Paystack API for transfers.
|
Package transfers provides methods for interacting with the Paystack API for transfers. |
|
verification
Package verification provides methods for interacting with the Paystack API for verification.
|
Package verification provides methods for interacting with the Paystack API for verification. |
|
virtual-accounts
Package virtualAccounts provides methods for interacting with the Paystack API for virtual-accounts.
|
Package virtualAccounts provides methods for interacting with the Paystack API for virtual-accounts. |