shopier

package module
v0.0.0-...-30502bc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Shopier Go SDK

Go Reference Go Version

Production-ready, zero-dependency Go SDK and API wrapper for the Shopier REST API. Built for high-concurrency microservices, e-commerce backends, and multi-tenant applications.


Features

  • Zero External Dependencies: Built entirely with Go standard library packages (net/http, crypto/hmac, log/slog, context, iter, time). Zero third-party vulnerability risk and fast compile times.
  • Full API Coverage: Complete type safety and models across all 12 Shopier REST API resources.
  • Modern Go Iterators: Native Go 1.23+ Range-over-func iterators (client.Orders.All, client.Products.All) alongside header-based pagination metadata (Shopier-Pagination-*).
  • Resilient Transport: Automatic exponential backoff with jitter on 5xx errors and automatic delay adherence on 429 Too Many Requests using the Retry-After header.
  • OAuth 2.0 Ready: Built-in support for authorization code exchange, token refresh, and token revocation managing Shopier's port :8443 requirements.
  • Webhook Verification: Constant-time HS256 (HMAC-SHA256) signature verification with standard http.Handler and multi-framework adapters (Gin, Chi, Fiber).
  • Testing Utilities: Built-in testutil.NewMockServer() for mocking Shopier API interactions in your own unit test suites.

Installation

go get github.com/AdisGroup/shopier-go

Quickstart

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/AdisGroup/shopier-go"
)

func main() {
	client, err := shopier.NewClient(os.Getenv("SHOPIER_TOKEN"))
	if err != nil {
		log.Fatalf("Client init failed: %v", err)
	}

	ctx := context.Background()

	// 1. Check account balances
	balances, err := client.Balance.Get(ctx)
	if err != nil {
		log.Fatalf("Balance inquiry failed: %v", err)
	}
	for _, b := range balances {
		fmt.Printf("Balance: %s %s\n", b.Amount, b.Currency)
	}

	// 2. Stream all unfulfilled orders with automatic pagination
	opts := &shopier.OrderListOptions{
		FulfillmentStatus: "unfulfilled",
	}

	for order, err := range client.Orders.All(ctx, opts) {
		if err != nil {
			log.Fatalf("Order stream error: %v", err)
		}
		fmt.Printf("Order #%s: %s %s (Buyer: %s %s)\n",
			order.ID, order.Totals.Total, order.Currency,
			order.ShippingInfo.FirstName, order.ShippingInfo.LastName)
	}
}

API Services Overview

Resource Service Client Field Key Methods
Orders client.Orders List, All, Get, Update, GetTransaction
Products client.Products List, All, Get, Create, Update, Delete
Categories client.Categories List, All, Get, Create, Update, Delete
Variations client.Variations List, All, Get, Create, Update, Delete
Selections client.Selections List, All, Get, Create, Update, Delete
Discounts client.Discounts ListCodes, CreateCode, ListAutomatic, CreateAutomatic
Shippings client.Shippings List, All, Get, Create, Delete
Balance client.Balance Get, ListTransactions, AllTransactions, GetTransaction
Payouts client.Payouts List, All, Get, ListTransactions, AllTransactions
Refunds client.Refunds List, All, Get, Create
Shop client.Shop GetOwner, GetSettings, UpdateSettings
Webhooks client.Webhooks List, Create, Delete
QuickCheckout client.QuickCheckout Create (Generates direct payment link)

Generate direct customer payment links (https://www.shopier.com/s/payment/{account}/{order_id}) by processing the checkout flow without needing an API token:

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/AdisGroup/shopier-go"
)

func main() {
	qc := shopier.NewQuickCheckoutService()

	result, err := qc.Create(context.Background(), &shopier.QuickCheckoutRequest{
		ProductURL: "https://www.shopier.com/adisgroup/50900391",
		Quantity:   1,
		Buyer: shopier.QuickCheckoutBuyer{
			Email:     "buyer@example.com",
			FirstName: "Ahmet",
			LastName:  "Yılmaz",
			Phone:     "+90 532 111 22 33",
			Country:   "Türkiye",
			City:      "İstanbul",
		},
	})
	if err != nil {
		log.Fatalf("Quick checkout failed: %v", err)
	}

	fmt.Printf("Direct Payment URL: %s\n", result.PaymentURL)
}

Webhook Signature Verification

Shopier signs event payloads with HS256 (HMAC-SHA256) via the Shopier-Signature header:

package main

import (
	"context"
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/AdisGroup/shopier-go/webhook"
)

func main() {
	secret := os.Getenv("SHOPIER_WEBHOOK_SECRET")

	handler := webhook.NewHandler(secret, func(ctx context.Context, evt *webhook.Event) error {
		log.Printf("Received Event: %s (ID: %s)", evt.Header.Event, evt.Header.WebhookID)

		switch evt.Header.Event {
		case webhook.EventOrderCreated:
			order, err := evt.Order()
			if err != nil {
				return err
			}
			fmt.Printf("New Order Placed: #%s for %s %s\n", order.ID, order.Totals.Total, order.Currency)

		case webhook.EventRefundRequested:
			refund, err := evt.Refund()
			if err != nil {
				return err
			}
			fmt.Printf("Refund Requested: #%s (Order: %s)\n", refund.ID, refund.OrderID)
		}

		return nil
	})

	http.Handle("/webhooks/shopier", handler)
	log.Fatal(http.ListenAndServe(":8080", nil))
}

OAuth 2.0 Web Application Flow

import "github.com/AdisGroup/shopier-go/oauth"

cfg := oauth.NewConfig(clientID, clientSecret, "https://yourapp.com/callback")

// 1. Generate authorization consent URL
consentURL := cfg.AuthCodeURL("state_nonce", oauth.ScopeOrdersRead, oauth.ScopeProductsWrite)

// 2. Exchange authorization code in callback handler
token, err := cfg.Exchange(ctx, authCode)

// 3. Refresh expired token
newToken, err := cfg.RefreshToken(ctx, token.RefreshToken)

// 4. Revoke access
err := cfg.Revoke(ctx, token.AccessToken)

Examples

Runnable example code is located in the examples/ directory:


Documentation & API Coverage Checklist

Every endpoint, resource model, webhook event, and authentication method specified in the official Shopier API documentation (ignore/shopier_docs) is fully implemented, verified, and tested in this SDK:

1. Guides & Onboarding (00_guides/)
  • 00_guides/01_introduction/01_overview.md — SDK Architecture & Base Client (shopier.go)
  • 00_guides/02_onboarding_checklist/01_sign-up-for-shopier-account.md — Account setup reference (docs/)
  • 00_guides/02_onboarding_checklist/02_enable-developer-mode.md — Developer mode configuration (docs/)
  • 00_guides/02_onboarding_checklist/03_create-your-app.md — OAuth application configuration (oauth/oauth.go)
  • 00_guides/02_onboarding_checklist/04_get-your-app-credentials.md — Client ID & Secret credentials handling (oauth/oauth.go)
  • 00_guides/02_onboarding_checklist/05_request-authorization-from-sellers.md — Consent URL generator with scopes (oauth/oauth.go)
  • 00_guides/02_onboarding_checklist/06_bonus-shortcut-to-start-playing-with-the-api.md — Personal Access Token (PAT) quickstart (examples/01_quickstart/main.go)
  • 00_guides/03_authentication/01_pats-and-apps.md — PAT and OAuth 2.0 dual authentication support (shopier.go, oauth/oauth.go)
  • 00_guides/03_authentication/02_creating-and-using-pats.md — HTTP Bearer Token authentication header injection (shopier.go)
  • 00_guides/03_authentication/03_oauth-20-flow.md — OAuth 2.0 Web Application Flow implementation (oauth/oauth.go)
  • 00_guides/03_authentication/04_oauth-20-flow.md — Authorization code exchange & token lifecycle (oauth/oauth.go)
  • 00_guides/03_authentication/05_oauth-20-implementation.md — Dedicated OAuth Token & Revoke endpoints on Port :8443 (oauth/oauth.go)
  • 00_guides/03_authentication/06_permission-scopes.md — Complete typed OAuth permission scopes (oauth/scopes.go)
  • 00_guides/04_app_review/01_introduction-to-app-reviews.md — App submission & production readiness guidelines (docs/)
  • 00_guides/04_app_review/02_submitting-your-app-for-review.md — Review process documentation (docs/)
  • 00_guides/04_app_review/03_publishing-your-app.md — App store publishing guidelines (docs/)
