buyte

package
v0.0.0-...-cb7f019 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FULL_CHECKOUT = "fullCheckout"
	CHARGE        = "charge"
	PAYMENT_TOKEN = "token"
)
View Source
const (
	APPLE_PAY  = "Apple Pay"
	GOOGLE_PAY = "Google Pay"
)
View Source
const (
	STRIPE = "STRIPE"
	ADYEN  = "ADYEN"
)

Payment Gateway Types

Variables

This section is empty.

Functions

func EnsureJSON

func EnsureJSON(value interface{}) (string, error)

Some Util

Types

type AWSConfig

type AWSConfig struct {
	Region                string `env:"AWS_REGION" envDefault:"ap-southeast-2"`
	APIGatewayId          string `env:"API_GATEWAY_ID"`
	APIGatewayName        string `env:"API_GATEWAY_NAME"`
	APIGatewayStage       string `env:"API_GATEWAY_STAGE"`
	APIGatewayUsagePlanId string `env:"API_GATEWAY_USAGE_PLAN_ID"`
	CognitoUserPoolId     string `env:"COGNITO_USERPOOLID"`
	CognitoClientId       string `env:"COGNITO_CLIENTID"`
}

Compatible with "github.com/caarlos0/env"

func NewEnvConfig

func NewEnvConfig() *AWSConfig

type ApplePayAuthorizedPaymentResponse

type ApplePayAuthorizedPaymentResponse struct {
	AuthorizedPaymentResponse
	Result *applepay.Response `json:"result"`
}

type ApplePayPaymentToken

type ApplePayPaymentToken struct {
	*PaymentToken
	Response *applepay.Response `json:"response"`
}

type AuthorizedPaymentResponse

type AuthorizedPaymentResponse struct {
	CheckoutId        string                                   `json:"checkoutId"`
	PaymentMethodId   string                                   `json:"paymentMethodId"`
	ShippingMethod    *AuthorizedPaymentResponseShippingMethod `json:"shippingMethod,omitempty"`
	Amount            int                                      `json:"amount"`
	Currency          string                                   `json:"currency"`
	Country           string                                   `json:"country"`
	RawPaymentRequest map[string]interface{}                   `json:"rawPaymentRequest,omitempty"`
}

type AuthorizedPaymentResponseShippingMethod

type AuthorizedPaymentResponseShippingMethod struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
	Rate        int    `json:"rate"`
	MinOrder    int    `json:"minOrder"`
	MaxOrder    int    `json:"maxOrder,omitempty"`
}

type Charge

type Charge struct {
	ID             string                 `json:"id"`
	Object         string                 `json:"object"`
	Source         *ChargeSource          `json:"source"`
	Amount         int                    `json:"amount"`
	FeeAmount      int                    `json:"feeAmount"`
	Currency       string                 `json:"currency"`
	Captured       bool                   `json:"captured"`
	ProviderCharge *GatewayCharge         `json:"providerCharge,omitempty"`
	Description    string                 `json:"description"`
	Customer       *Customer              `json:"customer"`
	Metadata       map[string]interface{} `json:"metadata"`
	Order          *ChargeOrder           `json:"order,omitempty"`
	CreatedAt      string                 `json:"createdAt"`
}

type ChargeOrder

type ChargeOrder struct {
	Reference string                   `json:"reference,omitempty"`
	Platform  string                   `json:"platform,omitempty"`
	Items     []map[string]interface{} `json:"items,omitempty"`
	Shipping  map[string]interface{}   `json:"shipping,omitempty"`
	Customer  map[string]interface{}   `json:"customer,omitempty"`
}

func (*ChargeOrder) AddItem

func (co *ChargeOrder) AddItem(item map[string]interface{})

type ChargeSource

type ChargeSource struct {
	ID                     string                        `json:"id"`
	PaymentMethod          *PaymentMethod                `json:"paymentMethod"`
	ShippingMethod         *PaymentTokenShipping         `json:"shippingMethod,omitempty"`
	SelectedShippingMethod *PaymentTokenSelectedShipping `json:"selectedShippingMethod,omitempty"`
	Checkout               *PaymentTokenBaseCheckout     `json:"checkout"`
}

type ChargeStore

type ChargeStore interface {
	CreateCharge(context.Context, *CreateChargeParams) (*Charge, error)
	GetCharge(context.Context, string) (*Charge, error)
}

type CheckoutStore

type CheckoutStore interface {
	GetFullCheckout(context.Context, string, *FullCheckoutOptions) (*FullCheckout, error)
}

type CreateChargeInput

type CreateChargeInput struct {
	Source      string                 `json:"source"`
	Amount      int                    `json:"amount"`
	FeeAmount   int                    `json:"feeAmount"`
	Currency    string                 `json:"currency"`
	Capture     *bool                  `json:"capture"`
	Description string                 `json:"description"`
	Metadata    map[string]interface{} `json:"metadata"`
	Order       ChargeOrder            `json:"order"`
}

Represents the Request Body data sent in POST /charges request.

func (*CreateChargeInput) SetFee

func (c *CreateChargeInput) SetFee(feeMultiplier float64, region string)

type CreateChargeOrderParams

type CreateChargeOrderParams struct {
	Reference string `json:"reference,omitempty"`
	Platform  string `json:"platform,omitempty"`
	Items     string `json:"items,omitempty"`
	Shipping  string `json:"shipping,omitempty"`
	Customer  string `json:"customer,omitempty"`
}

func (*CreateChargeOrderParams) SetCustomer

func (c *CreateChargeOrderParams) SetCustomer(data interface{}) error

func (*CreateChargeOrderParams) SetItems

func (c *CreateChargeOrderParams) SetItems(data interface{}) error

func (*CreateChargeOrderParams) SetShipping

func (c *CreateChargeOrderParams) SetShipping(data interface{}) error

type CreateChargeParams

type CreateChargeParams struct {
	ID             string                   `json:"id"`
	Source         string                   `json:"chargeSourceId"` // This is the payment token id.
	Amount         int                      `json:"amount"`
	FeeAmount      int                      `json:"feeAmount"`
	Currency       string                   `json:"currency"`
	Captured       bool                     `json:"captured"`
	Description    string                   `json:"description,omitempty"`
	Metadata       string                   `json:"metadata,omitempty"`
	ProviderCharge *GatewayCharge           `json:"providerCharge"`
	Customer       *Customer                `json:"customer"`
	Order          *CreateChargeOrderParams `json:"order,omitempty"`
	CreatedAt      string                   `json:"createdAt"`
}

Represent request body to GraphQL API to create a charge

func (*CreateChargeParams) SetFee

func (c *CreateChargeParams) SetFee(feeMultiplier float64, region string)

func (*CreateChargeParams) SetMetadata

func (c *CreateChargeParams) SetMetadata(data interface{}) error

func (*CreateChargeParams) SetOrder

func (c *CreateChargeParams) SetOrder(co *ChargeOrder) error

func (*CreateChargeParams) SetProviderCharge

func (c *CreateChargeParams) SetProviderCharge(gc *GatewayCharge)

type CreatePaymentTokenInput

type CreatePaymentTokenInput struct {
	ID                string                        `json:"id"`
	Value             interface{}                   `json:"value"`
	CheckoutId        string                        `json:"paymentTokenCheckoutId"`
	PaymentMethodId   string                        `json:"paymentTokenPaymentMethodId"`
	ShippingMethodId  string                        `json:"paymentTokenShippingMethodId,omitempty"`
	ShippingMethod    *PaymentTokenSelectedShipping `json:"selectedShippingMethod,omitempty"`
	Amount            int                           `json:"amount"`
	Currency          string                        `json:"currency"`
	Country           string                        `json:"country"`
	RawPaymentRequest interface{}                   `json:"rawPaymentRequest,omitempty"`
}

func NewApplePayPaymentTokenInput

func NewApplePayPaymentTokenInput(response *ApplePayAuthorizedPaymentResponse) *CreatePaymentTokenInput

NewApplePayPaymentTokenInput Sets result of Authed Payment Response as the value

func NewGooglePayPaymentTokenInput

func NewGooglePayPaymentTokenInput(response *GooglePayAuthorizedPaymentResponse) *CreatePaymentTokenInput

NewApplePayPaymentTokenInput Sets result of Authed Payment Response as the value

func NewPaymentTokenInput

func NewPaymentTokenInput(response *AuthorizedPaymentResponse) *CreatePaymentTokenInput

func (*CreatePaymentTokenInput) Format

func (i *CreatePaymentTokenInput) Format() error

Format Payment Token Input

type Customer

type Customer struct {
	Name            string           `json:"name,omitempty"`
	GivenName       string           `json:"givenName,omitempty"`
	FamilyName      string           `json:"familyName,omitempty"`
	EmailAddress    string           `json:"emailAddress,omitempty"`
	PhoneNumber     string           `json:"phoneNumber,omitempty"`
	ShippingAddress *CustomerAddress `json:"shippingAddress,omitempty"`
	BillingAddress  *CustomerAddress `json:"billingAddress,omitempty"`
}

func (*Customer) SetBillingAddress

func (c *Customer) SetBillingAddress(address *CustomerAddress)

func (*Customer) SetShippingAddress

func (c *Customer) SetShippingAddress(address *CustomerAddress)

type CustomerAddress

type CustomerAddress struct {
	AddressLines          []string `json:"addressLines,omitempty"`
	AdministrativeArea    string   `json:"administrativeArea,omitempty"`
	Country               string   `json:"country,omitempty"`
	CountryCode           string   `json:"countryCode,omitempty"`
	Locality              string   `json:"locality,omitempty"`
	PostalCode            string   `json:"postalCode,omitempty"`
	SubAdministrativeArea string   `json:"subAdministrativeArea,omitempty"`
	SubLocality           string   `json:"subLocality,omitempty"`
}

func (*CustomerAddress) Filter

func (c *CustomerAddress) Filter()

Filter address lines and other other array of empty values.

func (*CustomerAddress) IsEmpty

func (c *CustomerAddress) IsEmpty() bool

Check if all values are empty

type FullCheckout

type FullCheckout struct {
	ID              string                       `json:"id"`
	Object          string                       `json:"object"`
	Options         []FullCheckoutOptionResponse `json:"options"`
	ShippingMethods []FullCheckoutShippingMethod `json:"shippingMethods"`
	GatewayProvider FullCheckoutGatewayProvider  `json:"gatewayProvider"`
	Currency        string                       `json:"currency"`
	Country         string                       `json:"country"`
	Merchant        FullCheckoutMerchant         `json:"merchant"`
	CustomCSS       string                       `json:"customCss"`
}

type FullCheckoutGatewayProvider

type FullCheckoutGatewayProvider struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	PublicKey string `json:"publicKey"`
	IsTest    bool   `json:"isTest"`
}

type FullCheckoutMerchant

type FullCheckoutMerchant struct {
	StoreName  string `json:"storeName"`
	Website    string `json:"website"`
	CoverImage string `json:"coverImage"`
}

type FullCheckoutOptionResponse

type FullCheckoutOptionResponse struct {
	ID             string            `json:"id"`
	Name           string            `json:"name"`
	Image          string            `json:"image"`
	AdditionalData map[string]string `json:"additionalData,omitempty"`
}

Public Load Full Checkout Widget Response

type FullCheckoutOptions

type FullCheckoutOptions struct {
	UserCountryCode string
}

type FullCheckoutShippingMethod

type FullCheckoutShippingMethod struct {
	ID          string      `json:"id"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Rate        int         `json:"rate"`
	MinOrder    int         `json:"minOrder"`
	MaxOrder    interface{} `json:"maxOrder,omitempty"`
}

type Gateway

type Gateway struct {
	Type        string             `json:"type"`
	IsTest      bool               `json:"isTest"`
	Credentials interface{}        `json:"credentials"`
	Context     context.Context    `json:"-"`
	Logger      *zap.SugaredLogger `json:"-"`
}

type GatewayCharge

type GatewayCharge struct {
	Reference string `json:"reference"`
	Type      string `json:"type"`
}

type GooglePayAuthorizedPaymentResponse

type GooglePayAuthorizedPaymentResponse struct {
	AuthorizedPaymentResponse
	Result *googlepay.Response `json:"result"`
}

type GooglePayPaymentToken

type GooglePayPaymentToken struct {
	*PaymentToken
	Response *googlepay.Response `json:"response"`
}

type NetworkToken

type NetworkToken struct {
	*applepay.Token
}

func (*NetworkToken) ExpMonth

func (n *NetworkToken) ExpMonth() string

Network Token applicationExpirationDate is in YYMMDD format ApplicationExpirationDate https://www.emvlab.org/emvtags/show/t5F24/

func (*NetworkToken) ExpYear

func (n *NetworkToken) ExpYear() string

type PaymentMethod

type PaymentMethod struct {
	Name string `json:"name"`
}

type PaymentToken

type PaymentToken struct {
	ID                     string                        `json:"id"`
	Object                 string                        `json:"object"`
	Value                  string                        `json:"value"`
	PaymentMethod          *PaymentMethod                `json:"paymentMethod"`
	Amount                 int                           `json:"amount"`
	Currency               string                        `json:"currency"`
	ShippingMethod         *PaymentTokenShipping         `json:"shippingMethod,omitempty"`
	SelectedShippingMethod *PaymentTokenSelectedShipping `json:"selectedShippingMethod,omitempty"`
	Checkout               *PaymentTokenCheckout         `json:"checkout"`
}

func (*PaymentToken) ApplePay

func (p *PaymentToken) ApplePay() (*ApplePayPaymentToken, error)

func (*PaymentToken) Customer

func (p *PaymentToken) Customer() *Customer

func (*PaymentToken) Format

func (p *PaymentToken) Format() (interface{}, error)

func (*PaymentToken) GooglePay

func (p *PaymentToken) GooglePay() (*GooglePayPaymentToken, error)

func (*PaymentToken) IsApplePay

func (p *PaymentToken) IsApplePay() bool

func (*PaymentToken) IsGooglePay

func (p *PaymentToken) IsGooglePay() bool

func (*PaymentToken) IsRejectedSigningTimeDelta

func (p *PaymentToken) IsRejectedSigningTimeDelta(err error) bool

type PaymentTokenBaseCheckout

type PaymentTokenBaseCheckout struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
}

type PaymentTokenCheckout

type PaymentTokenCheckout struct {
	ID          string                      `json:"id"`
	Label       string                      `json:"label"`
	Description string                      `json:"description,omitempty"`
	Connection  *ProviderCheckoutConnection `json:"connection,omitempty"`
}

type PaymentTokenSelectedShipping

type PaymentTokenSelectedShipping struct {
	ID          string `json:"reference" mapstructure:"reference"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
	Rate        int    `json:"rate"`
	MinOrder    int    `json:"minOrderPrice,omitempty" mapstructure:"minOrderPrice"`
	MaxOrder    int    `json:"maxOrderPrice,omitempty" mapstructure:"maxOrderPrice"`
}

type PaymentTokenShipping

type PaymentTokenShipping struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
	Rate        int    `json:"rate"`
	MinOrder    int    `json:"minOrderPrice,omitempty" mapstructure:"minOrderPrice"`
	MaxOrder    int    `json:"maxOrderPrice,omitempty" mapstructure:"maxOrderPrice"`
}

func CopySelectedShippingMethodToShippingMethod

func CopySelectedShippingMethodToShippingMethod(selected *PaymentTokenSelectedShipping) *PaymentTokenShipping

Copy selected shipping data to ShippingMethod.

type PaymentTokenStore

type PaymentTokenStore interface {
	CreatePaymentToken(context.Context, *CreatePaymentTokenInput) (*PaymentToken, error)
	GetPaymentToken(context.Context, string) (*PaymentToken, error)
}

type ProviderCheckoutConnection

type ProviderCheckoutConnection struct {
	Type        string                                    `json:"type"`
	IsTest      bool                                      `json:"isTest"`
	Credentials string                                    `json:"credentials"`
	Provider    ProviderCheckoutConnectionProviderDetails `json:"provider"`
}

type ProviderCheckoutConnectionProviderDetails

type ProviderCheckoutConnectionProviderDetails struct {
	Name string `json:"name"`
}

type PublicPaymentToken

type PublicPaymentToken struct {
	ID       string `json:"id"`
	Object   string `json:"object"`
	Amount   int    `json:"amount"`
	Currency string `json:"currency"`
}

type Store

type Store interface {
	CheckoutStore
	PaymentTokenStore
	ChargeStore
}

Create a overarching store that inherits all methods of sub store interfaces

Jump to

Keyboard shortcuts

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