Skip to content

Commit

Permalink
Code formating and disable recurring request structure
Browse files Browse the repository at this point in the history
  • Loading branch information
zhutik committed Dec 27, 2017
1 parent f4e0085 commit e2746c7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
33 changes: 18 additions & 15 deletions payment.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
package adyen

/* One-click functionality gives the shopper the option to store their payment details with the merchant, within the Adyen environment. In this type of transaction, the shopper needs to enter the CVC code for the transaction to get through.
Same than for ONECLICK except than the shopper doesn't need to enter the CVC */
// One-click functionality gives the shopper the option to store their payment details with the merchant, within the Adyen environment.
//
// In this type of transaction, the shopper needs to enter the CVC code for the transaction to get through.
//
// Link: https://docs.adyen.com/developers/api-reference/payments-api#recurring
const (
RecurringPaymentOneClick = "ONECLICK"
RecurringPaymentOneClick = "ONECLICK"
RecurringPaymentRecurring = "RECURRING"
ShopperInteractionContAuth = "ContAuth"
SelectRecurringDetailReferenceLatests = "LATEST"
)

// AuthoriseEncrypted structure for Authorisation request (with encrypted card information)
type AuthoriseEncrypted struct {
AdditionalData *AdditionalData `json:"additionalData,omitempty"`
Amount *Amount `json:"amount"`
Reference string `json:"reference"`
MerchantAccount string `json:"merchantAccount"`
AdditionalData *AdditionalData `json:"additionalData,omitempty"`
Amount *Amount `json:"amount"`
Reference string `json:"reference"`
MerchantAccount string `json:"merchantAccount"`
// Mandatory for recurring payment
ShopperReference string `json:"shopperReference,omitempty"`
Recurring *Recurring `json:"recurring,omitempty"`
ShopperInteraction string `json:"shopperInteraction,omitempty"`
SelectedRecurringDetailReference string `json:"selectedRecurringDetailReference,omitempty"`
ShopperReference string `json:"shopperReference,omitempty"`
Recurring *Recurring `json:"recurring,omitempty"`
ShopperInteraction string `json:"shopperInteraction,omitempty"`
SelectedRecurringDetailReference string `json:"selectedRecurringDetailReference,omitempty"`
// Required for a 3DS process
BrowserInfo *BrowserInfo `json:"browserInfo,omitempty"`
}

// Authorise structure for Authorisation request (card is not encrypted)
type Authorise struct {
Card *Card `json:"card,omitempty"`
Amount *Amount `json:"amount"`
Reference string `json:"reference"`
MerchantAccount string `json:"merchantAccount"`
Card *Card `json:"card,omitempty"`
Amount *Amount `json:"amount"`
Reference string `json:"reference"`
MerchantAccount string `json:"merchantAccount"`
// Mandatory for recurring payment
ShopperReference string `json:"shopperReference,omitempty"`
Recurring *Recurring `json:"recurring,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions payment_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func (a *PaymentGateway) AuthoriseEncrypted(req *AuthoriseEncrypted) (*Authorise
// Authorise - Perform authorise payment in Adyen
//
// Used to perform authorisation transaction without credit card data encrypted
//
// NOTE: Due to PCI compliance, it's not recommended to send credit card data to server
//
// Please use AuthoriseEncrypted instead and adyen frontend encryption library
func (a *PaymentGateway) Authorise(req *Authorise) (*AuthoriseResponse, error) {
resp, err := a.execute(PaymentService, authoriseType, req)
Expand Down
18 changes: 18 additions & 0 deletions recurring.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ type RecurringDetail struct {
RecurringDetailReference string `json:"recurringDetailReference"`
Variant string `json:"variant"`
}

// RecurringDisableRequest structure to hold information regarding disable recurring request
//
// If `RecurringDetailReference` is specified, specific payment ID will be disabled
// otherwise all customer saved payment methods will be disabled
type RecurringDisableRequest struct {
MerchantAccount string `json:"merchantAccount"`
ShopperReference string `json:"shopperReference"`
// Type of a contract ONECLICK, RECURRING, PAYOUT or combination of them
Contract string `json:"contract,omitempty"`
// ID of a customer saved payment method, all will be disabled if none is specified
RecurringDetailReference string `json:"recurringDetailReference,omitempty"`
}

// RecurringDisableResponse structure to hold response for disable recurring request
type RecurringDisableResponse struct {
Response string `json:"response"`
}

0 comments on commit e2746c7

Please sign in to comment.