2. Shopier REST API Architecture (01_shopier_rest_api/)
  • 01_shopier_rest_api/01_introduction.md — Standard HTTP transport & Client constructor (shopier.go)
  • 01_shopier_rest_api/02_response-codes.md — Structured error decoding with APIError and status handlers (errors.go)
  • 01_shopier_rest_api/03_pagination.md — Header-based pagination parser (Shopier-Pagination-*) & PageResponse[T] (pagination.go)
  • 01_shopier_rest_api/04_sorting.md — URL query parameter sorting & ordering helpers (options.go)
  • 01_shopier_rest_api/05_versioning.md — API v1 endpoint versioning support (shopier.go)
  • 01_shopier_rest_api/06_rate-limits.md — Sliding window rate limiter tracking & Retry-After retry backoff (shopier.go, errors.go)
  • 01_shopier_rest_api/07_webhooks.md — HS256 HMAC-SHA256 signature verification & payload parsing (webhook/verify.go, webhook/events.go)
3. API Endpoints (02_api_endpoints/)
  • Balance Service
    • 02_api_endpoints/01_balance/01_balance.md — Balance service initialization (balance.go)
    • 02_api_endpoints/01_balance/02_the-balance-model.md — Balance struct model (balance.go)
    • 02_api_endpoints/01_balance/03_get-balance.md — client.Balance.Get(ctx) (balance.go)
    • 02_api_endpoints/01_balance/04_the-transaction-model.md — Transaction struct model (balance.go)
    • 02_api_endpoints/01_balance/05_get-balance-transactions.md — client.Balance.ListTransactions(ctx, opts) & AllTransactions iterator (balance.go)
    • 02_api_endpoints/01_balance/06_get-balance-transactions-orderid.md — client.Balance.GetTransaction(ctx, orderID) (balance.go)
  • Categories Service
    • 02_api_endpoints/02_categories/01_categories.md — Category service initialization (categories.go)
    • 02_api_endpoints/02_categories/02_the-category-model.md — Category struct model (categories.go)
    • 02_api_endpoints/02_categories/03_get-categories.md — client.Categories.List(ctx, opts) & All iterator (categories.go)
    • 02_api_endpoints/02_categories/04_post-categories.md — client.Categories.Create(ctx, req) (categories.go)
    • 02_api_endpoints/02_categories/05_get-categories-id.md — client.Categories.Get(ctx, categoryID) (categories.go)
    • 02_api_endpoints/02_categories/06_delete-categories-id.md — client.Categories.Delete(ctx, categoryID) (categories.go)
    • 02_api_endpoints/02_categories/07_put-categories-id.md — client.Categories.Update(ctx, categoryID, req) (categories.go)
  • Discounts Service
    • 02_api_endpoints/03_discounts/01_discounts.md — Discount service initialization (discounts.go)
    • 02_api_endpoints/03_discounts/02_the-discountcode-model.md — DiscountCode struct model (discounts.go)
    • 02_api_endpoints/03_discounts/03_get-discounts-codes.md — client.Discounts.ListCodes(ctx, opts) & AllCodes iterator (discounts.go)
    • 02_api_endpoints/03_discounts/04_post-discounts-codes.md — client.Discounts.CreateCode(ctx, req) (discounts.go)
    • 02_api_endpoints/03_discounts/05_get-discounts-codes-id.md — client.Discounts.GetCode(ctx, codeID) (discounts.go)
    • 02_api_endpoints/03_discounts/06_delete-discounts-codes-id.md — client.Discounts.DeleteCode(ctx, codeID) (discounts.go)
    • 02_api_endpoints/03_discounts/07_put-discounts-codes-id.md — client.Discounts.UpdateCode(ctx, codeID, req) (discounts.go)
    • 02_api_endpoints/03_discounts/08_the-automaticdiscount-model.md — AutomaticDiscount struct model (discounts.go)
    • 02_api_endpoints/03_discounts/09_get-discounts-automatic.md — client.Discounts.ListAutomatic(ctx, opts) & AllAutomatic iterator (discounts.go)
    • 02_api_endpoints/03_discounts/10_post-discounts-automatic.md — client.Discounts.CreateAutomatic(ctx, req) (discounts.go)
    • 02_api_endpoints/03_discounts/11_get-discounts-automatic-id.md — client.Discounts.GetAutomatic(ctx, discountID) (discounts.go)
    • 02_api_endpoints/03_discounts/12_put-discounts-automatic-id.md — client.Discounts.UpdateAutomatic(ctx, discountID, req) (discounts.go)
    • 02_api_endpoints/03_discounts/13_delete-discounts-automatic-id.md — client.Discounts.DeleteAutomatic(ctx, discountID) (discounts.go)
  • Orders Service
    • 02_api_endpoints/04_orders/01_orders.md — Order service initialization (orders.go)
    • 02_api_endpoints/04_orders/02_the-order-model.md — Order, BillingInfo, ShippingInfo, Totals models (orders.go)
    • 02_api_endpoints/04_orders/03_get-orders.md — client.Orders.List(ctx, opts) & All iterator (orders.go)
    • 02_api_endpoints/04_orders/04_get-orders-id.md — client.Orders.Get(ctx, orderID) (orders.go)
    • 02_api_endpoints/04_orders/05_put-orders-id.md — client.Orders.Update(ctx, orderID, req) (orders.go)
    • 02_api_endpoints/04_orders/06_the-transaction-model-3.md — OrderTransaction struct model (orders.go)
    • 02_api_endpoints/04_orders/07_get-orders-transactions-orderid.md — client.Orders.GetTransaction(ctx, orderID) (orders.go)
  • Payouts Service
    • 02_api_endpoints/05_payouts/01_payouts.md — Payout service initialization (payouts.go)
    • 02_api_endpoints/05_payouts/02_the-payout-model.md — Payout struct model (payouts.go)
    • 02_api_endpoints/05_payouts/03_get-payouts.md — client.Payouts.List(ctx, opts) & All iterator (payouts.go)
    • 02_api_endpoints/05_payouts/04_get-payouts-id.md — client.Payouts.Get(ctx, payoutID) (payouts.go)
    • 02_api_endpoints/05_payouts/05_the-transaction-model-2.md — PayoutTransaction struct model (payouts.go)
    • 02_api_endpoints/05_payouts/06_get-payouts-transactions-id.md — client.Payouts.ListTransactions(ctx, payoutID, opts) & AllTransactions iterator (payouts.go)
  • Products Service
    • 02_api_endpoints/06_products/01_products.md — Product service initialization (products.go)
    • 02_api_endpoints/06_products/02_the-product-model.md — Product, ProductMedia struct models (products.go)
    • 02_api_endpoints/06_products/03_get-products.md — client.Products.List(ctx, opts) & All iterator (products.go)
    • 02_api_endpoints/06_products/04_post-products.md — client.Products.Create(ctx, req) (products.go)
    • 02_api_endpoints/06_products/05_get-products-id.md — client.Products.Get(ctx, productID) (products.go)
    • 02_api_endpoints/06_products/06_delete-products-id.md — client.Products.Delete(ctx, productID) (products.go)
    • 02_api_endpoints/06_products/07_put-products-id.md — client.Products.Update(ctx, productID, req) (products.go)
  • Refunds Service
    • 02_api_endpoints/07_refunds/01_refunds.md — Refund service initialization (refunds.go)
    • 02_api_endpoints/07_refunds/02_the-refund-model.md — Refund struct model (refunds.go)
    • 02_api_endpoints/07_refunds/03_get-refunds.md — client.Refunds.List(ctx, opts) & All iterator (refunds.go)
    • 02_api_endpoints/07_refunds/04_post-refunds.md — client.Refunds.Create(ctx, req) (refunds.go)
    • 02_api_endpoints/07_refunds/05_get-refunds-id.md — client.Refunds.Get(ctx, refundID) (refunds.go)
  • Selections Service
    • 02_api_endpoints/08_selections/01_selections.md — Selection service initialization (selections.go)
    • 02_api_endpoints/08_selections/02_the-selection-model.md — Selection, SelectionOption struct models (selections.go)
    • 02_api_endpoints/08_selections/03_get-selections.md — client.Selections.List(ctx, opts) & All iterator (selections.go)
    • 02_api_endpoints/08_selections/04_post-selections.md — client.Selections.Create(ctx, req) (selections.go)
    • 02_api_endpoints/08_selections/05_get-selections-id.md — client.Selections.Get(ctx, selectionID) (selections.go)
    • 02_api_endpoints/08_selections/06_put-selections-id.md — client.Selections.Update(ctx, selectionID, req) (selections.go)
    • 02_api_endpoints/08_selections/07_delete-selections-id.md — client.Selections.Delete(ctx, selectionID) (selections.go)
  • Shippings Service
    • 02_api_endpoints/09_shippings/01_shippings.md — Shipping service initialization (shippings.go)
    • 02_api_endpoints/09_shippings/02_the-shipping-model.md — Shipping, ShippingCountry struct models (shippings.go)
    • 02_api_endpoints/09_shippings/03_get-shippings.md — client.Shippings.List(ctx, opts) & All iterator (shippings.go)
    • 02_api_endpoints/09_shippings/04_post-shippings.md — client.Shippings.Create(ctx, req) (shippings.go)
    • 02_api_endpoints/09_shippings/05_get-shippings-code.md — client.Shippings.Get(ctx, shippingCode) (shippings.go)
    • 02_api_endpoints/09_shippings/06_delete-shippings-code.md — client.Shippings.Delete(ctx, shippingCode) (shippings.go)
  • Shop Service
    • 02_api_endpoints/10_shop/01_shop.md — Shop service initialization (shop.go)
    • 02_api_endpoints/10_shop/02_the-shopowner-model.md — ShopOwner struct model (shop.go)
    • 02_api_endpoints/10_shop/03_get-shop-owner.md — client.Shop.GetOwner(ctx) (shop.go)
    • 02_api_endpoints/10_shop/04_the-shopsetting-model.md — ShopSetting struct model (shop.go)
    • 02_api_endpoints/10_shop/05_get-shop-settings.md — client.Shop.GetSettings(ctx) (shop.go)
    • 02_api_endpoints/10_shop/06_put-shop-settings.md — client.Shop.UpdateSettings(ctx, req) (shop.go)
  • Variations Service
    • 02_api_endpoints/11_variations/01_variations.md — Variation service initialization (variations.go)
    • 02_api_endpoints/11_variations/02_the-variation-model.md — Variation, VariationOption struct models (variations.go)
    • 02_api_endpoints/11_variations/03_get-variations.md — client.Variations.List(ctx, opts) & All iterator (variations.go)
    • 02_api_endpoints/11_variations/04_post-variations.md — client.Variations.Create(ctx, req) (variations.go)
    • 02_api_endpoints/11_variations/05_get-variations-id.md — client.Variations.Get(ctx, variationID) (variations.go)
    • 02_api_endpoints/11_variations/06_delete-variations-id.md — client.Variations.Delete(ctx, variationID) (variations.go)
    • 02_api_endpoints/11_variations/07_put-variations-id.md — client.Variations.Update(ctx, variationID, req) (variations.go)
  • Webhooks Service
    • 02_api_endpoints/12_webhooks/01_the-webhook-model.md — Webhook struct model (webhooks.go)
    • 02_api_endpoints/12_webhooks/02_get-webhooks.md — client.Webhooks.List(ctx, opts) & All iterator (webhooks.go)
    • 02_api_endpoints/12_webhooks/03_post-webhooks.md — client.Webhooks.Create(ctx, req) (webhooks.go)
    • 02_api_endpoints/12_webhooks/04_delete-webhooks-id.md — client.Webhooks.Delete(ctx, webhookID) (webhooks.go)
4. Webhooks Subsystem (03_webhooks/)
5. Unofficial Extensions

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	// DefaultBaseURL is the standard Shopier REST API v1 endpoint.
	DefaultBaseURL = "https://api.shopier.com/v1"

	// DefaultOAuthBaseURL is the Shopier OAuth 2.0 endpoint running on port 8443.
	DefaultOAuthBaseURL = "https://api.shopier.com:8443/v1"

	// Version is the current release version of this SDK.
	Version = "1.0.0"

	// DefaultUserAgent sent with outbound API requests.
	DefaultUserAgent = "shopier-go/" + Version
)

Variables

View Source
var (
	// ErrMissingToken indicates that an API request was attempted without an access token.
	ErrMissingToken = errors.New("shopier: access token is required")

	// ErrInvalidBaseURL indicates that the provided API base URL is malformed.
	ErrInvalidBaseURL = errors.New("shopier: invalid base URL")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int         `json:"status_code"`
	ErrorCode  string      `json:"error,omitempty"`
	Message    string      `json:"message,omitempty"`
	Detail     string      `json:"error_description,omitempty"`
	RawBody    []byte      `json:"-"`
	Header     http.Header `json:"-"`
}

APIError represents a non-2xx HTTP response from the Shopier REST API.

func (*APIError) Error

func (e *APIError) Error() string

type AuthenticationError

type AuthenticationError struct {
	APIError
}

AuthenticationError represents a 401 Unauthorized response, typically caused by an expired, invalid, or revoked Personal Access Token or OAuth2 access token.

func (*AuthenticationError) Error

func (e *AuthenticationError) Error() string

type AutomaticDiscount

type AutomaticDiscount struct {
	ID              string   `json:"id"`
	Title           string   `json:"title"`
	Scope           string   `json:"scope"` // "all", "selectedProducts", "selectedCategories"
	ProductIDs      []string `json:"productIds,omitempty"`
	CategoryIDs     []string `json:"categoryIds,omitempty"`
	DateCreated     string   `json:"dateCreated"`
	Type            string   `json:"type"` // "amount" or "percent"
	AmountOff       string   `json:"amountOff,omitempty"`
	PercentOff      string   `json:"percentOff,omitempty"`
	Requirement     string   `json:"requirement"` // "amount" or "quantity"
	AmountMinimum   string   `json:"amountMinimum,omitempty"`
	QuantityMinimum int      `json:"quantityMinimum,omitempty"`
	Currency        string   `json:"currency"`
	StartsAt        string   `json:"startsAt,omitempty"`
	ExpiresAt       string   `json:"expiresAt,omitempty"`
}

AutomaticDiscount represents a rule-based promotion applied without user entry.

type AutomaticDiscountCreateRequest

type AutomaticDiscountCreateRequest struct {
	Title           string   `json:"title"`
	Scope           string   `json:"scope"`
	ProductIDs      []string `json:"productIds,omitempty"`
	CategoryIDs     []string `json:"categoryIds,omitempty"`
	Type            string   `json:"type"`
	AmountOff       string   `json:"amountOff,omitempty"`
	PercentOff      string   `json:"percentOff,omitempty"`
	Requirement     string   `json:"requirement"`
	AmountMinimum   string   `json:"amountMinimum,omitempty"`
	QuantityMinimum int      `json:"quantityMinimum,omitempty"`
	Currency        string   `json:"currency"`
	StartsAt        string   `json:"startsAt,omitempty"`
	ExpiresAt       string   `json:"expiresAt,omitempty"`
}

AutomaticDiscountCreateRequest defines parameters for POST /discounts/automatic.

type AutomaticDiscountUpdateRequest

type AutomaticDiscountUpdateRequest struct {
	Title           string   `json:"title,omitempty"`
	Scope           string   `json:"scope,omitempty"`
	ProductIDs      []string `json:"productIds,omitempty"`
	CategoryIDs     []string `json:"categoryIds,omitempty"`
	AmountMinimum   string   `json:"amountMinimum,omitempty"`
	QuantityMinimum int      `json:"quantityMinimum,omitempty"`
	StartsAt        string   `json:"startsAt,omitempty"`
	ExpiresAt       string   `json:"expiresAt,omitempty"`
}

AutomaticDiscountUpdateRequest defines parameters for PUT /discounts/automatic/{id}.

type Balance

type Balance struct {
	Currency string `json:"currency"`
	Amount   string `json:"amount"`
}

Balance represents funds held in a specific currency in the merchant's account.

type BalanceListTransactionsOptions

type BalanceListTransactionsOptions struct {
	ListOptions
	DateStart string `url:"dateStart,omitempty"`
	DateEnd   string `url:"dateEnd,omitempty"`
}

BalanceListTransactionsOptions holds query filters for GET /balance/transactions.

func (*BalanceListTransactionsOptions) Values

Values compiles BalanceListTransactionsOptions into URL query parameters.

type BalanceService

type BalanceService struct {
	// contains filtered or unexported fields
}

BalanceService exposes balance inquiries and transaction ledger queries.

func (*BalanceService) AllTransactions

AllTransactions returns a Go 1.23+ iterator traversing all balance transactions across pages.

func (*BalanceService) Get

func (s *BalanceService) Get(ctx context.Context) ([]Balance, error)

Get retrieves current net balances across all active currencies.

func (*BalanceService) GetTransaction

func (s *BalanceService) GetTransaction(ctx context.Context, orderID string) (*Transaction, error)

GetTransaction retrieves a specific balance transaction by its associated order ID.

func (*BalanceService) ListTransactions

ListTransactions returns paginated balance transactions contributing to net funds.

type Category

type Category struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Placement int    `json:"placement"`
}

Category represents a grouping container for products.

type CategoryCreateRequest

type CategoryCreateRequest struct {
	Title string `json:"title"`
}

CategoryCreateRequest defines parameters for POST /categories.

type CategoryService

type CategoryService struct {
	// contains filtered or unexported fields
}

CategoryService exposes product category management endpoints.

func (*CategoryService) All

All returns a Go 1.23+ iterator traversing every category across all pages.

func (*CategoryService) Create

Create registers a new product category.

func (*CategoryService) Delete

func (s *CategoryService) Delete(ctx context.Context, id string) error

Delete permanently removes a product category.

func (*CategoryService) Get

func (s *CategoryService) Get(ctx context.Context, id string) (*Category, error)

Get retrieves a category by its ID.

func (*CategoryService) List

List returns paginated product categories.

func (*CategoryService) Update

Update renames an existing product category.

type CategoryUpdateRequest

type CategoryUpdateRequest struct {
	Title string `json:"title"`
}

CategoryUpdateRequest defines parameters for PUT /categories/{id}.

type Client

type Client struct {

	// Resource services
	Balance       *BalanceService
	Categories    *CategoryService
	Discounts     *DiscountService
	Orders        *OrderService
	Payouts       *PayoutService
	Products      *ProductService
	Refunds       *RefundService
	Selections    *SelectionService
	Shippings     *ShippingService
	Shop          *ShopService
	Variations    *VariationService
	Webhooks      *WebhookService
	QuickCheckout *QuickCheckoutService
	// contains filtered or unexported fields
}

Client coordinates API requests across all Shopier resource services.

func NewClient

func NewClient(token string, opts ...Option) (*Client, error)

NewClient returns a configured Shopier API client. An access token (Personal Access Token or OAuth2 bearer token) is required.

type DiscountCode

type DiscountCode struct {
	ID            string `json:"id"`
	Code          string `json:"code"`
	DateCreated   string `json:"dateCreated"`
	Type          string `json:"type"` // "amount" or "percent"
	AmountOff     string `json:"amountOff,omitempty"`
	PercentOff    string `json:"percentOff,omitempty"`
	AmountMinimum string `json:"amountMinimum,omitempty"`
	Currency      string `json:"currency"`
	NumAvailable  int    `json:"numAvailable"`
	NumUsed       int    `json:"numUsed"`
	ExpiresAt     string `json:"expiresAt,omitempty"`
}

DiscountCode represents a promotional code redeemed at checkout.

type DiscountCodeCreateRequest

type DiscountCodeCreateRequest struct {
	Code          string `json:"code"`
	Type          string `json:"type"` // "amount" or "percent"
	AmountOff     string `json:"amountOff,omitempty"`
	PercentOff    string `json:"percentOff,omitempty"`
	AmountMinimum string `json:"amountMinimum,omitempty"`
	Currency      string `json:"currency"`
	NumAvailable  int    `json:"numAvailable"`
	ExpiresAt     string `json:"expiresAt,omitempty"`
}

DiscountCodeCreateRequest defines parameters for POST /discounts/codes.

type DiscountCodeUpdateRequest

type DiscountCodeUpdateRequest struct {
	Code          string `json:"code,omitempty"`
	NumAvailable  int    `json:"numAvailable,omitempty"`
	ExpiresAt     string `json:"expiresAt,omitempty"`
	AmountMinimum string `json:"amountMinimum,omitempty"`
}

DiscountCodeUpdateRequest defines parameters for PUT /discounts/codes/{id}.

type DiscountService

type DiscountService struct {
	// contains filtered or unexported fields
}

DiscountService exposes promotional code and automatic discount endpoints.

func (*DiscountService) AllAutomatic

AllAutomatic returns a Go 1.23+ iterator traversing all automatic discounts.

func (*DiscountService) AllCodes

AllCodes returns a Go 1.23+ iterator traversing all discount codes across pages.

func (*DiscountService) CreateAutomatic

CreateAutomatic creates a new automatic discount campaign.

func (*DiscountService) CreateCode

CreateCode publishes a new discount code.

func (*DiscountService) DeleteAutomatic

func (s *DiscountService) DeleteAutomatic(ctx context.Context, id string) error

DeleteAutomatic permanently deletes an automatic discount campaign.

func (*DiscountService) DeleteCode

func (s *DiscountService) DeleteCode(ctx context.Context, id string) error

DeleteCode permanently deletes a discount code.

func (*DiscountService) GetAutomatic

func (s *DiscountService) GetAutomatic(ctx context.Context, id string) (*AutomaticDiscount, error)

GetAutomatic retrieves an automatic discount by ID.

func (*DiscountService) GetCode

func (s *DiscountService) GetCode(ctx context.Context, id string) (*DiscountCode, error)

GetCode retrieves a discount code by ID.

func (*DiscountService) ListAutomatic

ListAutomatic returns paginated automatic discount campaigns.

func (*DiscountService) ListCodes

ListCodes returns paginated discount codes.

func (*DiscountService) UpdateAutomatic

UpdateAutomatic updates an existing automatic discount campaign.

func (*DiscountService) UpdateCode

UpdateCode updates attributes of an existing discount code.

type ListOptions

type ListOptions struct {
	// Page specifies the page of results to return (default: 1, min: 1).
	Page int `url:"page,omitempty"`

	// Limit specifies the maximum number of items returned (default: 10, min: 1, max: 50).
	Limit int `url:"limit,omitempty"`

	// Sort specifies sort order or field where supported by the endpoint.
	Sort string `url:"sort,omitempty"`
}

ListOptions specifies common query parameters for all Shopier list endpoints.

func (*ListOptions) Values

func (o *ListOptions) Values() url.Values

Values converts ListOptions into standard url.Values.

type Option

type Option func(*Client)

Option represents a functional configuration option for Client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL overrides the default REST API base URL (default: "https://api.shopier.com/v1").

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom http.Client for network transport.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger configures a structured logger using Go's standard log/slog.

func WithMaxRetries

func WithMaxRetries(retries int) Option

WithMaxRetries sets the maximum retry attempts for transient server errors (5xx) and rate limit throttling (429). Setting 0 disables automatic retries.

func WithOAuthBaseURL

func WithOAuthBaseURL(url string) Option

WithOAuthBaseURL overrides the default OAuth base URL (default: "https://api.shopier.com:8443/v1"). Shopier routes OAuth token exchanges and revocations via port 8443.

func WithRetryDelay

func WithRetryDelay(initial, max time.Duration) Option

WithRetryDelay configures initial delay and maximum delay cap for exponential backoff.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout configures a default client-level timeout applied when a request context does not specify its own deadline.

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent customizes the User-Agent request header string.

type Order

