ministripe

package module
v0.0.3-beta-7 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

README

go-ministripe

go-ministripe is small Go library that serves as miniature version of Stripe SDK

Usecase

The reason im writing this library is that i need to charge user some money and it seems like excess to pull whole Stripe SDK to use only a very small subset of its features, and so is this library born.

Features

Implements simple operations with PaymentIntents It can:

  • Create payment intent
  • Check its status - weather its paid or not/something else
  • Delete payment intents // TODO

Import

Usage

Documentation

Overview

Package go-ministripe is small library for backend development that allows dev to communicate with Stripe API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SecretKey string // SecretKey secret key that is used to authenticate stripe requests, usually begins witk "sk_"
	PublicKey string // PublicKey public key, shareable with client side, begins with "pk_", optional for backend
	Timeout   uint   // timeout for requests in seconds
	// contains filtered or unexported fields
}

StripeConfig configuration structure type, used by the library

type PaymentIntent

type PaymentIntent struct {
	Id string `json:"id" url:"id"` // Id of the PaymentIntent
}

PaymentIntent PaymentIntent struct from Stripe API, only stores id of the PaymentIntent

type PaymentIntentParams

type PaymentIntentParams struct {
	Amount                    uint64 `url:"amount,omitempty"`                      // Amount of money to charge the user - in smallest unit of the currency (eg. 100 = 1$)
	Currency                  string `url:"currency,omitempty"`                    // Currency ISO format of the currency (eg. "czk" "eur" "usd")
	Description               string `url:"description,omitempty"`                 // Description usefull for displaying on the dashboard
	StatementDescriptor       string `url:"statement_descriptor,omitempty"`        // text that appears on the customer’s statement as the statement descriptor for a non-card charge.
	StatementDescriptorSuffix string `url:"statement_descriptor_suffix,omitempty"` // Provides information about a card charge.
}

Used for creating new paymentIntent with stripe API.

Note: There are lot of params missing, and thats for the sake of simplicity

type PaymentIntentResponse

type PaymentIntentResponse struct {
	Id           string `json:"id"`
	ClientSecret string `json:"client_secret"` // ClientSecret Used for client-side retrieval using a publishable key.
	Status       string `json:"status"`        // Status of this PaymentIntent, one of requires_payment_method, requires_confirmation, requires_action, processing, requires_capture, canceled, or succeeded
}

Used to store response from Stripe API after a request

type StripeClient

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

func NewStripeClient

func NewStripeClient(s *Config) (*StripeClient, error)

newStripeClient

func (*StripeClient) CancelPaymentIntent

func (sc *StripeClient) CancelPaymentIntent(p *PaymentIntent) (*PaymentIntentResponse, error)

func (*StripeClient) CreatePaymentIntent

func (sc *StripeClient) CreatePaymentIntent(params *PaymentIntentParams) (*PaymentIntentResponse, error)

Creates new PaymentIntent with specified parameters, as explained in stripe API

func (*StripeClient) PaymentIntentAction

func (sc *StripeClient) PaymentIntentAction(p *PaymentIntent, action string) (*PaymentIntentResponse, error)

func (*StripeClient) UpdatePaymentIntent

func (sc *StripeClient) UpdatePaymentIntent(p *PaymentIntent) (*PaymentIntentResponse, error)

type StripeRequestError

type StripeRequestError struct {
	StatusCode uint
	Err        error
}

func (*StripeRequestError) Error

func (err *StripeRequestError) Error() string

Jump to

Keyboard shortcuts

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