package module
Version: v1.0.4 Latest Latest

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 10 Imported by: 0



Unofficial Go Client SDK for the Primer APIs


To install, please execute the following go get command.

go get




This section is empty.


View Source
var (
	ErrCredentialsMissing     = errors.New("API Key credentials missing")
	ErrBaseURLMissing         = errors.New("base URL missing")
	ErrXIdempotencyKeyMissing = errors.New("X-Idempotency-Key missing")


This section is empty.


type Address

type Address struct {
	AddressLine1 string  `json:"addressLine1"`
	City         string  `json:"city"`
	CountryCode  string  `json:"countryCode"`
	PostalCode   string  `json:"postalCode"`
	FirstName    *string `json:"firstName,omitempty"`
	LastName     *string `json:"lastName,omitempty"`
	AddressLine2 *string `json:"addressLine2,omitempty"`
	State        *string `json:"state,omitempty"`

Address ...

type BaseDTO

type BaseDTO struct {
	RequestID       *string `json:"requestId,omitempty"`
	XIdempotencyKey *string `json:"xIdempotencyKey,omitempty"`

BaseDTO ...

func (*BaseDTO) SetRequestID

func (b *BaseDTO) SetRequestID(id string)

type BillingAddress

type BillingAddress struct {

BillingAddress ...

type BinData

type BinData struct {
	Network                    string  `json:"network"`
	RegionalRestriction        string  `json:"regionalRestriction"`
	AccountNumberType          string  `json:"accountNumberType"`
	AccountFundingType         string  `json:"accountFundingType"`
	PrepaidReloadableIndicator string  `json:"prepaidReloadableIndicator"`
	ProductUsageType           string  `json:"productUsageType"`
	ProductCode                string  `json:"productCode"`
	ProductName                string  `json:"productName"`
	IssuerCountryCode          *string `json:"issuerCountryCode,omitempty"`
	IssuerName                 *string `json:"issuerName,omitempty"`
	IssuerCurrencyCode         *string `json:"issuerCurrencyCode,omitempty"`

BinData ...

type CancelPayment

type CancelPayment struct {
	Reason string `json:"reason"`

CancelPayment ...

type CancelPaymentRequest

type CancelPaymentRequest struct {

CancelPaymentRequest ...

type CapturePayment

type CapturePayment struct {
	Amount int64 `json:"amount"`
	Final  bool  `json:"final"`

CapturePayment ...

type CapturePaymentRequest

type CapturePaymentRequest struct {

CapturePaymentRequest ...

type Client

type Client struct {
	// contains filtered or unexported fields

Client will be used to make requests to Primer APIs

func NewClient

func NewClient(options ...ClientOption) (*Client, error)

NewClient constructs a new Client which can make requests to the Primer APIs.

func (*Client) CancelPayment

func (c *Client) CancelPayment(ctx context.Context, req *CancelPaymentRequest, paymentId string) (*PaymentResponse, error)

func (*Client) CapturePayment

func (c *Client) CapturePayment(ctx context.Context, req *CapturePaymentRequest, paymentId string) (*PaymentResponse, error)

func (*Client) CreatePayment

func (c *Client) CreatePayment(ctx context.Context, req *CreatePaymentRequest) (*PaymentResponse, error)

func (*Client) GetPayment

func (c *Client) GetPayment(ctx context.Context, req *GetPaymentRequest, paymentId string) (*PaymentResponse, error)

func (*Client) RefundPayment

func (c *Client) RefundPayment(ctx context.Context, req *RefundPaymentRequest, paymentId string) (*PaymentResponse, error)

func (*Client) ResumePayment

func (c *Client) ResumePayment(ctx context.Context, req *ResumePaymentRequest, paymentId string) (*PaymentResponse, error)

type ClientOption

type ClientOption func(*Client) error

ClientOption constructor parameter for NewClient(...)

func WithAPIKey

func WithAPIKey(apiKey string) ClientOption

WithAPIKey configures a Primer API client with an API Key

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL configures a Primer API client with a custom base url

func WithHTTPClient

func WithHTTPClient(c *http.Client) ClientOption

WithHTTPClient configures a Primer API client with a http.Client to make requests over.

type CreatePayment

type CreatePayment struct {
	OrderID             string             `json:"orderId"`
	CurrencyCode        string             `json:"currencyCode"`
	Amount              int64              `json:"amount"`
	PaymentInstrument   PaymentInstrument  `json:"paymentInstrument"`
	StatementDescriptor *string            `json:"statementDescriptor,omitempty"`
	Customer            *Customer          `json:"customer,omitempty"`
	Metadata            *map[string]string `json:"metadata,omitempty"`

PaymentRequest ...

type CreatePaymentRequest

type CreatePaymentRequest struct {

CreatePaymentRequest ...

type Customer

type Customer struct {
	ID              string           `json:"id"`
	Email           *string          `json:"email,omitempty"`
	BillingAddress  *BillingAddress  `json:"billingAddress,omitempty"`
	ShippingAddress *ShippingAddress `json:"shippingAddress,omitempty"`

Customer ...

type DTO

type DTO interface {
	SetRequestID(id string)

DTO ...

type Data

type Data struct {
	ID           string    `json:"id"`
	Date         time.Time `json:"date"`
	Status       string    `json:"status"`
	OrderID      string    `json:"orderId"`
	CurrencyCode string    `json:"currencyCode"`
	Amount       int64     `json:"amount"`
	Processor    *string   `json:"processor,omitempty"`

Data ...

type Error

type Error struct {
	Status    int    `json:"status,omitempty"`
	Message   string `json:"message,omitempty"`
	RequestID string `json:"requestID,omitempty"`

Error is the conventional GrabExpress client error

func (*Error) Error

func (e *Error) Error() string

Error returns error message. This enables grabexpress.Error to comply with Go error interface

type GetPaymentRequest

type GetPaymentRequest struct {

GetPaymentRequest ...

type Payment

type Payment struct {
	ID                       string                    `json:"id"`
	Date                     time.Time                 `json:"date"`
	Status                   string                    `json:"status"`
	OrderID                  string                    `json:"orderId"`
	CurrencyCode             string                    `json:"currencyCode"`
	Amount                   int64                     `json:"amount"`
	AmountAuthorized         int64                     `json:"amountAuthorized"`
	AmountCapture            int64                     `json:"amountCaptured"`
	AmountRefunded           int64                     `json:"amountRefunded"`
	PaymentInstrument        PaymentInstrument         `json:"paymentInstrument"`
	Transactions             []Transaction             `json:"transactions"`
	Processor                *string                   `json:"processor,omitempty"`
	RequiredAction           *RequiredAction           `json:"requiredAction,omitempty"`
	StatementDescriptor      *string                   `json:"statementDescriptor,omitempty"`
	VaultedPaymentInstrument *VaultedPaymentInstrument `json:"vaultedPaymentInstrument,omitempty"`
	Customer                 *Customer                 `json:"customer,omitempty"`
	LastPaymentError         *PaymentError             `json:"lastPaymentError,omitempty"`
	Metadata                 *map[string]string        `json:"metadata"`
	WorkflowExecutionError   *WorkflowExecutionError   `json:"workflowExecutionError,omitempty"`

Payment ...

type PaymentCardToken

type PaymentCardToken struct {
	Last4Digits        string   `json:"last4Digits"`
	ExpirationMonth    string   `json:"expirationMonth"`
	ExpirationYear     string   `json:"expirationYear"`
	CardHolderName     *string  `json:"cardholderName,omitempty"`
	Network            *string  `json:"network,omitempty"`
	IsNetworkTokenized *bool    `json:"isNetworkTokenized,omitempty"`
	BinData            *BinData `json:"binData,omitempty"`

PaymentCardToken ...

type PaymentError

type PaymentError struct {
	Date             time.Time `json:"date"`
	PaymentErrorType string    `json:"type"`
	DeclineCode      *string   `json:"declineCode,omitempty"`
	DeclineType      *string   `json:"declineType,omitempty"`
	ProcessorMessage *string   `json:"processorMessage,omitempty"`

PaymentError ...

type PaymentEventType added in v1.0.4

type PaymentEventType string

PaymentEventType ...

const (
	// PaymentEventTypeCreation -
	PaymentEventTypeCreation PaymentEventType = "PAYMENT.CREATION"
	// PaymentEventTypeCreation -
	PaymentEventTypeCapture PaymentEventType = "PAYMENT.CAPTURE"
	// PaymentEventTypeCreation -
	PaymentEventTypeRefund PaymentEventType = "PAYMENT.REFUND"
	// PaymentEventTypeCreation -
	PaymentEventTypeCancellation PaymentEventType = "PAYMENT.CANCELLATION"

PaymentEventType enum

type PaymentInstrument

type PaymentInstrument struct {
	Token                      string                      `json:"token"`
	AnalyticsID                *string                     `json:"analyticsId,omitempty"`
	TokenType                  *string                     `json:"tokenType,omitempty"`
	PaymentInstrumentType      *string                     `json:"paymentInstrumentType,omitempty"`
	PaymentInstrumentData      *interface{}                `json:"paymentInstrumentData,omitempty"`
	ThreeDSecureAuthentication *ThreeDSecureAuthentication `json:"threeDSecureAuthentication,omitempty"`

PaymentInstrument ...

type PaymentInstrumentType

type PaymentInstrumentType string

PaymentInstrumentType ...

const (
	// PaymentInstrumentTypePaymentCard -
	PaymentInstrumentTypePaymentCard PaymentInstrumentType = "PAYMENT_CARD"
	// PaymentInstrumentTypePaypalOrder -
	PaymentInstrumentTypePaypalOrder PaymentInstrumentType = "PAYPAL_ORDER"
	// PaymentInstrumentTypePaypalBillingAgreement -
	PaymentInstrumentTypePaypalBillingAgreement PaymentInstrumentType = "PAYPAL_BILLING_AGREEMENT"
	// PaymentInstrumentTypeGooglePay -
	PaymentInstrumentTypeGooglePay PaymentInstrumentType = "GOOGLE_PAY"
	// PaymentInstrumentTypeGoCardlessMandate -
	PaymentInstrumentTypeGoCardlessMandate PaymentInstrumentType = "GOCARDLESS_MANDATE"
	// PaymentInstrumentTypeKlarnaAuthorizationToken -
	PaymentInstrumentTypeKlarnaAuthorizationToken PaymentInstrumentType = "KLARNA_AUTHORIZATION_TOKEN"
	// PaymentInstrumentTypeKlarnaCustomerToken -
	PaymentInstrumentTypeKlarnaCustomerToken PaymentInstrumentType = "KLARNA_CUSTOMER_TOKEN"
	// PaymentInstrumentTypeApplePay -
	PaymentInstrumentTypeApplePay PaymentInstrumentType = "APPLE_PAY"

PaymentInstrumentType enum

type PaymentResponse

type PaymentResponse struct {

PaymentResponse ...

type RefundPayment

type RefundPayment struct {
	Amount  int64   `json:"amount"`
	OrderID *string `json:"orderId,omitempty"`
	Reason  *string `json:"reason,omitempty"`

RefundPayment ...

type RefundPaymentRequest

type RefundPaymentRequest struct {

RefundPaymentRequest ...

type RequiredAction

type RequiredAction struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	ClientToken *string `json:"clientToken,omitempty"`

RequiredAction ...

type ResumePayment

type ResumePayment struct {
	ResumeToken string `json:"resumeToken"`

type ResumePaymentRequest

type ResumePaymentRequest struct {

ResumePaymentRequest ...

type SearchPayment

type SearchPayment struct {
	Data       []Data  `json:"data"`
	NextCursor *string `json:"nextCursor,omitempty"`
	PrevCursor *string `json:"prevCursor,omitempty"`

SearchPayment ...

type SearchPaymentResponse

type SearchPaymentResponse struct {

SearchPaymentResponse ...

type ShippingAddress

type ShippingAddress struct {

ShippingAddress ...

type ThreeDSecureAuthentication

type ThreeDSecureAuthentication struct {
	ResponseCode    string  `json:"responseCode"`
	ReasonCode      *string `json:"reasonCode,omitempty"`
	ReasonText      *string `json:"reasonText,omitempty"`
	ProtocolVersion *string `json:"protocolVersion,omitempty"`
	ChallengeIssued *bool   `json:"challengeIssued,omitempty"`

ThreeDSecureAuthentication ...

type TokenType

type TokenType string

TokenType ...

const (
	// TokenTypeMultiUse -
	TokenTypeMultiUse TokenType = "MULTI_USE"
	// TokenTypeSingleUse -
	TokenTypeSingleUse TokenType = "SINGLE_USE"

TokenType enum

type Transaction

type Transaction struct {
	ID                     string        `json:"id"`
	Processor              string        `json:"processor"`
	TransactionType        string        `json:"type"`
	Status                 string        `json:"status"`
	ProcessorTransactionID *string       `json:"processorTransactionId,omitempty"`
	PaymentError           *PaymentError `json:"paymentError,omitempty"`

Transaction ...

type TransactionStatus

type TransactionStatus string

TransactionStatus ...

const (
	// TransactionStatusPending -
	TransactionStatusPending TransactionStatus = "PENDING"
	// TransactionStatusFailed -
	TransactionStatusFailed TransactionStatus = "FAILED"
	// TransactionStatusAuthorized -
	TransactionStatusAuthorized TransactionStatus = "AUTHORIZED"
	// TransactionStatusSettling -
	TransactionStatusSettling TransactionStatus = "SETTLING"
	// TransactionStatusPartiallySettled -
	TransactionStatusPartiallySettled TransactionStatus = "PARTIALLY_SETTLED"
	// TransactionStatusSettled -
	TransactionStatusSettled TransactionStatus = "SETTLED"
	// TransactionStatusDeclined -
	TransactionStatusDeclined TransactionStatus = "DECLINED"
	// TransactionStatusCancelled -
	TransactionStatusCancelled TransactionStatus = "CANCELLED"

TransactionStatus enum

type VaultedPaymentInstrument

type VaultedPaymentInstrument struct {
	Token                      string                      `json:"token"`
	AnalyticsID                string                      `json:"analyticsId,omitempty"`
	TokenType                  string                      `json:"tokenType,omitempty"`
	PaymentInstrumentType      string                      `json:"paymentInstrumentType,omitempty"`
	PaymentInstrumentData      interface{}                 `json:"paymentInstrumentData,omitempty"`
	ThreeDSecureAuthentication *ThreeDSecureAuthentication `json:"threeDSecureAuthentication,omitempty"`

VaultedPaymentInstrument ...

type WorkflowExecutionError

type WorkflowExecutionError struct {
	Reason string  `json:"reason"`
	StepId *string `json:"stepId,omitempty"`

WorkflowExecutionError ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL