gopwa

package module
v0.0.0-...-032d8b1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2018 License: MIT Imports: 10 Imported by: 0

README

Go PayWithAmazon

Build Status GoDoc Go Report Card

Go PayWithAmazon (gopwa) is an api wrapper around the Amazon Payments endpoints. No additional dependencies are required to use this library.

See the official Amazon Payments docs for more information

Features:

  • Comprehensive suite of native types for all requests and responses for non-recurring endpoints (08/09/2018)
  • Supports both sandbox and live endpoints
  • Supports all amazon payment regions (17/08/2016)
  • Error handling with native type
  • New or custom request/responses are supported via interfaces (see paywithamazon.go: PayWithAmazon.Do())
  • Optionally supports retrying throttled requests with exponential backoff (disabled by default, enable with: PayWithAmazon.HandleThrottling(true))

Example

Construct new PayWithAmazon object:

pwa := gopwa.New("my-seller-id", "my-access-key", "my-access-secret", gopwa.UK, gopwa.Sandbox)

Get an orders reference details:

orderRefResp, err := pwa.GetOrderReferenceDetails(anOrderReferenceId, "")
if err != nil {
	return err
}

fmt.Printf("Request ID: %s", orderRefResp.Metadata.RequestId)

fmt.Printf("Order Reference ID: %s", orderRefResp.Result.AmazonOrderReferenceId)
fmt.Printf("Seller Note: %s", orderRefResp.Result.SellerNote)

Error handling (note this is very crude):

func getServiceStatus(pwa PayWithAmazon) (string, error) {
	serviceStatusResp, err := pwa.GetServiceStatus()
	if err != nil {
		log.Printf("getServiceStatus: %s", err.Error())

		if errResp, ok := err.(*gopwa.ErrorResponse); ok {
			if errResp.StatusCode == 503 {
				// Backoff and retry request
				time.Sleep(1 * time.Second)
				return getServiceStatus(pwa)
			}
		}

		return "", err
	}

	return serviceStatusResp.Result.Status, nil
}

Tests

Unit Tests

Simply run go test github.com/endiangroup/gopwa to run all unit tests

Integration Tests

The integration tests are a little tricker to run due to 3 factors:

  1. You need an Amazon Order Reference Id to initiate an order flow, which requires using the javascript libraries they provide, logging in with OAuth and 'paying'
  2. Amazon actively detects and prevents attempts to automate the frontend flow described above (no casperjs to the rescue)
  3. Amazon is efficient with their allocation of Amazon Order Reference Id's. If you generate an id via the frontend and do nothing with it, re-running the frontend flow will produce the same id.

Due to these factors the integration tests must be ran one-by-one. Happy to accept any PR's that can further automate this flow.

To run the integration tests you need to do some setup:

  1. You need to login to your Amazon Seller Central account and setup a sandbox user
  2. You need to note down your Client ID, Seller ID, Access Key ID and Access Key Secret

To run the tests open 2 terminals, in the first:

$ go run $GOPATH/src/github.com/endiangroup/gopwa/integration/cmd/main.go -client-id={Client ID} -seller-id={Seller ID}

This will start a http service at http://localhost:5000/:

  1. Browse to http://localhost:5000/
  2. Click the Pay With Amazon button
  3. Login with your sandbox user
  4. Wait until both widgets have loaded ~1-2seconds
  5. Click the Pay Now button
  6. Check the output of your terminal running the http service, you should see a Amazon Order Reference Id like S03-1673721-7848334 in your Stdout

In the second terminal run:

$ go test -tags integration $GOPATH/src/github.com/endiangroup/gopwa/ -seller-id={Seller ID} -key-id={Access Key ID} -key-secret={Access Key Secret} -{test-name}={Amazon Order Reference ID}

Where {test-name} is replace with one of the integration test flag names, you can see them with the following command:

$ cat $GOPATH/src/github.com/endiangroup/gopwa/integration_test.go | grep 'flag\.String'

Examples:

$ go test -tags integration $GOPATH/src/github.com/endiangroup/gopwa/ -seller-id={Seller ID} -key-id={Access Key ID} -key-secret={Access Key Secret} -authorize={Amazon Order Reference ID}
$ go test -tags integration $GOPATH/src/github.com/endiangroup/gopwa/ -seller-id={Seller ID} -key-id={Access Key ID} -key-secret={Access Key Secret} -capture={Amazon Order Reference ID}
$ go test -tags integration $GOPATH/src/github.com/endiangroup/gopwa/ -seller-id={Seller ID} -key-id={Access Key ID} -key-secret={Access Key Secret} -close-order-reference={Amazon Order Reference ID}

TODO:

  • Validation of request parameters (add a Validate() method to Request interface?)
  • Automate integration tests
  • Optional retry handling of failed requests (see official python library for example)
  • Add recurring payment specific helpers, requests and responses

Documentation

Index

Constants

View Source
const (
	UserAgent = "Go_PayWithAmazon"
	Version   = "0.0.1"
)

Variables

View Source
var BackoffDurations = []time.Duration{
	0 * time.Second,
	1 * time.Second,
	4 * time.Second,
	10 * time.Second,
}
View Source
var Now = func() time.Time { return time.Now() }
View Source
var Regions = []string{
	UK: "mws-eu.amazonservices.com",
	DE: "mws-eu.amazonservices.com",
	EU: "mws-eu.amazonservices.com",
	US: "mws.amazonservices.com",
	NA: "mws.amazonservices.com",
	JP: "mws.amazonservices.jp",
}

Functions

func NowForce

func NowForce(t time.Time)

func NowReset

func NowReset()

Types

type Address

type Address struct {
	Name          string
	AddressLine1  string
	AddressLine2  string
	AddressLine3  string
	City          string
	County        string
	District      string
	StateOrRegion string
	PostalCode    string
	CountryCode   string
	Phone         string
}

type ApiVersion

type ApiVersion string
const (
	V20130101 ApiVersion = "2013-01-01"
)

type AuthorisationState

type AuthorisationState string
const (
	AuthStatePending  AuthorisationState = "Pending"
	AuthStateOpen     AuthorisationState = "Open"
	AuthStateDeclined AuthorisationState = "Declined"
	AuthStateClosed   AuthorisationState = "Closed"
)

type AuthorizationDetails

type AuthorizationDetails struct {
	AmazonAuthorizationId       string
	AuthorizationBillingAddress Address
	AuthorizationReferenceId    string
	SellerAuthorizationNote     string
	AuthorizationAmount         Price
	CapturedAmount              Price
	AuthorizationFee            Price
	IdList                      []string
	CreationTimestamp           time.Time
	ExpirationTimestamp         time.Time
	AuthorizationStatus         AuthorizationStatus
	SoftDecline                 bool
	CaptureNow                  bool
	SoftDescriptor              string
}

type AuthorizationStatus

type AuthorizationStatus struct {
	State AuthorisationState
	StatusCommon
}

type Authorize

type Authorize struct {
	AmazonOrderReferenceId   string
	AuthorizationReferenceId string
	AuthorizationAmount      Price
	SellerAuthorizationNote  string
	TransactionTimeout       uint
	CaptureNow               bool
	SoftDescriptor           string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752010

func (Authorize) Action

func (req Authorize) Action() string

func (Authorize) AddValues

func (req Authorize) AddValues(v url.Values) url.Values

type AuthorizeResponse

type AuthorizeResponse struct {
	Result   *AuthorizeResult `xml:"AuthorizeResult"`
	Metadata ResponseMetadata `xml:"ResponseMetadata"`
}

type AuthorizeResult

type AuthorizeResult struct {
	AuthorizationDetails AuthorizationDetails
}

type BillingAgreementAttributes

type BillingAgreementAttributes struct {
	PlatformId                       string
	SellerNote                       string
	SellerBillingAgreementAttributes SellerBillingAgreementAttributes
}

type BillingAgreementDetails

type BillingAgreementDetails struct {
	AmazonBillingAgreementId         string
	BillingAddress                   Address
	SellerNote                       string
	PlatformId                       string
	ReleaseEnvironment               string
	Constraints                      []Constraint
	CreationTimestamp                time.Time
	BillingAgreementConsent          bool
	Buyer                            Buyer
	Destination                      Destination
	BillingAgreementLimits           BillingAgreementLimits
	BillingAgreementStatus           BillingAgreementStatus
	SellerBillingAgreementAttributes SellerBillingAgreementAttributes
}

type BillingAgreementLimits

type BillingAgreementLimits struct {
	AmountLimitPerTimePeriod Price
	TimePeriodStartDate      time.Time
	TimePeriodEndDate        time.Time
	CurrentRemainingBalance  Price
}

type BillingAgreementState

type BillingAgreementState string
const (
	BillAgreeStateDraft     BillingAgreementState = "Draft"
	BillAgreeStateOpen      BillingAgreementState = "Open"
	BillAgreeStateSuspended BillingAgreementState = "Suspended"
	BillAgreeStateCanceled  BillingAgreementState = "Canceled"
	BillAgreeStateClosed    BillingAgreementState = "Closed"
)

type BillingAgreementStatus

type BillingAgreementStatus struct {
	State                BillingAgreementState
	LastUpdatedTimestamp time.Time
	ReasonCode           string
	ReasonDescription    string
}

type Buyer

type Buyer struct {
	Name  string
	Email string
	Phone string
}

type CancelOrderReference

type CancelOrderReference struct {
	AmazonOrderReferenceId string
	CancelationReason      string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201751990

func (CancelOrderReference) Action

func (req CancelOrderReference) Action() string

func (CancelOrderReference) AddValues

func (req CancelOrderReference) AddValues(v url.Values) url.Values

type CancelOrderReferenceResponse

type CancelOrderReferenceResponse struct {
	Metadata ResponseMetadata `xml:"ResponseMetadata"`
}

type Capture

type Capture struct {
	AmazonAuthorizationId string
	CaptureReferenceId    string
	CaptureAmount         Price
	SellerCaptureNote     string
	SoftDescriptor        string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752040

func (Capture) Action

func (req Capture) Action() string

func (Capture) AddValues

func (req Capture) AddValues(v url.Values) url.Values

type CaptureDetails

type CaptureDetails struct {
	AmazonCaptureId    string
	CaptureReferenceId string
	SellerCaptureNote  string
	CaptureAmount      Price
	RefundedAmount     Price
	CaptureFee         Price
	IdList             []string
	CreationTimestamp  time.Time
	CaptureStatus      CaptureStatus
	SoftDescriptor     string
	ConvertedAmount    Price
	ConversionRate     string
}

type CaptureResponse

type CaptureResponse struct {
	Result   *CaptureResult   `xml:"CaptureResult"`
	Metadata ResponseMetadata `xml:"ResponseMetadata"`
}

type CaptureResult

type CaptureResult struct {
	CaptureDetails CaptureDetails
}

type CaptureState

type CaptureState string
const (
	CaptureStatePending   CaptureState = "Pending"
	CaptureStateDeclined  CaptureState = "Declined"
	CaptureStateCompleted CaptureState = "Completed"
	CaptureStateClosed    CaptureState = "Closed"
)

type CaptureStatus

type CaptureStatus struct {
	State CaptureState
	StatusCommon
}

type CloseAuthorization

type CloseAuthorization struct {
	AmazonAuthorizationId string
	ClosureReason         string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752070

func (CloseAuthorization) Action

func (req CloseAuthorization) Action() string

func (CloseAuthorization) AddValues

func (req CloseAuthorization) AddValues(v url.Values) url.Values

type CloseAuthorizationResponse

type CloseAuthorizationResponse struct {
	Metadata ResponseMetadata `xml:"ResponseMetadata"`
}

type CloseOrderReference

type CloseOrderReference struct {
	AmazonOrderReferenceId string
	ClosureReason          string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752000

func (CloseOrderReference) Action

func (req CloseOrderReference) Action() string

func (CloseOrderReference) AddValues

func (req CloseOrderReference) AddValues(v url.Values) url.Values

type CloseOrderReferenceResponse

type CloseOrderReferenceResponse struct {
	Metadata ResponseMetadata `xml:"ResponseMetadata"`
}

type ConfirmOrderReference

type ConfirmOrderReference struct {
	AmazonOrderReferenceId string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201751980

func (ConfirmOrderReference) Action

func (req ConfirmOrderReference) Action() string

func (ConfirmOrderReference) AddValues

func (req ConfirmOrderReference) AddValues(v url.Values) url.Values

type ConfirmOrderReferenceResponse

type ConfirmOrderReferenceResponse struct {
	Metadata ResponseMetadata `xml:"ResponseMetadata"`
}

type Constraint

type Constraint struct {
	ConstraintID string
	Description  string
}

type CreateOrderReferenceForId

type CreateOrderReferenceForId struct {
	Id                       string
	IdType                   string
	InheritShippingAddress   bool
	ConfirmNow               bool
	OrderReferenceAttributes OrderReferenceAttributes
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201751670

func (CreateOrderReferenceForId) Action

func (req CreateOrderReferenceForId) Action() string

func (CreateOrderReferenceForId) AddValues

func (req CreateOrderReferenceForId) AddValues(v url.Values) url.Values

type CreateOrderReferenceForIdResponse

type CreateOrderReferenceForIdResponse struct {
	Result   *CreateOrderReferenceForIdResult `xml:"CreateOrderReferenceForIdResult"`
	Metadata ResponseMetadata                 `xml:"ResponseMetadata"`
}

type CreateOrderReferenceForIdResult

type CreateOrderReferenceForIdResult struct {
	OrderReferenceDetails OrderReferenceDetails
}

type Destination

type Destination struct {
	DestinationType     string
	PhysicalDestination Address
}

type Environment

type Environment string
const (
	Sandbox Environment = "/OffAmazonPayments_Sandbox"
	Live    Environment = "/OffAmazonPayments"
)

type Error

type Error struct {
	Type    string
	Code    string
	Message string
	Detail  string
}

type ErrorResponse

type ErrorResponse struct {
	StatusCode int     `xml:"-"`
	Errors     []Error `xml:"Error"`
	RequestID  string
}

For error format see: http://docs.developer.amazonservices.com/en_US/dev_guide/DG_ResponseFormat.html For possible error codes see: https://payments.amazon.co.uk/developer/documentation/apireference/201753060

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

type GetAuthorizationDetails

type GetAuthorizationDetails struct {
	AmazonAuthorizationId string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752030

func (GetAuthorizationDetails) Action

func (req GetAuthorizationDetails) Action() string

func (GetAuthorizationDetails) AddValues

func (req GetAuthorizationDetails) AddValues(v url.Values) url.Values

type GetAuthorizationDetailsResponse

type GetAuthorizationDetailsResponse struct {
	Result   *GetAuthorizationDetailsResult `xml:"GetAuthorizationDetailsResult"`
	Metadata ResponseMetadata               `xml:"ResponseMetadata"`
}

type GetAuthorizationDetailsResult

type GetAuthorizationDetailsResult struct {
	AuthorizationDetails AuthorizationDetails
}

type GetCaptureDetails

type GetCaptureDetails struct {
	AmazonCaptureId string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752060

func (GetCaptureDetails) Action

func (req GetCaptureDetails) Action() string

func (GetCaptureDetails) AddValues

func (req GetCaptureDetails) AddValues(v url.Values) url.Values

type GetCaptureDetailsResponse

type GetCaptureDetailsResponse struct {
	Result   *GetCaptureDetailsResult `xml:"GetCaptureDetailsResult"`
	Metadata ResponseMetadata         `xml:"ResponseMetadata"`
}

type GetCaptureDetailsResult

type GetCaptureDetailsResult struct {
	CaptureDetails CaptureDetails
}

type GetMerchantAccountStatus

type GetMerchantAccountStatus struct {
	SellerId string
}

See: https://pay.amazon.com/uk/developer/documentation/apireference/82TPMDNUCGPGUK8

func (GetMerchantAccountStatus) Action

func (req GetMerchantAccountStatus) Action() string

func (GetMerchantAccountStatus) AddValues

func (req GetMerchantAccountStatus) AddValues(v url.Values) url.Values

type GetMerchantAccountStatusResponse

type GetMerchantAccountStatusResponse struct {
	Result   *GetMerchantAccountStatusResult `xml:"GetMerchantAccountStatusResult"`
	Metadata ResponseMetadata                `xml:"ResponseMetadata"`
}

type GetMerchantAccountStatusResult

type GetMerchantAccountStatusResult struct {
	AccountStatus string
}

type GetOrderReferenceDetails

type GetOrderReferenceDetails struct {
	AmazonOrderReferenceId string
	AddressConsentToken    string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201751970

func (GetOrderReferenceDetails) Action

func (req GetOrderReferenceDetails) Action() string

func (GetOrderReferenceDetails) AddValues

func (req GetOrderReferenceDetails) AddValues(v url.Values) url.Values

type GetOrderReferenceDetailsResponse

type GetOrderReferenceDetailsResponse struct {
	Result   *GetOrderReferenceDetailsResult `xml:"GetOrderReferenceDetailsResult"`
	Metadata ResponseMetadata                `xml:"ResponseMetadata"`
}

type GetOrderReferenceDetailsResult

type GetOrderReferenceDetailsResult struct {
	OrderReferenceDetails OrderReferenceDetails
}

type GetRefundDetails

type GetRefundDetails struct {
	AmazonRefundId string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752100

func (GetRefundDetails) Action

func (req GetRefundDetails) Action() string

func (GetRefundDetails) AddValues

func (req GetRefundDetails) AddValues(v url.Values) url.Values

type GetRefundDetailsResponse

type GetRefundDetailsResponse struct {
	Result   *GetRefundDetailsResult `xml:"GetRefundDetailsResult"`
	Metadata ResponseMetadata        `xml:"ResponseMetadata"`
}

type GetRefundDetailsResult

type GetRefundDetailsResult struct {
	RefundDetails RefundDetails
}

type GetServiceStatus

type GetServiceStatus struct{}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752110

func (GetServiceStatus) Action

func (req GetServiceStatus) Action() string

func (GetServiceStatus) AddValues

func (req GetServiceStatus) AddValues(v url.Values) url.Values

type GetServiceStatusResponse

type GetServiceStatusResponse struct {
	Result   *GetServiceStatusResult `xml:"GetServiceStatusResult"`
	Metadata ResponseMetadata        `xml:"ResponseMetadata"`
}

type GetServiceStatusResult

type GetServiceStatusResult struct {
	Status    string
	Timestamp time.Time
	MessageId string
	Messages  []Message
}

type Message

type Message struct {
	Locale string
	Text   string
}

type MockRequest

type MockRequest struct {
	mock.Mock
}

MockRequest is an autogenerated mock type for the Request type

func (*MockRequest) Action

func (_m *MockRequest) Action() string

Action provides a mock function with given fields:

func (*MockRequest) AddValues

func (_m *MockRequest) AddValues(_a0 url.Values) url.Values

AddValues provides a mock function with given fields: _a0

type MockSignatory

type MockSignatory struct {
	mock.Mock
}

MockSignatory is an autogenerated mock type for the Signatory type

func (*MockSignatory) Method

func (_m *MockSignatory) Method() string

Method provides a mock function with given fields:

func (*MockSignatory) Sign

func (_m *MockSignatory) Sign(_a0 string) []byte

Sign provides a mock function with given fields: _a0

func (*MockSignatory) Version

func (_m *MockSignatory) Version() string

Version provides a mock function with given fields:

type OrderAttributes

type OrderAttributes struct {
	OrderTotal                       OrderTotal
	PlatformID                       string
	SellerNote                       string
	SellerOrderAttributes            SellerOrderAttributes
	PaymentServiceProviderAttributes PaymentServiceProviderAttributes
}

func (OrderAttributes) AddValues

func (o OrderAttributes) AddValues(prefix string, v url.Values) url.Values

type OrderReferenceAttributes

type OrderReferenceAttributes struct {
	PlatformId            string
	SellerNote            string
	OrderTotal            OrderTotal
	SellerOrderAttributes SellerOrderAttributes
}

func (OrderReferenceAttributes) AddValues

func (o OrderReferenceAttributes) AddValues(prefix string, v url.Values) url.Values

type OrderReferenceDetails

type OrderReferenceDetails struct {
	AmazonOrderReferenceId string
	SellerNote             string
	PlatformId             string
	ReleaseEnvironment     string
	OrderLanguage          string
	CreationTimestamp      time.Time
	ExpirationTimestamp    time.Time
	BillingAddress         Address
	Constraints            []Constraint
	IdList                 []string
	Buyer                  Buyer
	OrderTotal             OrderTotal
	Destination            Destination
	OrderReferenceStatus   OrderReferenceStatus
	SellerOrderAttributes  SellerOrderAttributes
}

type OrderReferenceState

type OrderReferenceState string
const (
	OrderRefStateDraft     OrderReferenceState = "Draft"
	OrderRefStateOpen      OrderReferenceState = "Open"
	OrderRefStateSuspended OrderReferenceState = "Suspended"
	OrderRefStateCanceled  OrderReferenceState = "Canceled"
	OrderRefStateClosed    OrderReferenceState = "Closed"
)

type OrderReferenceStatus

type OrderReferenceStatus struct {
	State               OrderReferenceState
	LastUpdateTimestamp time.Time
	ReasonCode          string
	ReasonDescription   string
}

type OrderTotal

type OrderTotal struct {
	CurrencyCode string
	Amount       string
}

func (OrderTotal) AddValues

func (o OrderTotal) AddValues(prefix string, v url.Values) url.Values

type PayWithAmazon

type PayWithAmazon struct {
	AccessKeyID string
	SellerID    string
	HttpClient  *http.Client
	Signatory   Signatory
	Endpoint    *url.URL
	ApiVersion  ApiVersion
	// contains filtered or unexported fields
}

func New

func New(sellerID, accessKeyID, accessKeySecret string, region Region, environment Environment) *PayWithAmazon

func (PayWithAmazon) Authorize

func (pwa PayWithAmazon) Authorize(
	amazonOrderReferenceId string,
	authorizationReferenceId string,
	authorizationAmount Price,
	sellerAuthorizationNote string,
	transactionTimeout uint,
	captureNow bool,
	softDescriptor string,
) (*AuthorizeResponse, error)

func (PayWithAmazon) CancelOrderReference

func (pwa PayWithAmazon) CancelOrderReference(amazonOrderReferenceId, cancelationReason string) (*CancelOrderReferenceResponse, error)

func (PayWithAmazon) Capture

func (pwa PayWithAmazon) Capture(
	amazonAuthorizationId string,
	captureReferenceId string,
	captureAmount Price,
	sellerCaptureNote string,
	softDescriptor string,
) (*CaptureResponse, error)

func (PayWithAmazon) CloseAuthorization

func (pwa PayWithAmazon) CloseAuthorization(amazonAuthorizationId, closureReason string) (*CloseAuthorizationResponse, error)

func (PayWithAmazon) CloseOrderReference

func (pwa PayWithAmazon) CloseOrderReference(amazonOrderReferenceId, closureReason string) (*CloseOrderReferenceResponse, error)

func (PayWithAmazon) ConfirmOrderReference

func (pwa PayWithAmazon) ConfirmOrderReference(amazonOrderReferenceId string) (*ConfirmOrderReferenceResponse, error)

func (PayWithAmazon) CreateOrderReferenceForId

func (pwa PayWithAmazon) CreateOrderReferenceForId(
	id string,
	idType string,
	inheritShippingAddress bool,
	confirmNow bool,
	orderReferenceAttributes OrderReferenceAttributes,
) (*CreateOrderReferenceForIdResponse, error)

func (PayWithAmazon) Do

func (pwa PayWithAmazon) Do(amazonReq Request, response interface{}) error

func (PayWithAmazon) GetAuthorizationDetails

func (pwa PayWithAmazon) GetAuthorizationDetails(amazonAuthorizationId string) (*GetAuthorizationDetailsResponse, error)

func (PayWithAmazon) GetCaptureDetails

func (pwa PayWithAmazon) GetCaptureDetails(amazonCaptureId string) (*GetCaptureDetailsResponse, error)

func (PayWithAmazon) GetMerchantAccountStatus

func (pwa PayWithAmazon) GetMerchantAccountStatus(sellerId string) (*GetMerchantAccountStatusResponse, error)

func (PayWithAmazon) GetOrderReferenceDetails

func (pwa PayWithAmazon) GetOrderReferenceDetails(amazonOrderReferenceId, addressConsentToken string) (*GetOrderReferenceDetailsResponse, error)

func (PayWithAmazon) GetRefundDetails

func (pwa PayWithAmazon) GetRefundDetails(amazonRefundId string) (*GetRefundDetailsResponse, error)

func (PayWithAmazon) GetServiceStatus

func (pwa PayWithAmazon) GetServiceStatus() (*GetServiceStatusResponse, error)

func (*PayWithAmazon) HandleThrottling

func (pwa *PayWithAmazon) HandleThrottling(shouldHandleThrottling bool)

func (PayWithAmazon) Refund

func (pwa PayWithAmazon) Refund(
	amazonCaptureId string,
	refundReferenceId string,
	refundAmount Price,
	sellerRefundNote string,
	softDescriptor string,
) (*RefundResponse, error)

func (PayWithAmazon) SetOrderAttributes

func (pwa PayWithAmazon) SetOrderAttributes(amazonOrderReferenceId string, orderAttributes OrderAttributes) (*SetOrderAttributesResponse, error)

func (PayWithAmazon) SetOrderReferenceDetails

func (pwa PayWithAmazon) SetOrderReferenceDetails(amazonOrderReferenceId string, orderReferenceAttributes OrderReferenceAttributes) (*SetOrderReferenceDetailsResponse, error)

type PaymentServiceProviderAttributes

type PaymentServiceProviderAttributes struct {
	PaymentServiceProviderId      string
	PaymentServiceProviderOrderId string
}

func (PaymentServiceProviderAttributes) AddValues

type Price

type Price struct {
	CurrencyCode string
	Amount       string
}

func (Price) AddValues

func (p Price) AddValues(prefix string, v url.Values) url.Values

type Refund

type Refund struct {
	AmazonCaptureId   string
	RefundReferenceId string
	RefundAmount      Price
	SellerRefundNote  string
	SoftDescriptor    string
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201752080

func (Refund) Action

func (req Refund) Action() string

func (Refund) AddValues

func (req Refund) AddValues(v url.Values) url.Values

type RefundDetails

type RefundDetails struct {
	AmazonRefundId    string
	RefundReferenceId string
	SellerRefundNote  string
	RefundType        string
	RefundAmount      Price
	FeeRefunded       Price
	CreationTimestamp time.Time
	RefundStatus      RefundStatus
	SoftDescriptor    string
	ConvertedAmount   Price
	ConversionRate    string
}

type RefundResponse

type RefundResponse struct {
	Result   *RefundResult    `xml:"RefundResult"`
	Metadata ResponseMetadata `xml:"ResponseMetadata"`
}

type RefundResult

type RefundResult struct {
	RefundDetails RefundDetails
}

type RefundState

type RefundState string
const (
	RefundStatePending   RefundState = "Pending"
	RefundStateDeclined  RefundState = "Declined"
	RefundStateCompleted RefundState = "Completed"
)

type RefundStatus

type RefundStatus struct {
	State RefundState
	StatusCommon
}

type Region

type Region uint8
const (
	UK Region = iota
	DE
	EU
	US
	NA
	JP
)

type Request

type Request interface {
	Action() string
	AddValues(url.Values) url.Values
}

type ResponseMetadata

type ResponseMetadata struct {
	RequestId string
}

type SellerBillingAgreementAttributes

type SellerBillingAgreementAttributes struct {
	SellerBillingAgreementId string
	StoreName                string
	CustomInformation        string
}

type SellerOrderAttributes

type SellerOrderAttributes struct {
	SellerOrderId     string
	StoreName         string
	CustomInformation string
}

func (SellerOrderAttributes) AddValues

func (s SellerOrderAttributes) AddValues(prefix string, v url.Values) url.Values

type SetOrderAttributes

type SetOrderAttributes struct {
	AmazonOrderReferenceId string
	OrderAttributes        OrderAttributes
}

See: https://pay.amazon.com/uk/developer/documentation/apireference/22N636REVGXTPNR

func (SetOrderAttributes) Action

func (req SetOrderAttributes) Action() string

func (SetOrderAttributes) AddValues

func (req SetOrderAttributes) AddValues(v url.Values) url.Values

type SetOrderAttributesResponse

type SetOrderAttributesResponse struct {
	Result   *SetOrderAttributesResult `xml:"SetOrderAttributesResult"`
	Metadata ResponseMetadata          `xml:"ResponseMetadata"`
}

type SetOrderAttributesResult

type SetOrderAttributesResult struct {
	OrderReferenceDetails OrderReferenceDetails
}

type SetOrderReferenceDetails

type SetOrderReferenceDetails struct {
	AmazonOrderReferenceId   string
	OrderReferenceAttributes OrderReferenceAttributes
}

See: https://payments.amazon.co.uk/developer/documentation/apireference/201751960

func (SetOrderReferenceDetails) Action

func (req SetOrderReferenceDetails) Action() string

func (SetOrderReferenceDetails) AddValues

func (req SetOrderReferenceDetails) AddValues(v url.Values) url.Values

type SetOrderReferenceDetailsResponse

type SetOrderReferenceDetailsResponse struct {
	Result   *SetOrderReferenceDetailsResult `xml:"SetOrderReferenceDetailsResult"`
	Metadata ResponseMetadata                `xml:"ResponseMetadata"`
}

type SetOrderReferenceDetailsResult

type SetOrderReferenceDetailsResult struct {
	OrderReferenceDetails OrderReferenceDetails
}

type Signatory

type Signatory interface {
	Sign(string) []byte
	Method() string
	Version() string
}

type StatusCommon

type StatusCommon struct {
	LastUpdateTimestamp time.Time
	ReasonCode          string
	ReasonDescription   string
}

type V2Hmac256Signatory

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

func (V2Hmac256Signatory) Method

func (h V2Hmac256Signatory) Method() string

func (V2Hmac256Signatory) Sign

func (h V2Hmac256Signatory) Sign(raw string) []byte

func (V2Hmac256Signatory) Version

func (h V2Hmac256Signatory) Version() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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