type Order struct {
	ID            string            `json:"id"`
	Status        string            `json:"status"`
	PaymentStatus string            `json:"paymentStatus"`
	Installments  bool              `json:"installments"`
	DateCreated   string            `json:"dateCreated"`
	Currency      string            `json:"currency"`
	PaymentMethod string            `json:"paymentMethod"`
	Totals        OrderTotals       `json:"totals"`
	Discounts     []OrderDiscount   `json:"discounts,omitempty"`
	ShippingInfo  OrderShippingInfo `json:"shippingInfo"`
	BillingInfo   *OrderBillingInfo `json:"billingInfo,omitempty"`
	Note          string            `json:"note,omitempty"`
	LineItems     []OrderLineItem   `json:"lineItems"`
}

Order represents an order placed through Shopier.

type OrderBillingInfo

type OrderBillingInfo struct {
	FirstName  string `json:"firstName"`
	LastName   string `json:"lastName"`
	NationalID string `json:"nationalId,omitempty"`
	Email      string `json:"email"`
	Phone      string `json:"phone"`
	Company    string `json:"company,omitempty"`
	TaxOffice  string `json:"taxOffice,omitempty"`
	TaxNumber  string `json:"taxNumber,omitempty"`
	Address    string `json:"address"`
	District   string `json:"district"`
	City       string `json:"city"`
	State      string `json:"state,omitempty"`
	Postcode   string `json:"postcode,omitempty"`
	Country    string `json:"country"`
}

OrderBillingInfo represents corporate or separate invoicing details.

type OrderDiscount

type OrderDiscount struct {
	ID     string `json:"id"`
	Method string `json:"method"`
}

OrderDiscount describes a discount applied to an order.

type OrderFulfillments

type OrderFulfillments struct {
	ProductType     string `json:"productType,omitempty"`
	ShippingCompany string `json:"shippingCompany,omitempty"`
	TrackingNumber  string `json:"trackingNumber,omitempty"`
	Note            string `json:"note,omitempty"`
}

OrderFulfillments defines delivery execution status and carrier details.

type OrderLineItem

type OrderLineItem struct {
	ProductID string                   `json:"productId"`
	Title     string                   `json:"title"`
	Type      string                   `json:"type"`
	Selection []OrderLineItemSelection `json:"selection,omitempty"`
	Options   []OrderLineItemOption    `json:"options,omitempty"`
	Quantity  int                      `json:"quantity"`
	Price     string                   `json:"price"`
}

OrderLineItem represents an individual item within an order.

type OrderLineItemOption

type OrderLineItemOption struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	Price string `json:"price"`
}

OrderLineItemOption represents buyer-selected addon options for a line item.

type OrderLineItemSelection

type OrderLineItemSelection struct {
	ID             string `json:"id"`
	Title          string `json:"title"`
	VariationTitle string `json:"variationTitle"`
}

OrderLineItemSelection represents variant choices for a line item.

type OrderListOptions

type OrderListOptions struct {
	ListOptions
	DateStart         string `url:"dateStart,omitempty"`
	DateEnd           string `url:"dateEnd,omitempty"`
	FulfillmentStatus string `url:"fulfillmentStatus,omitempty"`
	RefundType        string `url:"refundType,omitempty"`
	CustomerEmail     string `url:"customerEmail,omitempty"`
	CustomerPhone     string `url:"customerPhone,omitempty"`
	ProductID         string `url:"productId,omitempty"`
}

OrderListOptions holds query filters accepted by GET /orders. Shopier defaults dateStart/dateEnd to the last 60 days when omitted.

func (*OrderListOptions) Values

func (o *OrderListOptions) Values() url.Values

Values compiles OrderListOptions into URL query parameters.

type OrderService

type OrderService struct {
	// contains filtered or unexported fields
}

OrderService exposes order management endpoints.

func (*OrderService) All

All returns a Go 1.23+ range iterator traversing every order matching opts. Pages are fetched lazily as the loop progresses.

func (*OrderService) Get

func (s *OrderService) Get(ctx context.Context, id string) (*Order, error)

Get retrieves an order by its unique Shopier ID.

func (*OrderService) GetTransaction

func (s *OrderService) GetTransaction(ctx context.Context, orderID string) (*OrderTransaction, error)

GetTransaction retrieves settlement and fee breakdown for an order.

func (*OrderService) List

List queries orders matching the specified filter parameters.

func (*OrderService) Update

func (s *OrderService) Update(ctx context.Context, id string, req *OrderUpdateRequest) (*Order, error)

Update updates an order's fulfillment tracking or buyer shipping address.

type OrderShippingInfo

type OrderShippingInfo struct {
	FirstName  string `json:"firstName"`
	LastName   string `json:"lastName"`
	NationalID string `json:"nationalId,omitempty"`
	Email      string `json:"email"`
	Phone      string `json:"phone"`
	Company    string `json:"company,omitempty"`
	Address    string `json:"address"`
	District   string `json:"district"`
	City       string `json:"city"`
	State      string `json:"state,omitempty"`
	Postcode   string `json:"postcode,omitempty"`
	Country    string `json:"country"`
}

OrderShippingInfo represents the recipient and destination delivery details.

type OrderTotals

type OrderTotals struct {
	Subtotal string `json:"subtotal"`
	Shipping string `json:"shipping"`
	Discount string `json:"discount"`
	Total    string `json:"total"`
}

OrderTotals specifies price breakdowns for an order.

type OrderTransaction

type OrderTransaction struct {
	OrderID     string            `json:"orderId"`
	Type        string            `json:"type"`
	Description string            `json:"description,omitempty"`
	DateCreated string            `json:"dateCreated"`
	Gross       TransactionAmount `json:"gross"`
	Fee         TransactionFee    `json:"fee"`
	Net         TransactionAmount `json:"net"`
}

OrderTransaction provides financial breakdown details for an order payment.

type OrderUpdateRequest

type OrderUpdateRequest struct {
	Fulfillments *OrderFulfillments `json:"fulfillments,omitempty"`
	ShippingInfo *OrderShippingInfo `json:"shippingInfo,omitempty"`
}

OrderUpdateRequest defines payload parameters accepted by PUT /orders/{id}.

type PageResponse

type PageResponse[T any] struct {
	Items      []T            `json:"items"`
	Pagination PaginationInfo `json:"pagination"`
}

PageResponse wraps an item slice alongside its Shopier pagination metadata.

type PaginationInfo

type PaginationInfo struct {
	Page       int `json:"page"`
	Limit      int `json:"limit"`
	TotalPages int `json:"total_pages"`
	TotalItems int `json:"total_items"`
}

PaginationInfo holds pagination metadata extracted from Shopier response headers. Shopier delivers pagination state via custom HTTP headers rather than response bodies: - Shopier-Pagination-Page - Shopier-Pagination-Limit - Shopier-Pagination-Total-Pages - Shopier-Pagination-Total-Items

func ParsePaginationHeaders

func ParsePaginationHeaders(header http.Header) PaginationInfo

ParsePaginationHeaders reads Shopier-Pagination-* headers from an HTTP response.

func (PaginationInfo) HasNextPage

func (p PaginationInfo) HasNextPage() bool

HasNextPage returns true if more pages are available after the current page.

func (PaginationInfo) NextPage

func (p PaginationInfo) NextPage() int

NextPage returns the index for the next page, or 0 if no subsequent pages exist.

type Payout

type Payout struct {
	ID          string            `json:"id"`
	Status      string            `json:"status"` // "pending" or "paid"
	DateCreated string            `json:"dateCreated"`
	Amount      string            `json:"amount"`
	Currency    string            `json:"currency"`
	Destination PayoutDestination `json:"destination"`
}

Payout represents a fund disbursement transferred to the merchant's bank account.

type PayoutDestination

type PayoutDestination struct {
	Type string `json:"type"` // "bankAccount"
	IBAN string `json:"iban"`
}

PayoutDestination specifies the bank details receiving transferred funds.

type PayoutService

type PayoutService struct {
	// contains filtered or unexported fields
}

PayoutService exposes merchant disbursement endpoints.

func (*PayoutService) All

All returns a Go 1.23+ iterator traversing all payouts across pages.

func (*PayoutService) AllTransactions

func (s *PayoutService) AllTransactions(ctx context.Context, id string, opts *ListOptions) iter.Seq2[Transaction, error]

AllTransactions returns a Go 1.23+ iterator traversing all transactions of a payout across pages.

func (*PayoutService) Get

func (s *PayoutService) Get(ctx context.Context, id string) (*Payout, error)

Get retrieves a payout record by its ID.

func (*PayoutService) List

List returns paginated payout transfer records.

func (*PayoutService) ListTransactions

func (s *PayoutService) ListTransactions(ctx context.Context, id string, opts *ListOptions) (*PageResponse[Transaction], error)

ListTransactions returns paginated transactions included in a specific payout.

type Product

type Product struct {
	ID               string               `json:"id"`
	Title            string               `json:"title"`
	Description      string               `json:"description,omitempty"`
	Type             string               `json:"type"`
	DateCreated      string               `json:"dateCreated,omitempty"`
	URL              string               `json:"url,omitempty"`
	Media            []ProductMedia       `json:"media"`
	PriceData        ProductPriceData     `json:"priceData"`
	StockStatus      string               `json:"stockStatus,omitempty"`
	StockQuantity    int                  `json:"stockQuantity"`
	ShippingPayer    string               `json:"shippingPayer"`
	Categories       []ProductCategoryRef `json:"categories,omitempty"`
	Variants         []ProductVariant     `json:"variants,omitempty"`
	Options          []ProductOption      `json:"options,omitempty"`
	SingleOption     bool                 `json:"singleOption"`
	CustomListing    bool                 `json:"customListing"`
	CustomNote       string               `json:"customNote,omitempty"`
	PlacementScore   int                  `json:"placementScore,omitempty"`
	DispatchDuration int                  `json:"dispatchDuration,omitempty"`
}

Product represents a merchandise listing in a Shopier storefront.

type ProductCategoryRef

type ProductCategoryRef struct {
	ID         string `json:"id,omitempty"`
	CategoryID string `json:"categoryId,omitempty"`
	Title      string `json:"title,omitempty"`
}

ProductCategoryRef links a product to an existing category.

type ProductCreateRequest

type ProductCreateRequest struct {
	Title            string               `json:"title"`
	Description      string               `json:"description,omitempty"`
	Type             string               `json:"type"`
	Media            []ProductMedia       `json:"media"`
	PriceData        ProductPriceData     `json:"priceData"`
	StockQuantity    int                  `json:"stockQuantity,omitempty"`
	ShippingPayer    string               `json:"shippingPayer"`
	Categories       []ProductCategoryRef `json:"categories,omitempty"`
	Variants         []ProductVariant     `json:"variants,omitempty"`
	Options          []ProductOption      `json:"options,omitempty"`
	SingleOption     bool                 `json:"singleOption,omitempty"`
	CustomListing    bool                 `json:"customListing,omitempty"`
	CustomNote       string               `json:"customNote,omitempty"`
	PlacementScore   int                  `json:"placementScore,omitempty"`
	DispatchDuration int                  `json:"dispatchDuration,omitempty"`
}

ProductCreateRequest defines parameters required by POST /products.

type ProductListOptions

type ProductListOptions struct {
	ListOptions
	Title    string `url:"title,omitempty"`
	Status   string `url:"status,omitempty"`
	Category string `url:"category,omitempty"`
}

ProductListOptions holds filter parameters accepted by GET /products.

func (*ProductListOptions) Values

func (o *ProductListOptions) Values() url.Values

Values compiles ProductListOptions into URL query parameters.

type ProductMedia

type ProductMedia struct {
	ID        string `json:"id,omitempty"`
	Type      string `json:"type"`
	URL       string `json:"url"`
	Placement int    `json:"placement"`
}

ProductMedia describes an image asset attached to a product listing.

type ProductOption

type ProductOption struct {
	ID          string `json:"id,omitempty"`
	OptionID    string `json:"optionId,omitempty"`
	Title       string `json:"title,omitempty"`
	OptionTitle string `json:"optionTitle,omitempty"`
	Price       string `json:"price,omitempty"`
	OptionPrice string `json:"optionPrice,omitempty"`
}

ProductOption defines an optional addon item configurable by the buyer.

type ProductPriceData

type ProductPriceData struct {
	Currency        string `json:"currency"`
	Price           string `json:"price"`
	Discount        bool   `json:"discount"`
	DiscountedPrice string `json:"discountedPrice,omitempty"`
	ShippingPrice   string `json:"shippingPrice,omitempty"`
}

ProductPriceData holds currency, unit price, discounts, and shipping cost.

type ProductService

type ProductService struct {
	// contains filtered or unexported fields
}

ProductService exposes product catalog management endpoints.

func (*ProductService) All

All returns a Go 1.23+ range iterator across all products matching opts.

func (*ProductService) Create

Create publishes a new product to the shop.

func (*ProductService) Delete

func (s *ProductService) Delete(ctx context.Context, id string) error

Delete permanently removes a product listing from the storefront.

func (*ProductService) Get

func (s *ProductService) Get(ctx context.Context, id string) (*Product, error)

Get retrieves a single product by its unique Shopier ID.

func (*ProductService) List

List queries products matching the filter criteria.

func (*ProductService) Update

func (s *ProductService) Update(ctx context.Context, id string, req *ProductUpdateRequest) (*Product, error)

Update updates an existing product's attributes.

type ProductUpdateRequest

type ProductUpdateRequest struct {
	Title            *string              `json:"title,omitempty"`
	Description      *string              `json:"description,omitempty"`
	Type             *string              `json:"type,omitempty"`
	Media            []ProductMedia       `json:"media,omitempty"`
	PriceData        *ProductPriceData    `json:"priceData,omitempty"`
	StockQuantity    *int                 `json:"stockQuantity,omitempty"`
	ShippingPayer    *string              `json:"shippingPayer,omitempty"`
	Categories       []ProductCategoryRef `json:"categories,omitempty"`
	Variants         []ProductVariant     `json:"variants,omitempty"`
	Options          []ProductOption      `json:"options,omitempty"`
	SingleOption     *bool                `json:"singleOption,omitempty"`
	CustomListing    *bool                `json:"customListing,omitempty"`
	CustomNote       *string              `json:"customNote,omitempty"`
	PlacementScore   *int                 `json:"placementScore,omitempty"`
	DispatchDuration *int                 `json:"dispatchDuration,omitempty"`
}

ProductUpdateRequest defines parameters accepted by PUT /products/{id}.

type ProductVariant

type ProductVariant struct {
	VariationID    string            `json:"variationId,omitempty"`
	VariationTitle string            `json:"variationTitle,omitempty"`
	SelectionID    any               `json:"selectionId,omitempty"` // array of strings on input, string or array on response
	SelectionTitle string            `json:"selectionTitle,omitempty"`
	StockStatus    string            `json:"stockStatus,omitempty"`
	StockQuantity  int               `json:"stockQuantity"`
	Media          []ProductMedia    `json:"media,omitempty"`
	PriceData      *ProductPriceData `json:"priceData,omitempty"`
	Primary        bool              `json:"primary,omitempty"`
}

ProductVariant defines variant stock and pricing tied to variation selections.

type QuickCheckoutBuyer

type QuickCheckoutBuyer struct {
	Email     string `json:"email"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Phone     string `json:"phone"`                // e.g. "+90 532 477 02 10" or "5324770210"
	PhoneCode string `json:"phone_code,omitempty"` // defaults to "TR"
	Country   string `json:"country,omitempty"`    // defaults to "Türkiye"
	City      string `json:"city,omitempty"`
	State     string `json:"state,omitempty"`
	Address   string `json:"address,omitempty"`
	ZipCode   string `json:"zip_code,omitempty"`
	TCIDNo    string `json:"tcid_no,omitempty"`
	Comment   string `json:"comment,omitempty"`
}

QuickCheckoutBuyer holds buyer and delivery details for the checkout session.

type QuickCheckoutError

type QuickCheckoutError struct {
	Stage      QuickCheckoutStage `json:"stage"`
	StatusCode int                `json:"status_code,omitempty"`
	Message    string             `json:"message"`
	Body       string             `json:"body,omitempty"`
	Err        error              `json:"-"`
}

QuickCheckoutError captures failures during unofficial checkout link creation.

func (*QuickCheckoutError) Error

func (e *QuickCheckoutError) Error() string

func (*QuickCheckoutError) Unwrap

func (e *QuickCheckoutError) Unwrap() error

type QuickCheckoutOption

type QuickCheckoutOption func(*QuickCheckoutService)

QuickCheckoutOption configures the QuickCheckoutService.

func WithQuickCheckoutBaseURL

func WithQuickCheckoutBaseURL(baseURL string) QuickCheckoutOption

WithQuickCheckoutBaseURL sets a custom base URL (default: "https://www.shopier.com").

func WithQuickCheckoutHTTPClient

func WithQuickCheckoutHTTPClient(client *http.Client) QuickCheckoutOption

WithQuickCheckoutHTTPClient provides a custom base HTTP client (transport/proxy settings).

func WithQuickCheckoutTimeout

func WithQuickCheckoutTimeout(timeout time.Duration) QuickCheckoutOption

WithQuickCheckoutTimeout sets request timeout.

func WithQuickCheckoutUserAgent

func WithQuickCheckoutUserAgent(ua string) QuickCheckoutOption

WithQuickCheckoutUserAgent sets a custom User-Agent header.

type QuickCheckoutRequest

type QuickCheckoutRequest struct {
	// ProductURL can be provided instead of Account and ProductID (e.g. "https://www.shopier.com/adisgroup/50900391").
	ProductURL string `json:"product_url,omitempty"`

	// Account is the seller username / shop slug (e.g. "adisgroup").
	Account string `json:"account,omitempty"`

	// ProductID is the unique numeric or alphanumeric product identifier.
	ProductID string `json:"product_id,omitempty"`

	// Quantity defaults to 1 if omitted.
	Quantity int `json:"quantity,omitempty"`

	// Options can contain optional variant or selection parameters.
	Options map[string]string `json:"options,omitempty"`

	// Buyer contains shipping and contact information.
	Buyer QuickCheckoutBuyer `json:"buyer"`
}

QuickCheckoutRequest defines inputs to generate a checkout link.

type QuickCheckoutResult

type QuickCheckoutResult struct {
	OrderID     string         `json:"order_id"`
	PaymentURL  string         `json:"payment_url"`
	Account     string         `json:"account"`
	ProductID   string         `json:"product_id"`
	RawResponse map[string]any `json:"raw_response,omitempty"`
}

QuickCheckoutResult contains the generated order ID and direct checkout link.

type QuickCheckoutService

type QuickCheckoutService struct {
	// contains filtered or unexported fields
}

QuickCheckoutService generates direct checkout and payment links.

func NewQuickCheckoutService

func NewQuickCheckoutService(opts ...QuickCheckoutOption) *QuickCheckoutService

NewQuickCheckoutService creates an isolated QuickCheckoutService instance.

func (*QuickCheckoutService) Create

Create executes the 4-step frontend flow and returns a direct payment URL. Each execution uses a fresh, isolated cookie jar for total concurrency safety.

type QuickCheckoutStage

type QuickCheckoutStage string

QuickCheckoutStage represents a step in the unofficial checkout process.

const (
	StageParseInput        QuickCheckoutStage = "parse_input"
	StageFetchProduct      QuickCheckoutStage = "fetch_product"
	StageExtractCSRF       QuickCheckoutStage = "extract_csrf"
	StageCheckPayment      QuickCheckoutStage = "check_payment"
	StageFetchShippingForm QuickCheckoutStage = "fetch_shipping_form"
	StageProcessShipment   QuickCheckoutStage = "process_shipment"
)

type RateLimitError

type RateLimitError struct {
	APIError
	// RetryAfter indicates the duration requested by the server before retrying.
	// Parsed from the 'Retry-After' response header (in seconds).
	RetryAfter time.Duration
}

RateLimitError represents a 429 Too Many Requests response. Shopier enforces rate limits on a 60-second sliding window (default: 200 req/min).

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

type Refund

type Refund struct {
	ID           string `json:"id"`
	Type         string `json:"type"`   // "full" or "partial"
	Status       string `json:"status"` // "pending", "failed", "succeeded"
	OrderID      string `json:"orderId"`
	DateCreated  string `json:"dateCreated"`
	DateRefunded string `json:"dateRefunded,omitempty"`
	Currency     string `json:"currency"`
	Total        string `json:"total"`
	Note         string `json:"note,omitempty"`
}

Refund represents a payment reimbursement for an order.

type RefundCreateRequest

type RefundCreateRequest struct {
	OrderID string `json:"orderId"`
	Amount  string `json:"amount,omitempty"`
	Note    string `json:"note,omitempty"`
}

RefundCreateRequest defines parameters for POST /refunds.

type RefundListOptions

type RefundListOptions struct {
	ListOptions
	OrderID string `url:"orderId,omitempty"`
}

RefundListOptions holds query filters for GET /refunds.

func (*RefundListOptions) Values

func (o *RefundListOptions) Values() url.Values

Values compiles RefundListOptions into URL query parameters.

type RefundService

type RefundService struct {
	// contains filtered or unexported fields
}

RefundService exposes order refund management endpoints.

func (*RefundService) All

All returns a Go 1.23+ iterator traversing all refunds across pages.

func (*RefundService) Create

func (s *RefundService) Create(ctx context.Context, req *RefundCreateRequest) (*Refund, error)

Create initiates a full or partial refund on a paid order.

func (*RefundService) Get

func (s *RefundService) Get(ctx context.Context, id string) (*Refund, error)

Get retrieves a refund by its ID.

func (*RefundService) List

List returns paginated refund records.

type Selection

type Selection struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	VariationID string `json:"variationId"`
}

Selection represents a concrete option within an attribute variation (e.g. "Red" in "Color").

type SelectionCreateRequest

type SelectionCreateRequest struct {
	VariationID string `json:"variationId"`
	Title       string `json:"title"`
}

SelectionCreateRequest defines parameters for POST /selections.

type SelectionListOptions

type SelectionListOptions struct {
	ListOptions
	VariationIDs []string `url:"variationId,omitempty"`
}

SelectionListOptions holds query filters for GET /selections.

func (*SelectionListOptions) Values

func (o *SelectionListOptions) Values() url.Values

Values compiles SelectionListOptions into URL query parameters.

type SelectionService

type SelectionService struct {
	// contains filtered or unexported fields
}

SelectionService exposes variation selection endpoints.

func (*SelectionService) All

All returns a Go 1.23+ iterator traversing selections across all pages.

func (*SelectionService) Create

Create adds a new option value to a variation.

func (*SelectionService) Delete

func (s *SelectionService) Delete(ctx context.Context, id string) error

Delete permanently removes a selection.

func (*SelectionService) Get

func (s *SelectionService) Get(ctx context.Context, id string) (*Selection, error)

Get retrieves a selection by its ID.

func (*SelectionService) List

List returns paginated variation selections.

func (*SelectionService) Update

Update renames an existing selection.

type SelectionUpdateRequest

type SelectionUpdateRequest struct {
	Title string `json:"title"`
}

SelectionUpdateRequest defines parameters for PUT /selections/{id}.

type Shipping

type Shipping struct {
	OrderID        string `json:"orderId"`
	Status         string `json:"status"`
	Method         string `json:"method"`
	Type           string `json:"type"`
	DateCreated    string `json:"dateCreated"`
	DateDispatched string `json:"dateDispatched,omitempty"`
	Company        string `json:"company"`
	Code           string `json:"code"`
	TrackingNumber string `json:"trackingNumber,omitempty"`
	TrackingURL    string `json:"trackingUrl,omitempty"`
	Size           string `json:"size,omitempty"`
	SizeUnit       string `json:"sizeUnit,omitempty"`
	Weight         string `json:"weight,omitempty"`
	WeightUnit     string `json:"weightUnit,omitempty"`
	Cost           string `json:"cost,omitempty"`
	Currency       string `json:"currency,omitempty"`
}

Shipping represents shipment tracking and carrier dispatch status.

type ShippingCreateRequest

type ShippingCreateRequest struct {
	OrderID string `json:"orderId"`
	Company string `json:"company"`
}

ShippingCreateRequest defines parameters for POST /shippings.

type ShippingListOptions

type ShippingListOptions struct {
	ListOptions
	Status  string `url:"status,omitempty"`
	Method  string `url:"method,omitempty"`
	Type    string `url:"type,omitempty"`
	OrderID string `url:"orderId,omitempty"`
}

ShippingListOptions holds query filters for GET /shippings.

func (*ShippingListOptions) Values

func (o *ShippingListOptions) Values() url.Values

Values compiles ShippingListOptions into URL query parameters.

type ShippingService

type ShippingService struct {
	// contains filtered or unexported fields
}

ShippingService exposes shipping code and tracking management endpoints.

func (*ShippingService) All

All returns a Go 1.23+ iterator traversing all shipping records.

func (*ShippingService) Create

Create generates a new contracted shipping code for an order.

func (*ShippingService) Delete

func (s *ShippingService) Delete(ctx context.Context, code string) error

Delete cancels an unmanifested shipping code.

func (*ShippingService) Get

func (s *ShippingService) Get(ctx context.Context, code string) (*Shipping, error)

Get retrieves a shipping record by its unique shipping code.

func (*ShippingService) List

List returns paginated shipping records.

type ShopOwner

type ShopOwner struct {
	ID          string               `json:"id"`
	Type        string               `json:"type"` // "personal" or "business"
	FirstName   string               `json:"firstName"`
	LastName    string               `json:"lastName"`
	Contact     ShopOwnerContact     `json:"contact"`
	Company     *ShopOwnerCompany    `json:"company,omitempty"`
	BankAccount ShopOwnerBankAccount `json:"bankAccount"`
}

ShopOwner represents identity and registration details of the merchant.

type ShopOwnerBankAccount

type ShopOwnerBankAccount struct {
	AccountHolder string `json:"accountHolder"`
	IBAN          string `json:"iban"`
}

ShopOwnerBankAccount specifies registered merchant settlement account.

type ShopOwnerCompany

type ShopOwnerCompany struct {
	Name      string `json:"name"`
	TaxOffice string `json:"taxOffice"`
	TaxNumber string `json:"taxNumber"`
}

ShopOwnerCompany specifies business legal registration details.

type ShopOwnerContact

type ShopOwnerContact struct {
	Email    string `json:"email"`
	Phone    string `json:"phone"`
	Address  string `json:"address"`
	District string `json:"district"`
	City     string `json:"city"`
	State    string `json:"state,omitempty"`
	Country  string `json:"country"`
}

ShopOwnerContact represents merchant communication coordinates.

type ShopService

type ShopService struct {
	// contains filtered or unexported fields
}

ShopService exposes merchant profile and store preference endpoints.

func (*ShopService) GetOwner

func (s *ShopService) GetOwner(ctx context.Context) (*ShopOwner, error)

GetOwner retrieves legal entity and contact information of the merchant.

func (*ShopService) GetSettings

func (s *ShopService) GetSettings(ctx context.Context) (*ShopSettings, error)

GetSettings retrieves current storefront display and configuration settings.

func (*ShopService) UpdateSettings

func (s *ShopService) UpdateSettings(ctx context.Context, req *ShopSettingsUpdateRequest) (*ShopSettings, error)

UpdateSettings modifies storefront preferences and contact coordinates.

type ShopSettings

type ShopSettings struct {
	Name         string `json:"name"`
	URL          string `json:"url"`
	Title        string `json:"title"`
	Slogan       string `json:"slogan,omitempty"`
	Announcement string `json:"announcement,omitempty"`
	Confirmation string `json:"confirmation,omitempty"`
	Email        string `json:"email"`
	Phone        string `json:"phone"`
	Access       bool   `json:"access"`
	Cart         bool   `json:"cart"`
	MobileView   string `json:"mobileView"` // "singleColumn" or "doubleColumn"
	Filter       bool   `json:"filter"`
	OutOfStock   bool   `json:"outOfStock"`
	Language     string `json:"language"` // "TR" or "EN"
	Vacation     bool   `json:"vacation"`
}

ShopSettings encapsulates public storefront display and behavior configuration.

type ShopSettingsUpdateRequest

type ShopSettingsUpdateRequest struct {
	Title        *string `json:"title,omitempty"`
	Slogan       *string `json:"slogan,omitempty"`
	Announcement *string `json:"announcement,omitempty"`
	Confirmation *string `json:"confirmation,omitempty"`
	Email        *string `json:"email,omitempty"`
	Phone        *string `json:"phone,omitempty"`
	Access       *bool   `json:"access,omitempty"`
	Cart         *bool   `json:"cart,omitempty"`
	MobileView   *string `json:"mobileView,omitempty"`
	Filter       *bool   `json:"filter,omitempty"`
	OutOfStock   *bool   `json:"outOfStock,omitempty"`
	Language     *string `json:"language,omitempty"`
	Vacation     *bool   `json:"vacation,omitempty"`
}

ShopSettingsUpdateRequest defines mutable parameters for PUT /shop/settings.

type Transaction

type Transaction struct {
	OrderID     string            `json:"orderId,omitempty"`
	Type        string            `json:"type"`
	Description string            `json:"description,omitempty"`
	DateCreated string            `json:"dateCreated"`
	Gross       TransactionAmount `json:"gross"`
	Fee         TransactionFee    `json:"fee"`
	Net         TransactionAmount `json:"net"`
}

Transaction represents a financial ledger entry (charge, fee, adjustment, payout item).

type TransactionAmount

type TransactionAmount struct {
	OriginCurrency string `json:"originCurrency"`
	OriginAmount   string `json:"originAmount"`
	Currency       string `json:"currency"`
	Amount         string `json:"amount"`
}

TransactionAmount contains amount details in original and settlement currencies.

type TransactionFee

type TransactionFee struct {
	Currency string `json:"currency"`
	Amount   string `json:"amount"`
}

TransactionFee contains fee deductions applied to a transaction.

type Variation

type Variation struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Placement int    `json:"placement"`
}

Variation represents an attribute axis (e.g. Size, Color) applicable to products.

type VariationCreateRequest

type VariationCreateRequest struct {
	Title string `json:"title"`
}

VariationCreateRequest defines parameters for POST /variations.

type VariationService

type VariationService struct {
	// contains filtered or unexported fields
}

VariationService exposes product variation management endpoints.

func (*VariationService) All

All returns a Go 1.23+ iterator traversing variations across all pages.

func (*VariationService) Create

Create registers a new variation.

func (*VariationService) Delete

func (s *VariationService) Delete(ctx context.Context, id string) error

Delete permanently removes a variation.

func (*VariationService) Get

func (s *VariationService) Get(ctx context.Context, id string) (*Variation, error)

Get retrieves a variation by its ID.

func (*VariationService) List

List returns paginated product variations.

func (*VariationService) Update

Update updates an existing variation title.

type VariationUpdateRequest

type VariationUpdateRequest struct {
	Title string `json:"title"`
}

VariationUpdateRequest defines parameters for PUT /variations/{id}.

type WebhookCreateRequest

type WebhookCreateRequest struct {
	Event string `json:"event"`
	URL   string `json:"url"`
}

WebhookCreateRequest defines parameters for POST /webhooks.

type WebhookService

type WebhookService struct {
	// contains filtered or unexported fields
}

WebhookService exposes webhook registration and subscription lifecycle endpoints.

func (*WebhookService) Create

Create registers a new notification URL for a specific webhook event. Save the returned Token securely, as Shopier will not expose it in subsequent List queries.

func (*WebhookService) Delete

func (s *WebhookService) Delete(ctx context.Context, id string) error

Delete permanently removes a webhook subscription by its ID.

func (*WebhookService) List

List retrieves all active webhook event subscriptions.

type WebhookSubscription

type WebhookSubscription struct {
	ID    string `json:"id"`
	Event string `json:"event"`
	URL   string `json:"url"`
	// Token is the secret signing key used to compute HMAC-SHA256 signatures.
	// Shopier returns this value only on the initial subscription creation response.
	Token string `json:"token,omitempty"`
}

WebhookSubscription represents an event callback registration with Shopier.

Directories

Path Synopsis
examples
01_quickstart command
02_oauth_flow command
04_iterators command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL