amazonpay

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion = "v2"
)
View Source
const (
	SDKVersion = "2.2.1"
)

Variables

View Source
var (
	RegionMap = map[string]string{
		"eu": "eu",
		"de": "eu",
		"uk": "eu",
		"us": "na",
		"na": "na",
		"jp": "jp",
	}
	RegionHostMap = map[string]string{
		"eu": "pay-api.amazon.eu",
		"na": "pay-api.amazon.com",
		"jp": "pay-api.amazon.jp",
	}
)

Functions

func Bool

func Bool(v bool) *bool

Bool bool to pointer function

func Int

func Int(v int) *int

Int int to pointer function

func Int64

func Int64(v int64) *int64

Int64 int64 to pointer function

func MustParseInt64

func MustParseInt64(v string) int64

MustParseInt64 string to int64 without error function

func ParseInt64

func ParseInt64(v string) (int64, error)

ParseInt64 string to int64 function

func String

func String(v string) *string

String string to pointer function

Types

type AddressDetails

type AddressDetails struct {
	Name          string `json:"name,omitempty"`
	AddressLine1  string `json:"addressLine1,omitempty"`
	AddressLine2  string `json:"addressLine2,omitempty"`
	AddressLine3  string `json:"addressLine3,omitempty"`
	City          string `json:"city,omitempty"`
	County        string `json:"county,omitempty"`
	District      string `json:"district,omitempty"`
	StateOrRegion string `json:"stateOrRegion,omitempty"`
	PostalCode    string `json:"postalCode,omitempty"`
	CountryCode   string `json:"countryCode,omitempty"`
	PhoneNumber   string `json:"phoneNumber,omitempty"`
}

type Buyer

type Buyer struct {
	BuyerID         string `json:"buyerId,omitempty"`
	Name            string `json:"name,omitempty"`
	Email           string `json:"email,omitempty"`
	PostalCode      string `json:"postalCode,omitempty"`
	ShippingAddress AddressDetails
	PhoneNumber     string `json:"phoneNumber,omitempty"`
}

type ChargePermissionResponse

type ChargePermissionResponse struct {
	ErrorResponse
	ChargePermissionID          string              `json:"chargePermissionId,omitempty"`
	ChargePermissionReferenceID string              `json:"chargePermissionReferenceId,omitempty"`
	Buyer                       *Buyer              `json:"buyer,omitempty"`
	ReleaseEnvironment          string              `json:"releaseEnvironment,omitempty"`
	ShippingAddress             *AddressDetails     `json:"shippingAddress,omitempty"`
	BillingAddress              *AddressDetails     `json:"billingAddress,omitempty"`
	PaymentPreferences          []PaymentPreference `json:"paymentPreferences,omitempty"`
	StatusDetails               *StatusDetails      `json:"statusDetails,omitempty"`
	CreationTimestamp           string              `json:"creationTimestamp,omitempty"`
	ExpirationTimestamp         string              `json:"expirationTimestamp,omitempty"`
	MerchantMetadata            *MerchantMetadata   `json:"merchantMetadata,omitempty"`
	PlatformID                  string              `json:"platformId,omitempty"`
	Limits                      *Limits             `json:"limits,omitempty"`
	PresentmentCurrency         string              `json:"presentmentCurrency,omitempty"`
}

type CheckoutSessionResponse

type CheckoutSessionResponse struct {
	ErrorResponse
	CheckoutSessionID      string                  `json:"checkoutSessionId,omitempty"`
	WebCheckoutDetails     *WebCheckoutDetails     `json:"webCheckoutDetails,omitempty"`
	ChargePermissionType   string                  `json:"chargePermissionType,omitempty"`
	RecurringMetadata      *RecurringMetadata      `json:"recurringMetadata,omitempty"`
	ProductType            string                  `json:"productType,omitempty"`
	PaymentDetails         *PaymentDetails         `json:"paymentDetails,omitempty"`
	MerchantMetadata       *MerchantMetadata       `json:"merchantMetadata,omitempty"`
	Buyer                  *Buyer                  `json:"buyer,omitempty"`
	BillingAddress         *AddressDetails         `json:"billingAddress,omitempty"`
	PaymentPreferences     []PaymentPreference     `json:"paymentPreferences,omitempty"`
	StatusDetails          *StatusDetails          `json:"statusDetails,omitempty"`
	ShippingAddress        *AddressDetails         `json:"shippingAddress,omitempty"`
	PlatformID             string                  `json:"platformId,omitempty"`
	ChargePermissionID     string                  `json:"chargePermissionId,omitempty"`
	ChargeID               string                  `json:"chargeId,omitempty"`
	Constraints            []Constraint            `json:"constraints,omitempty"`
	CreationTimestamp      string                  `json:"creationTimestamp,omitempty"`
	ExpirationTimestamp    string                  `json:"expirationTimestamp,omitempty"`
	StoreID                string                  `json:"storeId,omitempty"`
	DeliverySpecifications *DeliverySpecifications `json:"deliverySpecifications,omitempty"`
	ProviderMetadata       *ProviderMetadata       `json:"providerMetadata,omitempty"`
	ReleaseEnvironment     string                  `json:"releaseEnvironment,omitempty"`
}

type Client

type Client struct {
	PublicKeyID string
	PrivateKey  []byte
	Region      string
	Sandbox     bool
	HTTPClient  *http.Client
	// contains filtered or unexported fields
}

Client type

func New

func New(publicKeyID string, privateKey []byte, region string, sandbox bool, httpClient *http.Client) (*Client, error)

New returns a new pay client instance.

func (*Client) CloseChargePermission

func (c *Client) CloseChargePermission(ctx context.Context, chargePermissionID string, req *CloseChargePermissionRequest) (*CloseChargePermissionResponse, *http.Response, error)

func (*Client) CompleteCheckoutSession

func (c *Client) CompleteCheckoutSession(ctx context.Context, checkoutSessionID string, req *CompleteCheckoutSessionRequest) (*CompleteCheckoutSessionResponse, *http.Response, error)

func (*Client) CreateCharge

func (*Client) CreateRefund

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do method

func (*Client) GenerateButtonSignature

func (c *Client) GenerateButtonSignature(payload string) (string, error)

GenerateButtonSignature method

func (*Client) GetChargePermission

func (c *Client) GetChargePermission(ctx context.Context, chargePermissionID string) (*GetChargePermissionResponse, *http.Response, error)

func (*Client) GetCheckoutSession

func (c *Client) GetCheckoutSession(ctx context.Context, checkoutSessionID string) (*GetCheckoutSessionResponse, *http.Response, error)

func (*Client) GetRefund

func (c *Client) GetRefund(ctx context.Context, refundID string) (*GetRefundResponse, *http.Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)

NewRequest method

func (*Client) UpdateCheckoutSession

func (c *Client) UpdateCheckoutSession(ctx context.Context, checkoutSessionID string, req *UpdateCheckoutSessionRequest) (*UpdateCheckoutSessionResponse, *http.Response, error)

type CloseChargePermissionRequest

type CloseChargePermissionRequest struct {
	ClosureReason        string `json:"closureReason,omitempty"`
	CancelPendingCharges *bool  `json:"cancelPendingCharges,omitempty"`
}

type CloseChargePermissionResponse

type CloseChargePermissionResponse ChargePermissionResponse

type CompleteCheckoutSessionRequest

type CompleteCheckoutSessionRequest struct {
	ChargeAmount *Price `json:"chargeAmount,omitempty"`
}

type CompleteCheckoutSessionResponse

type CompleteCheckoutSessionResponse CheckoutSessionResponse

type Constraint

type Constraint struct {
	ConstraintID string `json:"constraintId,omitempty"`
	Description  string `json:"description,omitempty"`
}

type CreateChargeRequest

type CreateChargeRequest struct {
	ChargePermissionID            string            `json:"chargePermissionId,omitempty"`
	ChargeAmount                  *Price            `json:"chargeAmount,omitempty"`
	CaptureNow                    *bool             `json:"captureNow,omitempty"`
	SoftDescriptor                string            `json:"softDescriptor,omitempty"`
	CanHandlePendingAuthorization *bool             `json:"canHandlePendingAuthorization,omitempty"`
	MerchantMetadata              *MerchantMetadata `json:"merchantMetadata,omitempty"`
	ProviderMetadata              *ProviderMetadata `json:"providerMetadata,omitempty"`
}

type CreateChargeResponse

type CreateChargeResponse struct {
	ErrorResponse
	ChargeID            string            `json:"chargeId,omitempty"`
	ChargePermissionID  string            `json:"chargePermissionId,omitempty"`
	ChargeAmount        *Price            `json:"chargeAmount,omitempty"`
	CaptureAmount       *Price            `json:"captureAmount,omitempty"`
	RefundedAmount      *Price            `json:"refundedAmount,omitempty"`
	ConvertedAmount     string            `json:"convertedAmount,omitempty"`
	ConversionRate      string            `json:"conversionRate,omitempty"`
	SoftDescriptor      string            `json:"softDescriptor,omitempty"`
	MerchantMetadata    *MerchantMetadata `json:"merchantMetadata,omitempty"`
	ProviderMetadata    *ProviderMetadata `json:"providerMetadata,omitempty"`
	StatusDetails       *StatusDetails    `json:"statusDetails,omitempty"`
	CreationTimestamp   string            `json:"creationTimestamp,omitempty"`
	ExpirationTimestamp string            `json:"expirationTimestamp,omitempty"`
	ReleaseEnvironment  string            `json:"releaseEnvironment,omitempty"`
}

type CreateCheckoutSessionRequest

type CreateCheckoutSessionRequest struct {
	WebCheckoutDetails     *WebCheckoutDetails     `json:"webCheckoutDetails,omitempty"`
	StoreID                string                  `json:"storeId,omitempty"`
	ChargePermissionType   string                  `json:"chargePermissionType,omitempty"`
	RecurringMetadata      *RecurringMetadata      `json:"recurringMetadata,omitempty"`
	DeliverySpecifications *DeliverySpecifications `json:"deliverySpecifications,omitempty"`
	PaymentDetails         *PaymentDetails         `json:"paymentDetails,omitempty"`
	MerchantMetadata       *MerchantMetadata       `json:"merchantMetadata,omitempty"`
	PlatformID             string                  `json:"platformId,omitempty"`
	ProviderMetadata       *ProviderMetadata       `json:"providerMetadata,omitempty"`
	AddressDetails         *AddressDetails         `json:"addressDetails,omitempty"`
}

func (*CreateCheckoutSessionRequest) ToPayload

func (c *CreateCheckoutSessionRequest) ToPayload() (string, error)

type CreateRefundRequest

type CreateRefundRequest struct {
	ChargeID       string `json:"chargeId,omitempty"`
	RefundAmount   *Price `json:"refundAmount,omitempty"`
	SoftDescriptor string `json:"softDescriptor,omitempty"`
}

type CreateRefundResponse

type CreateRefundResponse RefundResponse

type DeliverySpecifications

type DeliverySpecifications struct {
	SpecialRestrictions []string `json:"specialRestrictions,omitempty"`
	AddressRestrictions struct {
		Type         string `json:"type,omitempty"`
		Restrictions struct {
			US struct {
				StatesOrRegions []string `json:"statesOrRegions,omitempty"`
				ZipCodes        []string `json:"zipCodes,omitempty"`
			} `json:"US,omitempty"`
			GB struct {
				ZipCodes []string `json:"zipCodes,omitempty"`
			} `json:"GB,omitempty"`
			IN struct {
				StatesOrRegions []string `json:"statesOrRegions,omitempty"`
			} `json:"IN,omitempty"`
			JP struct {
			} `json:"JP,omitempty"`
		} `json:"restrictions,omitempty"`
	} `json:"addressRestrictions,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	ReasonCode string `json:"reasonCode,omitempty"`
	Message    string `json:"message,omitempty"`
}

type Frequency

type Frequency struct {
	Unit  string `json:"unit,omitempty"`
	Value string `json:"value,omitempty"`
}

type GetChargePermissionResponse

type GetChargePermissionResponse ChargePermissionResponse

type GetCheckoutSessionResponse

type GetCheckoutSessionResponse CheckoutSessionResponse

type GetRefundResponse

type GetRefundResponse RefundResponse

type Limits

type Limits struct {
	AmountLimit   *Price `json:"amountLimit,omitempty"`
	AmountBalance *Price `json:"amountBalance,omitempty"`
}

type MerchantMetadata

type MerchantMetadata struct {
	MerchantReferenceID string `json:"merchantReferenceId,omitempty"`
	MerchantStoreName   string `json:"merchantStoreName,omitempty"`
	NoteToBuyer         string `json:"noteToBuyer,omitempty"`
	CustomInformation   string `json:"customInformation,omitempty"`
}

type PaymentDetails

type PaymentDetails struct {
	PaymentIntent                 string `json:"paymentIntent,omitempty"`
	CanHandlePendingAuthorization *bool  `json:"canHandlePendingAuthorization,omitempty"`
	ChargeAmount                  *Price `json:"chargeAmount,omitempty"`
	TotalOrderAmount              *Price `json:"totalOrderAmount,omitempty"`
	SoftDescriptor                string `json:"softDescriptor,omitempty"`
	PresentmentCurrency           string `json:"presentmentCurrency,omitempty"`
	AllowOvercharge               *bool  `json:"allowOvercharge,omitempty"`
	ExtendExpiration              *bool  `json:"extendExpiration,omitempty"`
}

type PaymentPreference

type PaymentPreference struct {
	PaymentDescriptor string `json:"paymentDescriptor,omitempty"`
}

type Price

type Price struct {
	Amount       string `json:"amount,omitempty"`
	CurrencyCode string `json:"currencyCode,omitempty"`
}

type ProviderMetadata

type ProviderMetadata struct {
	ProviderReferenceID string `json:"providerReferenceId,omitempty"`
}

type Reason

type Reason struct {
	ReasonCode        string `json:"reasonCode,omitempty"`
	ReasonDescription string `json:"reasonDescription,omitempty"`
}

type RecurringMetadata

type RecurringMetadata struct {
	Frequency *Frequency `json:"frequency,omitempty"`
	Amount    *Price     `json:"amount,omitempty"`
}

type RefundResponse

type RefundResponse struct {
	ErrorResponse
	RefundID           string         `json:"refundId,omitempty"`
	ChargeID           string         `json:"chargeId,omitempty"`
	RefundAmount       *Price         `json:"refundAmount,omitempty"`
	SoftDescriptor     string         `json:"softDescriptor,omitempty"`
	CreationTimestamp  string         `json:"creationTimestamp,omitempty"`
	StatusDetails      *StatusDetails `json:"statusDetails,omitempty"`
	ReleaseEnvironment string         `json:"releaseEnvironment,omitempty"`
}

type StatusDetails

type StatusDetails struct {
	State string `json:"state,omitempty"`
	// https://amazonpaycheckoutintegrationguide.s3.amazonaws.com/amazon-pay-api-v2/checkout-session.html#type-statusdetails
	ReasonCode        string `json:"reasonCode,omitempty"`
	ReasonDescription string `json:"reasonDescription,omitempty"`
	// https://amazonpaycheckoutintegrationguide.s3.amazonaws.com/amazon-pay-api-v2/charge-permission.html#type-statusdetails
	Reasons              []Reason `json:"reasons,omitempty"`
	LastUpdatedTimestamp string   `json:"lastUpdatedTimestamp,omitempty"`
}

type UpdateCheckoutSessionRequest

type UpdateCheckoutSessionRequest struct {
	WebCheckoutDetails *WebCheckoutDetails `json:"webCheckoutDetails,omitempty"`
	PaymentDetails     *PaymentDetails     `json:"paymentDetails,omitempty"`
	MerchantMetadata   *MerchantMetadata   `json:"merchantMetadata,omitempty"`
}

type UpdateCheckoutSessionResponse

type UpdateCheckoutSessionResponse CheckoutSessionResponse

type WebCheckoutDetails

type WebCheckoutDetails struct {
	CheckoutReviewReturnURL string `json:"checkoutReviewReturnUrl,omitempty"`
	CheckoutResultReturnURL string `json:"checkoutResultReturnUrl,omitempty"`
	AmazonPayRedirectURL    string `json:"amazonPayRedirectUrl,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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