braintree

package module
v0.0.0-...-4781f84 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2017 License: MIT Imports: 12 Imported by: 0

README

braintree

Build Status Software License GoDoc Test Coverage Go Report Card

This project is not even close to be ready for production. Development has just started.

The goal is to build a braintree client in go.

Documentation

Index

Constants

View Source
const (
	EnvironmentProduction = "production"
	EnvironmentSanbox     = "sandbox"
)

Braintree Environments

View Source
const (
	CardTypeAmericanExpress = "American Express"
	CardTypeCarteBlanche    = "Card Blanche"
	CardTypeChinaUnionPay   = "China UnionPay"
	CardTypeDinersClub      = "Diners Club"
	CardTypeDiscover        = "Discover"
	CardTypeJCB             = "JCB"
	CardTypeLaser           = "Laser"
	CardTypeMaestro         = "Maestro"
	CardTypeMasterCard      = "MasterCard"
	CardTypeSolo            = "Solo"
	CardTypeSwitch          = "Switch"
	CardTypeVisa            = "Visa"
	CardTypeUnknown         = "Unknown"
)

Card Types accepted by braintree.

View Source
const (
	SubscriptionStatusActive   = "Active"
	SubscriptionStatusCanceled = "Canceled"
	SubscriptionStatusExpired  = "Expired"
	SubscriptionStatusPastDue  = "Past Due"
	SubscriptionStatusPending  = "Pending"
)

Possible subscription statuses on braintree.

View Source
const (
	PaymentInstrumentAndroidPayCard = "android_pay_card"
	PaymentInstrumentApplePayCard   = "apple_pay_card"
	PaymentInstrumentCreditCard     = "credit_card"
	PaymentInstrumentPaypalAccount  = "paypal_account"
	PaymentInstrumentVenmoAccount   = "venmo_account"
)

Payment instrument types of a transaction.

View Source
const (
	TransactionStatusAuthorisationExpired   = "authorisation_expired"
	TransactionStatusAuthorized             = "authorized"
	TransactionStatusAuthorizing            = "authorizing"
	TransactionStatusSettlementPending      = "settlement_pending"
	TransactionStatusSettlementConfirmed    = "settlement_confirmed"
	TransactionStatusSettlementDeclined     = "settlement_declined"
	TransactionStatusFailed                 = "failed"
	TransactionStatusGatewayRejected        = "gateway_rejected"
	TransactionStatusProcessorDeclined      = "processor_declined"
	TransactionStatusSettled                = "settled"
	TransactionStatusSettling               = "settling"
	TransactionStatusSubmittedForSettlement = "submitted_for_settlement"
	TransactionStatusVoided                 = "voided"
)

Status types of a transaction.

View Source
const (
	TransactionTypeSale   = "sale"
	TransactionTypeCredit = "credit"
)

Types of a transaction.

View Source
const (
	WebhookAccountUpdaterDailyReport = "account_updater_daily_report"

	WebhookCheck = "check"

	WebhookDisbursement          = "disbursement"
	WebhookDisbursementException = "disbursement_exception"

	WebhookDisputeLost   = "dispute_lost"
	WebhookDisputeOpened = "dispute_opened"
	WebhookDisputeWon    = "dispute_won"

	WebhookSubscriptionCanceled              = "subscription_canceled"
	WebhookSubscriptionChargedSuccessfully   = "subscription_charged_successfully"
	WebhookSubscriptionChargedUnsuccessfully = "subscription_charged_unsuccessfully"
	WebhookSubscriptionExpired               = "subscription_expired"
	WebhookSubscriptionTrialEnded            = "subscription_trial_ended"
	WebhookSubscriptionWentActive            = "subscription_went_active"
	WebhookSubscriptionWentPastDue           = "subscription_went_past_due"

	WebhookSubMerchantAccountApproved = "sub_merchant_account_approved"
	WebhookSubMerchantAccountDeclined = "sub_merchant_account_declined"

	WebhookPartnerMerchantAccountConnected    = "partner_merchant_account_connected"
	WebhookPartnerMerchantAccountDisconnected = "partner_merchant_account_disconnected"
	WebhookPartnerMerchantAccountDeclined     = "partner_merchant_account_declined"

	WebhookTransactionSettled            = "transaction_settled"
	WebhookTransactionSettlementDeclined = "transaction_settlement_declined"
	WebhookTransactionDispursed          = "transaction_dispursed"
)

Kind of webhooks.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Company            string    `xml:"company"`
	CountryCodeAlpha2  string    `xml:"country-code-alpha2"`
	CountryCodeAlpha3  string    `xml:"country-code-alpha3"`
	CountryCodeNumeric string    `xml:"country-code-numeric"`
	CountryName        string    `xml:"country-name"`
	CreatedAt          time.Time `xml:"created-at"`
	CustomerID         string    `xml:"customer-id"`
	ExtendedAddress    string    `xml:"extended-address"`
	FirstName          string    `xml:"first-name"`
	ID                 string    `xml:"id"`
	LastName           string    `xml:"last-name"`
	Locality           string    `xml:"locality"`
	PostalCode         string    `xml:"postal-code"`
	Region             string    `xml:"region"`
	StreetAddress      string    `xml:"street-address"`
	UpdatedAt          time.Time `xml:"updated-at"`
}

Address is a braintree address.

type AddressGW

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

AddressGW is an Address Gateway.

func (AddressGW) Create

func (agw AddressGW) Create(customerID string, address AddressInput) (*Address, error)

Create an address on braintree.

func (AddressGW) Delete

func (agw AddressGW) Delete(customerID, addressID string) error

Delete an address on braintree.

func (AddressGW) Find

func (agw AddressGW) Find(customerID, addressID string) (*Address, error)

Find gets a specific address for a customer.

func (AddressGW) Update

func (agw AddressGW) Update(customerID, addressID string, address AddressInput) (*Address, error)

Update an address in braintree.

type AddressInput

type AddressInput struct {
	XMLName            xml.Name
	Company            string `xml:"company,omitempty"`
	CountryCodeAlpha2  string `xml:"country-code-alpha2,omitempty"`
	CountryCodeAlpha3  string `xml:"country-code-alpha3,omitempty"`
	CountryCodeNumeric string `xml:"country-code-numeric,omitempty"`
	CountryName        string `xml:"country-name,omitempty"`
	ExtendedAddress    string `xml:"extended-address,omitempty"`
	FirstName          string `xml:"first-name,omitempty"`
	ID                 string `xml:"id,omitempty,omitempty"`
	LastName           string `xml:"last-name,omitempty"`
	Locality           string `xml:"locality,omitempty"`
	PostalCode         string `xml:"postal-code,omitempty"`
	Region             string `xml:"region,omitempty"`
	StreetAddress      string `xml:"street-address,omitempty"`
}

AddressInput is used to create or update an address on braintree.

type Braintree

type Braintree struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

Braintree client

func New

func New() (*Braintree, error)

New returns a braintree client with credentials from env.

BRAINTREE_ENVIRONMENT has to be set to production or sandbox. BRAINTREE_MERCHANT_ID, BRAINTREE_PUBLIC_KEY and BRAINTREE_PRIVATE_KEY have to be set.

func (*Braintree) Address

func (bt *Braintree) Address() AddressGW

Address provides the address gateway for this braintree client.

func (*Braintree) ClientToken

func (bt *Braintree) ClientToken() ClientTokenGW

ClientToken provides the client token gateway for this braintree client.

func (*Braintree) Customer

func (bt *Braintree) Customer() CustomerGW

Customer provides the customer gateway for this braintree client.

func (*Braintree) PaymentMethod

func (bt *Braintree) PaymentMethod() PaymentMethodGW

PaymentMethod provides the payment method gateway for this braintree client.

func (*Braintree) Plan

func (bt *Braintree) Plan() PlanGW

Plan provides the plan gateway for this braintree client.

func (*Braintree) Subscription

func (bt *Braintree) Subscription() SubscriptionGW

Subscription provides the subscription gateway for this braintree client.

func (*Braintree) Transaction

func (bt *Braintree) Transaction() TransactionGW

Transaction provides the transaction gateway for this braintree client.

type ClientTokenGW

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

ClientTokenGW is a ClientToken Gateway.

func (ClientTokenGW) Generate

func (ctgw ClientTokenGW) Generate(ct ClientTokenInput) (string, error)

Generate a client token.

Version is required.

type ClientTokenInput

type ClientTokenInput struct {
	XMLName           xml.Name
	CustomerID        string              `xml:"customer-id,omitempty"`
	MerchantAccountID string              `xml:"merchant-account-id,omitempty"`
	Options           *ClientTokenOptions `xml:"options,omitempty"`
	Version           int                 `xml:"version"`
}

ClientTokenInput is used to generate a client token.

type ClientTokenOptions

type ClientTokenOptions struct {
	FailOnDuplicatePaymentMethod bool `xml:"fail-on-duplicate-payment-method,omitempty"`
	MakeDefault                  bool `xml:"make-default,omitempty"`
	VerifyCard                   bool `xml:"verify-card,omitempty"`
}

ClientTokenOptions can be used as part of a ClientTokenInput.

type CreditCard

type CreditCard struct {
	BillingAddress         Address        `xml:"billing-address"`
	BIN                    string         `xml:"bin"`
	CardType               string         `xml:"card-type"`
	CardholderName         string         `xml:"cardholder-name"`
	Commercial             string         `xml:"commercial"`
	CountryOfIssuance      string         `xml:"country-of-issuance"`
	CreatedAt              time.Time      `xml:"created-at"`
	CustomerID             string         `xml:"customer-id"`
	CustomerLocation       string         `xml:"customer-location"`
	Debit                  string         `xml:"debit"`
	Default                bool           `xml:"default"`
	DurbinRegulated        string         `xml:"durbin-regulated"`
	ExpirationDate         string         `xml:"expiration-date"`
	ExpirationMonth        string         `xml:"expiration-month"`
	ExpirationYear         string         `xml:"expiration-year"`
	Expired                bool           `xml:"expired"`
	Healthcare             string         `xml:"healthcare"`
	ImageURL               string         `xml:"image-url"`
	IssuingBank            string         `xml:"issuing-bank"`
	Last4                  string         `xml:"last-4"`
	MaskedNumber           string         `xml:"masked-number"`
	Payroll                string         `xml:"payroll"`
	Prepaid                string         `xml:"prepaid"`
	ProductID              string         `xml:"product-id"`
	Subscriptions          []Subscription `xml:"subscriptions>subscription"`
	Token                  string         `xml:"token"`
	UniqueNumberIdentifier string         `xml:"unique-number-identifier"`
	UpdatedAt              time.Time      `xml:"updated-at"`
}

A CreditCard is a braintree credit card.

type CreditCardInput

type CreditCardInput struct {
	XMLName            xml.Name
	BillingAddress     *AddressInput         `xml:"billing-address,omitempty"`
	BillingAddressID   string                `xml:"billing-address-id,omitempty"`
	CardholderName     string                `xml:"cardholder-name,omitempty"`
	CustomerID         string                `xml:"customerID,omitempty"`
	Options            *PaymentMethodOptions `xml:"options,omitempty"`
	PaymentMethodNonce string                `xml:"payment-method-nonce,omitempty"`
	RiskData           *RiskData             `xml:"risk-data,omitempty"`
	Token              string                `xml:"token,omitempty"`
}

CreditCardInput is used to create or update a credit card on braintree.

type CustomFields

type CustomFields map[string]string

CustomFields contains braintree custom fields as a map

func (CustomFields) MarshalXML

func (cf CustomFields) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML encodes CustomFields into xml

func (*CustomFields) UnmarshalXML

func (cf *CustomFields) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML decodes XML into CustomFields

type Customer

type Customer struct {
	Addresses []Address `xml:"addresses>address"`
	// AndroidPayCards
	// ApplePayCards
	Company        string       `xml:"company"`
	CreatedAt      time.Time    `xml:"created-at"`
	CreditCards    []CreditCard `xml:"credit-cards>credit-card"`
	CustomFields   CustomFields `xml:"custom-fields"`
	Email          string       `xml:"email"`
	Fax            string       `xml:"fax"`
	FirstName      string       `xml:"first-name"`
	ID             string       `xml:"id"`
	LastName       string       `xml:"last-name"`
	PaypalAccounts []Paypal     `xml:"paypal-accounts>paypal-account"`
	Phone          string       `xml:"phone"`
	UpdatedAt      time.Time    `xml:"updated-at"`
	Website        string       `xml:"website"`
}

Customer is a braintree customer.

func (Customer) PaymentMethods

func (c Customer) PaymentMethods() []PaymentMethod

PaymentMethods of a customer. Currently Credit Cards and Paypal accounts.

func (Customer) Subscriptions

func (c Customer) Subscriptions() []Subscription

Subscriptions of a customer.

type CustomerGW

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

CustomerGW is a Customer Gateway.

func (CustomerGW) Create

func (cgw CustomerGW) Create(customer CustomerInput) (*Customer, error)

Create a Customer on braintree.

func (CustomerGW) Delete

func (cgw CustomerGW) Delete(id string) error

Delete a Customer on braintree.

func (CustomerGW) Find

func (cgw CustomerGW) Find(id string) (*Customer, error)

Find a Customer with a given id on braintree.

func (CustomerGW) Update

func (cgw CustomerGW) Update(customer CustomerInput) (*Customer, error)

Update a Customer on braintree.

ID is required.

type CustomerInput

type CustomerInput struct {
	XMLName            xml.Name
	Company            string           `xml:"company,omitempty"`
	CreditCard         *CreditCardInput `xml:"credit-card,omitempty"`
	CustomFields       CustomFields     `xml:"custom-fields,omitempty"`
	Email              string           `xml:"email,omitempty"`
	Fax                string           `xml:"fax,omitempty"`
	FirstName          string           `xml:"first-name,omitempty"`
	ID                 string           `xml:"id,omitempty"`
	LastName           string           `xml:"last-name,omitempty"`
	PaymentMethodNonce string           `xml:"payment-method-nonce,omitempty"`
	Phone              string           `xml:"phone,omitempty"`
	RiskData           *RiskData        `xml:"risk-data,omitempty"`
	Website            string           `xml:"website,omitempty"`
}

CustomerInput is used to create or update a customer.

type GatewayError

type GatewayError struct {
	Message string
}

A GatewayError is returned from braintree if a payment is blocked by gateway settings of the braintree account.

func (*GatewayError) Error

func (e *GatewayError) Error() string

type PaymentMethod

type PaymentMethod interface {
	// contains filtered or unexported methods
}

A PaymentMethod is currently a *CreditCard or *Paypal.

type PaymentMethodGW

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

PaymentMethodGW is a payment method gateway.

func (PaymentMethodGW) Create

Create a payment method on braintree.

func (PaymentMethodGW) Delete

func (pgw PaymentMethodGW) Delete(token string) error

Delete a payment method on braintree.

func (PaymentMethodGW) Find

func (pgw PaymentMethodGW) Find(token string) (PaymentMethod, error)

Find a payment method on braintree.

func (PaymentMethodGW) Update

Update a payment method on braintree.

Token is required.

type PaymentMethodInput

type PaymentMethodInput struct {
	XMLName            xml.Name
	BillingAddress     *AddressInput         `xml:"billing-address,omitempty"`
	BillingAddressID   string                `xml:"billing-address-id,omitempty"`
	CardholderName     string                `xml:"cardholder-name,omitempty"`
	CustomerID         string                `xml:"customer-id"`
	Options            *PaymentMethodOptions `xml:"options,omitempty"`
	PaymentMethodNonce string                `xml:"payment-method-nonce"`
	RiskData           *RiskData             `xml:"risk-data,omitempty"`
	Token              string                `xml:"token,omitempty"`
}

PaymentMethodInput is used to create a payment method on braintree.

CustomerID and PaymentMethodNonce are required.

type PaymentMethodOptions

type PaymentMethodOptions struct {
	FailOnDuplicatePaymentMethod bool   `xml:"fail-on-duplicate-payment-method,omitempty"`
	MakeDefault                  bool   `xml:"make-default,omitempty"`
	VerificationAmount           string `xml:"verification-amount,omitempty"`
	VerificationMerchantID       string `xml:"verification-merchant-id,omitempty"`
	VerifyCard                   bool   `xml:"verify-card,omitempty"`
}

PaymentMethodOptions can be used as part of a PaymentMethodInput.

type Paypal

type Paypal struct {
	BillingAgreementID string         `xml:"billing-agreement-id"`
	CreatedAt          time.Time      `xml:"created-at"`
	CustomerID         string         `xml:"customer-id"`
	Default            bool           `xml:"default"`
	Email              string         `xml:"email"`
	ImageURL           string         `xml:"image-url"`
	Subscriptions      []Subscription `xml:"subscriptions>subscription"`
	Token              string         `xml:"token"`
	UpdatedAt          time.Time      `xml:"updated-at"`
}

A Paypal account on braintree.

type Plan

type Plan struct {
	// AddOns
	// BillingDayOfMonth int       `xml:"billing-day-of-month"`
	BillingFrequency int       `xml:"billing-frequency"`
	CreatedAt        time.Time `xml:"created-at"`
	CurrencyISOCode  string    `xml:"currency-iso-code"`
	Description      string    `xml:"description"`
	// Discounts
	ID   string `xml:"id"`
	Name string `xml:"name"`
	// NumberOfBillingCycles int    `xml:"number-of-billing-cycles"`
	Price decimal.Decimal `xml:"price"`
	// TrialDuration     int       `xml:"trial-duration"`
	// TrialDurationUnit string    `xml:"trial-duration_unit"`
	TrialPeriod bool      `xml:"trial-period"`
	UpdatedAt   time.Time `xml:"updated-at"`
}

A Plan for a braintree subscription.

type PlanGW

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

PlanGW is a Plan Gateway.

func (PlanGW) All

func (pwg PlanGW) All() ([]Plan, error)

All returns all Plans in the merchant accounts.

type ProcessorError

type ProcessorError struct {
	Code    int
	Message string
}

A ProcessorError is returned from braintree if a payment failed.

func (*ProcessorError) Error

func (e *ProcessorError) Error() string

type RiskData

type RiskData struct {
	CustomerBrowser string `xml:"customer-browser,omitempty"`
	CustomerIP      string `xml:"customer-ip,omitempty"`
}

RiskData can be used as part of some input structs.

type Subscription

type Subscription struct {
	// AddOns
	Balance                decimal.Decimal `xml:"balance"`
	BillingPeriodEndDate   btdate.Date     `xml:"billing-period-end-date"`
	BillingDayOfMonth      int             `xml:"billing-day-of-month"`
	BillingPeriodStartDate btdate.Date     `xml:"billing-period-start-date"`
	CreatedAt              time.Time       `xml:"created-at"`
	CurrentBillingCycle    int             `xml:"current-billing-cycle"`
	DaysPastDue            sql.NullInt64   `xml:"days-past-due"`
	// Descriptor
	// Discounts
	FailureCount            int             `xml:"failure-count"`
	ID                      string          `xml:"id"`
	MerchantAccountID       string          `xml:"merchant-account-id"`
	NeverExpires            bool            `xml:"never-expires"`
	NextBillAmount          decimal.Decimal `xml:"next-bill-amount"`
	NextBillingDate         btdate.Date     `xml:"next-billing-date"`
	NextBillingPeriodAmount decimal.Decimal `xml:"next-billing-period-amount"`
	NumberOfBillingCycles   sql.NullInt64   `xml:"number-of-billing-cycles"`
	PaidThroughDate         btdate.Date     `xml:"paid-through-date"`
	PaymentMethodToken      string          `xml:"payment-method-token"`
	PlanID                  string          `xml:"plan-id"`
	Price                   decimal.Decimal `xml:"price"`
	Status                  string          `xml:"status"`
	// StatusHistory
	Transactions      []Transaction  `xml:"transactions>transaction"`
	TrialDuration     sql.NullInt64  `xml:"trial-duration"`
	TrialDurationUnit sql.NullString `xml:"trial-duration-unit"`
	TrialPeriod       bool           `xml:"trial-period"`
	UpdatedAt         time.Time      `xml:"updated-at"`
}

A Subscription on braintree.

type SubscriptionGW

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

SubscriptionGW is a Subscription Gateway.

func (SubscriptionGW) Cancel

func (sgw SubscriptionGW) Cancel(id string) (*Subscription, error)

Cancel a subscription on braintree.

func (SubscriptionGW) Create

func (sgw SubscriptionGW) Create(subscription SubscriptionInput) (*Subscription, error)

Create a subscription on braintree.

One of PaymentMethodNonce or PaymentMethodToken is required. PlanID is required.

func (SubscriptionGW) Find

func (sgw SubscriptionGW) Find(id string) (*Subscription, error)

Find a subscription with a given subscription id on braintree.

func (SubscriptionGW) RetryCharge

func (sgw SubscriptionGW) RetryCharge(id string) error

RetryCharge will retry to charge a Past Due subscription.

func (SubscriptionGW) Update

func (sgw SubscriptionGW) Update(subscription SubscriptionInput) (*Subscription, error)

Update a subscription on braintree.

ID is required.

type SubscriptionInput

type SubscriptionInput struct {
	XMLName xml.Name
	// AddOns
	BillingDayOfMonth int `xml:"billing-day-of-month,omitempty"`
	// Descriptor
	// Discounts
	FirstBillingDate      *btdate.Date `xml:"first-billing-date"`
	ID                    string       `xml:"id,omitempty"`
	MerchantAccountID     string       `xml:"merchant-account-id,omitempty"`
	NeverExpires          bool         `xml:"never-expires,omitempty"`
	NumberOfBillingCycles int          `xml:"number-of-billing-cycles,omitempty"`
	// Options
	PaymentMethodNonce string           `xml:"payment-method-nonce,omitempty"`
	PaymentMethodToken string           `xml:"payment-method-token,omitempty"`
	PlanID             string           `xml:"plan-id,omitempty"`
	Price              *decimal.Decimal `xml:"price,omitempty"`
	TrialDuration      int              `xml:"trial-duration,omitempty"`
	TrialDurationUnit  string           `xml:"trial-duration-unit,omitempty"`
	TrialPeriod        bool             `xml:"trial-period,omitempty"`
}

SubscriptionInput is used to create or update a subscription.

type Transaction

type Transaction struct {
	// AddOns
	AdditionalProcessorResponse string          `xml:"additional-processor-response"`
	Amount                      decimal.Decimal `xml:"amount"`
	// AndroidPayCard
	// ApplePayDetails
	// AVSErrorResponseCode
	// AVSPostalCodeResponseCode
	// AVSStreetAddressResponseCode
	BillingDetails Address   `xml:"billing-details"`
	Channel        string    `xml:"channel"`
	CreatedAt      time.Time `xml:"created-at"`
	// CreditCardDetails
	CurrencyISOCode string
	CustomFields    CustomFields `xml:"custom-fields"`
	// CustomerDetails
	// CVVResponseCode
	// Descriptor
	// DisbursementDetails
	// Discounts
	// Disputes
	EscrowStatus           string `xml:"escrow-status"`
	GatewayRejectionReason string `xml:"gateway-rejection-reason"`
	ID                     string `xml:"id"`
	MerchantAccountID      string `xml:"merchant-account-id"`
	OrderID                string `xml:"order-id"`
	PaymentInstrumentType  string `xml:"payment-instrument-type"`
	// PaypalDetails
	PlanID string `xml:"plan-id"`
	// ProcessorAuthoriationCode
	ProcessorResponseCode           string `xml:"processor-response-code"`
	ProcessorResponseText           string `xml:"processor-response-text"`
	ProcessorSettlementResponseCode string `xml:"processor-settlement-response-code"`
	ProcessorSettlementResponseText string `xml:"processor-settlement-response-text"`
	PurchaseOrderNumber             string `xml:"purchase-order-number"`
	// Recurring
	// RefundIDs
	RefundedTransactionID string `xml:"refunded-transaction-id"`
	// RiskData
	// ServiceFeeAmount`
	SettlementBatchID string `xml:"settlement-batch-id"`
	// ShippingDetails
	Status        string   `xml:"status"`
	StatusHistory []string `xml:"status-history"`
	// SubscriptionDetails
	SubscriptionID string `xml:"subscription-id"`
	// TaxAmount
	TaxExempt bool `xml:"tax-exempt"`
	// ThreeDSecureInfo
	Type      string    `xml:"type"`
	UpdatedAt time.Time `xml:"updated-at"`
}

A Transaction on braintree.

type TransactionGW

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

TransactionGW is a transaction gateway.

func (TransactionGW) Create

func (tgw TransactionGW) Create(transaction TransactionInput) (*Transaction, error)

Create a transaction on braintree.

One of PaymentMethodNonce or PaymentMethodToken is required. Amount and Type are required.

func (TransactionGW) Find

func (tgw TransactionGW) Find(id string) (*Transaction, error)

Find a transaction with a given transaction id on braintree.

func (TransactionGW) Refund

func (tgw TransactionGW) Refund(id string) (*Transaction, error)

Refund a transaction on braintree after settlement.

func (TransactionGW) Settle

func (tgw TransactionGW) Settle(id string) (*Transaction, error)

Settle a transaction on braintree.

This will only work in the sandbox environment.

func (TransactionGW) Void

func (tgw TransactionGW) Void(id string) (*Transaction, error)

Void a transactionon braintree before settlement.

type TransactionInput

type TransactionInput struct {
	XMLName          xml.Name
	Amount           decimal.Decimal `xml:"amount"`
	Billing          *AddressInput   `xml:"billing,omitempty"`
	BillingAddressID string          `xml:"billing-address-id,omitempty"`
	Channel          string          `xml:"channel,omitempty"`
	CustomFields     CustomFields    `xml:"custom-fields,omitempty"`
	Customer         *CustomerInput  `xml:"customer,omitempty"`
	CustomerID       string          `xml:"customer-id,omitempty"`
	// Descriptor
	DeviceData          string              `xml:"device-date,omitempty"`
	DeviceSessionID     string              `xml:"device-session-id,omitempty"`
	MerchantAccountID   string              `xml:"merchant-account-id,omitempty"`
	Options             *TransactionOptions `xml:"options,omitempty"`
	OrderID             string              `xml:"order-id,omitempty"`
	PaymentMethodNonce  string              `xml:"payment-method-nonce,omitempty"`
	PaymentMethodToken  string              `xml:"payment-method_token,omitempty"`
	PurchaseOrderNumber string              `xml:"purchase-order-number,omitempty"`
	Recurring           bool                `xml:"recurring,omitempty"`
	// RiskData
	// ServiceFeeAmount
	Shipping          *AddressInput `xml:"shipping,omitempty"`
	ShippingAddressID string        `xml:"shipping-address-id,omitempty"`
	// TaxAmount
	TaxExempt bool `xml:"tax-exempt,omitempty"`
	// ThreeDSecurePassThru
	TransactionSource string `xml:"transaction-source,omitempty"`
	Type              string `xml:"type,omitempty"`
}

TransactionInput is used to do a sale.

type TransactionOptions

type TransactionOptions struct {
	AddBillingAddressToPaymentMethod bool `xml:"add-billing-address-to-payment-method,omitempty"`
	HoldInEscrow                     bool `xml:"hold-in-escrow,omitempty"`
	// Paypal
	StoreInVault          bool `xml:"store-in-vault,omitempty"`
	StoreInVaultOnSuccess bool `xml:"store-in-vault-on-success,omitempty"`
	SubmitForSettlement   bool `xml:"submit-for-settlement,omitempty"`
}

TransactionOptions are optional settings for creating a transaction.

type ValidationError

type ValidationError struct {
	Attribute string `xml:"attribute"`
	Code      int    `xml:"code"`
	Message   string `xml:"message"`
}

A ValidationError is returned from braintree in response to an invalid api call.

func (*ValidationError) Error

func (e *ValidationError) Error() string

type WebhookNotification

type WebhookNotification struct {
	Kind      string         `xml:"kind"`
	Subject   WebhookSubject `xml:"subject"`
	Timestamp time.Time      `xml:"timestamp"`
}

WebhookNotification is an automated notifications from braintree via webhook.

type WebhookSubject

type WebhookSubject struct {
	Subscription *Subscription `xml:"subscription"`
	Transaction  *Transaction  `xml:"transaction"`
}

WebhookSubject might change in the future. Handles only Subscriptions and Transactions for now.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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