braintree

package module
v0.0.0-...-f111e9b Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: MIT Imports: 26 Imported by: 0

README

Braintree Go

NOTE: Figure 53 is not maintaining this package for public use, but we are sharing our changes with the public in case they are valuable, since we've benefitted from the work of other forks of this repository.

A Go client library for Braintree, the payments company behind awesome companies like GitHub, Heroku, and 37signals.

This is not an official client library. Braintree maintains server-side libraries for Ruby, Python, PHP, Perl, Node, C# and Java, but not Go. This package implements the core functionality of the other client libraries, but it's missing a few advanced features.

With that said, this package contains more than enough to get you started accepting payments using Braintree. If there's a feature the other client libraries implement that you really need, open an issue (or better yet, a pull request).

Usage

Setting up your credentials is easy.

import "github.com/braintree-go/braintree-go"

bt := braintree.New(
  braintree.Sandbox,
  "YOUR_BRAINTREE_MERCH_ID",
  "YOUR_BRAINTREE_PUB_KEY",
  "YOUR_BRAINTREE_PRIV_KEY",
)

So is creating your first transaction.

ctx := context.Background()
tx, err := bt.Transaction().Create(ctx, &braintree.TransactionRequest{
  Type: "sale",
  Amount: braintree.NewDecimal(100, 2), // 100 cents
  CreditCard: &braintree.CreditCard{
    Number:         "4111111111111111",
    ExpirationDate: "05/14",
  },
})

The error returned by these calls is typed. The package returns a generic error when something mechanical goes wrong, such as receiving malformed XML or being unable to connect to the Braintree gateway. However, if Braintree was able to process the request correctly, but was unable to fulfill it due to a semantic failure (such as the credit card being declined) then a BraintreeError type is returned.

In addition to creating transactions, you can also tokenize credit card information for repeat or subscription billing using the CreditCard, Customer, and Subscription types. This package is completely compatible with Braintree.js, so if you encrypt your customers' credit cards in the browser, you can pass them on to Braintree without ever seeing them yourself. This decreases your PCI regulatory exposure and helps to secure your users' data. See the examples folder for a working implementation.

Installation

The usual. go get github.com/braintree-go/braintree-go

Supported Go Versions
  • 1.7
  • 1.8
  • 1.9
  • 1.10
  • 1.11
  • 1.12
Documentation

Braintree provides a ton of documentation on how to use their API. I recommend you use the Ruby documentation when following along, as the Ruby client library is broadly similar to this one.

For details on this package, see GoDoc.

Testing

The integration tests run against a sandbox account created in the Braintree Sandbox. See TESTING.md for further instructions on how to set up your sandbox for integration testing.

You can run tests locally using the same credentials that Travis CI uses by using the credentials in .default.env. Simply cp .default.env .env if you use a tool that autoloads .env files, or source .default.env to load the credentials into your shell. Then run tests with go test -tags='unit integration' ./....

source .default.env
go test -tags='unit integration' ./...
Webhook Integration Testing

You can use the WebhookTestingGateway to write your own integration tests to verify your application is processing incoming webhook notifications correctly.

A simple example:

package integration_test

import (
  "testing"
  "net/http/httptest"

  "github.com/Figure53/braintree-go"
)

func TestMyWebhook(t *testing.T) {
  bt := braintree.New(
    braintree.Sandbox,
    "merchaint_id",
    "public_key",
    "private_key",
  )

  r, err := bt.WebhookTesting().Request(
    braintree.SubscriptionChargedSuccessfullyWebhook,
    "123", // id
  )
  if err != nil {
    t.Fatal(err)
  }

  // You can now send the payload and signature to your webhook handler
  // and test your application's busines logic

  w := httptest.NewRecorder()
  router.ServeHTTP(w, r)

  // assertions
}
License

The MIT License (MIT)

Copyright (c) 2013 Lionel Barrow

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributors

Documentation

Overview

Package braintree is a client library for Braintree.

Initializing

Initialize it with API Keys:

braintree.New(Sandbox, merchantId, publicKey, privateKey)

Initialize it with an Access Token:

braintree.NewWithAccessToken(accessToken)

Loggers and HTTP Clients

Optionally configure a logger and HTTP client:

bt := braintree.New(...)
bt.Logger = log.New(...)
bt.HttpClient = ...

Creating Transactions

Create transactions:

ctx := context.Background()
t, err := bt.Transaction().Create(ctx, &braintree.TransactionRequest{
	Type:   "sale",
	Amount: braintree.NewDecimal(100, 2), // $1.00
	PaymentMethodNonce: braintree.FakeNonceTransactable,
})

API Errors

API errors are intended to be consumed in two ways. One, they can be dealt with as a single unit:

t, err := bt.Transaction().Create(...)
err.Error() => "A top level error message"

Second, you can drill down to see specific error messages on a field-by-field basis:

err.For("Transaction").On("Base")[0].Message => "A more specific error message"

Index

Constants

View Source
const (
	// Exception messages
	BankRejected         = "bank_rejected"
	InsufficientFunds    = "insuffient_funds"
	AccountNotAuthorized = "account_not_authorized"

	// Followup actions
	ContactUs                = "contact_us"
	UpdateFundingInformation = "update_funding_information"
	None                     = "none"
)
View Source
const (
	FakeNonceTransactable                       = "fake-valid-nonce"
	FakeNonceConsumed                           = "fake-consumed-nonce"
	FakeNoncePayPalOneTimePayment               = "fake-paypal-one-time-nonce"
	FakeNoncePayPalFuturePayment                = "fake-paypal-future-nonce"
	FakeNonceApplePayVisa                       = "fake-apple-pay-visa-nonce"
	FakeNonceApplePayMastercard                 = "fake-apple-pay-mastercard-nonce"
	FakeNonceApplePayAmex                       = "fake-apple-pay-amex-nonce"
	FakeNonceAbstractTransactable               = "fake-abstract-transactable-nonce"
	FakeNoncePayPalBillingAgreement             = "fake-paypal-billing-agreement-nonce"
	FakeNonceEurope                             = "fake-europe-bank-account-nonce"
	FakeNonceCoinbase                           = "fake-coinbase-nonce"
	FakeNonceAndroidPay                         = "fake-android-pay-nonce"
	FakeNonceAndroidPayDiscover                 = "fake-android-pay-discover-nonce"
	FakeNonceAndroidPayVisa                     = "fake-android-pay-visa-nonce"
	FakeNonceAndroidPayMasterCard               = "fake-android-pay-mastercard-nonce"
	FakeNonceAndroidPayAmEx                     = "fake-android-pay-amex-nonce"
	FakeNonceAmexExpressCheckout                = "fake-amex-express-checkout-nonce"
	FakeNonceVenmoAccount                       = "fake-venmo-account-nonce"
	FakeNonceTransactableVisa                   = "fake-valid-visa-nonce"
	FakeNonceTransactableAmEx                   = "fake-valid-amex-nonce"
	FakeNonceTransactableMasterCard             = "fake-valid-mastercard-nonce"
	FakeNonceTransactableDiscover               = "fake-valid-discover-nonce"
	FakeNonceTransactableJCB                    = "fake-valid-jcb-nonce"
	FakeNonceTransactableMaestro                = "fake-valid-maestro-nonce"
	FakeNonceTransactableDinersClub             = "fake-valid-dinersclub-nonce"
	FakeNonceTransactablePrepaid                = "fake-valid-prepaid-nonce"
	FakeNonceTransactableCommercial             = "fake-valid-commercial-nonce"
	FakeNonceTransactableDurbinRegulated        = "fake-valid-durbin-regulated-nonce"
	FakeNonceTransactableHealthcare             = "fake-valid-healthcare-nonce"
	FakeNonceTransactableDebit                  = "fake-valid-debit-nonce"
	FakeNonceTransactablePayroll                = "fake-valid-payroll-nonce"
	FakeNonceTransactableNoIndicators           = "fake-valid-no-indicators-nonce"
	FakeNonceTransactableUnknownIndicators      = "fake-valid-unknown-indicators-nonce"
	FakeNonceTransactableCountryOfIssuanceUSA   = "fake-valid-country-of-issuance-usa-nonce"
	FakeNonceTransactableCountryOfIssuanceCAD   = "fake-valid-country-of-issuance-cad-nonce"
	FakeNonceTransactableIssuingBankNetworkOnly = "fake-valid-issuing-bank-network-only-nonce"
	FakeNonceProcessorDeclinedVisa              = "fake-processor-declined-visa-nonce"
	FakeNonceProcessorDeclinedMasterCard        = "fake-processor-declined-mastercard-nonce"
	FakeNonceProcessorDeclinedAmEx              = "fake-processor-declined-amex-nonce"
	FakeNonceProcessorDeclinedDiscover          = "fake-processor-declined-discover-nonce"
	FakeNonceProcessorFailureJCB                = "fake-processor-failure-jcb-nonce"
	FakeNonceLuhnInvalid                        = "fake-luhn-invalid-nonce"
	FakeNoncePayPalFuturePaymentRefreshToken    = "fake-paypal-future-refresh-token-nonce"
	FakeNonceSEPA                               = "fake-sepa-bank-account-nonce"
	FakeNonceMasterpassAmEx                     = "fake-masterpass-amex-nonce"
	FakeNonceMasterpassDiscover                 = "fake-masterpass-discover-nonce"
	FakeNonceMasterpassMaestro                  = "fake-masterpass-maestro-nonce"
	FakeNonceMasterpassMasterCard               = "fake-masterpass-mastercard-nonce"
	FakeNonceMasterpassVisa                     = "fake-masterpass-visa-nonce"
	FakeNonceGatewayRejectedFraud               = "fake-gateway-rejected-fraud-nonce"
	FakeNonceVisaCheckoutVisa                   = "fake-visa-checkout-visa-nonce"
	FakeNonceVisaCheckoutAmEx                   = "fake-visa-checkout-amex-nonce"
	FakeNonceVisaCheckoutMasterCard             = "fake-visa-checkout-mastercard-nonce"
	FakeNonceVisaCheckoutDiscover               = "fake-visa-checkout-discover-nonce"
)
View Source
const (
	FUNDING_DEST_BANK         = "bank"
	FUNDING_DEST_MOBILE_PHONE = "mobile_phone"
	FUNDING_DEST_EMAIL        = "email"
)
View Source
const (
	ModificationKindDiscount = "discount"
	ModificationKindAddOn    = "add_on"
)
View Source
const (
	SubscriptionTrialDurationUnitDay   = "day"
	SubscriptionTrialDurationUnitMonth = "month"
)
View Source
const (
	CheckWebhook                             = "check"
	DisbursementWebhook                      = "disbursement"
	DisbursementExceptionWebhook             = "disbursement_exception"
	SubscriptionCanceledWebhook              = "subscription_canceled"
	SubscriptionChargedSuccessfullyWebhook   = "subscription_charged_successfully"
	SubscriptionChargedUnsuccessfullyWebhook = "subscription_charged_unsuccessfully"
	SubscriptionExpiredWebhook               = "subscription_expired"
	SubscriptionTrialEndedWebhook            = "subscription_trial_ended"
	SubscriptionWentActiveWebhook            = "subscription_went_active"
	SubscriptionWentPastDueWebhook           = "subscription_went_past_due"
	SubMerchantAccountApprovedWebhook        = "sub_merchant_account_approved"
	SubMerchantAccountDeclinedWebhook        = "sub_merchant_account_declined"
	PartnerMerchantConnectedWebhook          = "partner_merchant_connected"
	PartnerMerchantDisconnectedWebhook       = "partner_merchant_disconnected"
	PartnerMerchantDeclinedWebhook           = "partner_merchant_declined"
	TransactionSettledWebhook                = "transaction_settled"
	TransactionSettlementDeclinedWebhook     = "transaction_settlement_declined"
	TransactionDisbursedWebhook              = "transaction_disbursed"
	DisputeOpenedWebhook                     = "dispute_opened"
	DisputeLostWebhook                       = "dispute_lost"
	DisputeWonWebhook                        = "dispute_won"
	AccountUpdaterDailyReportWebhook         = "account_updater_daily_report"
)
View Source
const LibraryVersion = "0.22.0"

Variables

View Source
var (
	Development = NewEnvironment("http://localhost:3000")
	Sandbox     = NewEnvironment("https://api.sandbox.braintreegateway.com:443")
	Production  = NewEnvironment("https://api.braintreegateway.com:443")
)

Functions

This section is empty.

Types

type APIError

type APIError interface {
	error
	StatusCode() int
}

type AVSResponseCode

type AVSResponseCode string
const (
	// The postal code or street address provided matches the information on file with the cardholder's bank.
	AVSResponseCodeMatches AVSResponseCode = "M"

	// The postal code or street address provided does not match the information on file with the cardholder's bank.
	AVSResponseCodeDoesNotMatch AVSResponseCode = "N"

	// The card-issuing bank received the postal code or street address but did not verify whether it was correct.
	// This typically happens if the processor declines an authorization before the bank evaluates the postal code.
	AVSResponseCodeNotVerified AVSResponseCode = "U"

	// No postal code or street address was provided.
	AVSResponseCodeNotProvided AVSResponseCode = "I"

	// AVS information was provided but the card-issuing bank does not participate in address verification.
	// This typically indicates a card-issuing bank outside of the US, Canada, and the UK.
	AVSResponseCodeNotSupported AVSResponseCode = "S"

	// A system error prevented any verification of street address or postal code.
	AVSResponseCodeSystemError AVSResponseCode = "E"

	// AVS information was provided but this type of transaction does not support address verification.
	AVSResponseCodeNotApplicable AVSResponseCode = "A"
)

type AccountUpdaterDailyReport

type AccountUpdaterDailyReport struct {
	XMLName    xml.Name `xml:"account-updater-daily-report"`
	ReportDate string   `xml:"report-date"`
	ReportURL  string   `xml:"report-url"`
}

type AddModificationRequest

type AddModificationRequest struct {
	ModificationRequest
	InheritedFromID string `xml:"inherited-from-id,omitempty"`
}

type AddOn

type AddOn struct {
	XMLName string `xml:"add-on"`
	Modification
}

type AddOnGateway

type AddOnGateway struct {
	*Braintree
}

func (*AddOnGateway) All

func (g *AddOnGateway) All(ctx context.Context) ([]AddOn, error)

All gets all addons.

type AddOnList

type AddOnList struct {
	XMLName string  `xml:"add-ons"`
	AddOns  []AddOn `xml:"add-on"`
}

type Address

type Address struct {
	XMLName            xml.Name
	Id                 string     `xml:"id,omitempty"`
	CustomerId         string     `xml:"customer-id,omitempty"`
	FirstName          string     `xml:"first-name,omitempty"`
	LastName           string     `xml:"last-name,omitempty"`
	Company            string     `xml:"company,omitempty"`
	StreetAddress      string     `xml:"street-address,omitempty"`
	ExtendedAddress    string     `xml:"extended-address,omitempty"`
	Locality           string     `xml:"locality,omitempty"`
	Region             string     `xml:"region,omitempty"`
	PostalCode         string     `xml:"postal-code,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"`
	CreatedAt          *time.Time `xml:"created-at,omitempty"`
	UpdatedAt          *time.Time `xml:"updated-at,omitempty"`
}

type AddressGateway

type AddressGateway struct {
	*Braintree
}

func (*AddressGateway) Create

func (g *AddressGateway) Create(ctx context.Context, customerID string, a *AddressRequest) (*Address, error)

Create creates a new address for the specified customer id.

func (*AddressGateway) Delete

func (g *AddressGateway) Delete(ctx context.Context, customerId, addrId string) error

Delete deletes the address for the specified id and customer id.

func (*AddressGateway) Update

func (g *AddressGateway) Update(ctx context.Context, customerID, addrID string, a *AddressRequest) (*Address, error)

Update updates an address for the address id and customer id.

type AddressRequest

type AddressRequest struct {
	XMLName            xml.Name `xml:"address"`
	FirstName          string   `xml:"first-name,omitempty"`
	LastName           string   `xml:"last-name,omitempty"`
	Company            string   `xml:"company,omitempty"`
	StreetAddress      string   `xml:"street-address,omitempty"`
	ExtendedAddress    string   `xml:"extended-address,omitempty"`
	Locality           string   `xml:"locality,omitempty"`
	Region             string   `xml:"region,omitempty"`
	PostalCode         string   `xml:"postal-code,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"`
}

type Addresses

type Addresses struct {
	XMLName string     `xml:"addresses"`
	Address []*Address `xml:"address"`
}

type AndroidPayCard

type AndroidPayCard struct {
	XMLName             xml.Name       `xml:"android-pay-card"`
	Token               string         `xml:"token"`
	CardType            string         `xml:"-"`
	Last4               string         `xml:"-"`
	SourceCardType      string         `xml:"source-card-type"`
	SourceCardLast4     string         `xml:"source-card-last-4"`
	SourceDescription   string         `xml:"source-description"`
	VirtualCardType     string         `xml:"virtual-card-type"`
	VirtualCardLast4    string         `xml:"virtual-card-last-4"`
	ExpirationMonth     string         `xml:"expiration-month"`
	ExpirationYear      string         `xml:"expiration-year"`
	BIN                 string         `xml:"bin"`
	GoogleTransactionID string         `xml:"google-transaction-id"`
	ImageURL            string         `xml:"image-url"`
	Default             bool           `xml:"default"`
	CustomerId          string         `xml:"customer-id"`
	CreatedAt           *time.Time     `xml:"created-at"`
	UpdatedAt           *time.Time     `xml:"updated-at"`
	Subscriptions       *Subscriptions `xml:"subscriptions"`
}

func (*AndroidPayCard) AllSubscriptions

func (a *AndroidPayCard) AllSubscriptions() []*Subscription

AllSubscriptions returns all subscriptions for this paypal account, or nil if none present.

func (*AndroidPayCard) GetCustomerId

func (a *AndroidPayCard) GetCustomerId() string

func (*AndroidPayCard) GetImageURL

func (a *AndroidPayCard) GetImageURL() string

func (*AndroidPayCard) GetToken

func (a *AndroidPayCard) GetToken() string

func (*AndroidPayCard) IsDefault

func (a *AndroidPayCard) IsDefault() bool

func (*AndroidPayCard) UnmarshalXML

func (a *AndroidPayCard) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type AndroidPayCards

type AndroidPayCards struct {
	AndroidPayCard []*AndroidPayCard `xml:"android-pay-card"`
}

func (*AndroidPayCards) PaymentMethods

func (a *AndroidPayCards) PaymentMethods() []PaymentMethod

type AndroidPayDetails

type AndroidPayDetails struct {
	Token               string `xml:"token"`
	CardType            string `xml:"-"`
	Last4               string `xml:"-"`
	SourceCardType      string `xml:"source-card-type"`
	SourceCardLast4     string `xml:"source-card-last-4"`
	SourceDescription   string `xml:"source-description"`
	VirtualCardType     string `xml:"virtual-card-type"`
	VirtualCardLast4    string `xml:"virtual-card-last-4"`
	ExpirationMonth     string `xml:"expiration-month"`
	ExpirationYear      string `xml:"expiration-year"`
	BIN                 string `xml:"bin"`
	GoogleTransactionID string `xml:"google-transaction-id"`
	ImageURL            string `xml:"image-url"`
}

func (*AndroidPayDetails) UnmarshalXML

func (a *AndroidPayDetails) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type ApplePayCard

type ApplePayCard struct {
	XMLName               xml.Name       `xml:"apple-pay-card"`
	Token                 string         `xml:"token"`
	ImageURL              string         `xml:"image-url"`
	CardType              string         `xml:"card-type"`
	PaymentInstrumentName string         `xml:"payment-instrument-name"`
	SourceDescription     string         `xml:"source-description"`
	BIN                   string         `xml:"bin"`
	Last4                 string         `xml:"last-4"`
	ExpirationMonth       string         `xml:"expiration-month"`
	ExpirationYear        string         `xml:"expiration-year"`
	Expired               bool           `xml:"expired"`
	Default               bool           `xml:"default"`
	CustomerId            string         `xml:"customer-id"`
	CreatedAt             *time.Time     `xml:"created-at"`
	UpdatedAt             *time.Time     `xml:"updated-at"`
	Subscriptions         *Subscriptions `xml:"subscriptions"`
}

func (*ApplePayCard) AllSubscriptions

func (a *ApplePayCard) AllSubscriptions() []*Subscription

AllSubscriptions returns all subscriptions for this paypal account, or nil if none present.

func (*ApplePayCard) GetCustomerId

func (a *ApplePayCard) GetCustomerId() string

func (*ApplePayCard) GetImageURL

func (a *ApplePayCard) GetImageURL() string

func (*ApplePayCard) GetToken

func (a *ApplePayCard) GetToken() string

func (*ApplePayCard) IsDefault

func (a *ApplePayCard) IsDefault() bool

type ApplePayCards

type ApplePayCards struct {
	ApplePayCard []*ApplePayCard `xml:"apple-pay-card"`
}

func (*ApplePayCards) PaymentMethods

func (a *ApplePayCards) PaymentMethods() []PaymentMethod

type ApplePayDetails

type ApplePayDetails struct {
	Token                 string `xml:"token"`
	CardType              string `xml:"card-type"`
	PaymentInstrumentName string `xml:"payment-instrument-name"`
	SourceDescription     string `xml:"source-description"`
	CardholderName        string `xml:"cardholder-name"`
	ExpirationMonth       string `xml:"expiration-month"`
	ExpirationYear        string `xml:"expiration-year"`
	Last4                 string `xml:"last-4"`
	BIN                   string `xml:"bin"`
}

type Braintree

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

Braintree interacts with the Braintree API.

func New

func New(env Environment, merchId, pubKey, privKey string) *Braintree

New creates a Braintree client with API Keys.

func NewWithAccessToken

func NewWithAccessToken(accessToken string) (*Braintree, error)

NewWithAccessToken creates a Braintree client with an Access Token. Note: When using an access token, webhooks are unsupported and the WebhookNotification() function will panic.

func NewWithHttpClient

func NewWithHttpClient(env Environment, merchantId, publicKey, privateKey string, client *http.Client) *Braintree

NewWithHttpClient creates a Braintree client with API Keys and a HTTP Client.

func (*Braintree) AddOn

func (g *Braintree) AddOn() *AddOnGateway

func (*Braintree) Address

func (g *Braintree) Address() *AddressGateway

func (*Braintree) ClientToken

func (g *Braintree) ClientToken() *ClientTokenGateway

func (*Braintree) CreditCard

func (g *Braintree) CreditCard() *CreditCardGateway

func (*Braintree) Customer

func (g *Braintree) Customer() *CustomerGateway

func (*Braintree) Discount

func (g *Braintree) Discount() *DiscountGateway

func (*Braintree) Dispute

func (g *Braintree) Dispute() *DisputeGateway

func (*Braintree) Environment

func (g *Braintree) Environment() Environment

Environment returns the current environment.

func (*Braintree) MerchantAccount

func (g *Braintree) MerchantAccount() *MerchantAccountGateway

func (*Braintree) MerchantID

func (g *Braintree) MerchantID() string

MerchantID returns the current merchant id.

func (*Braintree) MerchantURL

func (g *Braintree) MerchantURL() string

MerchantURL returns the configured merchant's base URL for outgoing requests.

func (*Braintree) PayPalAccount

func (g *Braintree) PayPalAccount() *PayPalAccountGateway

func (*Braintree) PaymentMethod

func (g *Braintree) PaymentMethod() *PaymentMethodGateway

func (*Braintree) PaymentMethodNonce

func (g *Braintree) PaymentMethodNonce() *PaymentMethodNonceGateway

func (*Braintree) Plan

func (g *Braintree) Plan() *PlanGateway

func (*Braintree) Settlement

func (g *Braintree) Settlement() *SettlementGateway

func (*Braintree) Subscription

func (g *Braintree) Subscription() *SubscriptionGateway

func (*Braintree) Testing

func (g *Braintree) Testing() *TestingGateway

func (*Braintree) Transaction

func (g *Braintree) Transaction() *TransactionGateway

func (*Braintree) TransactionLineItem

func (g *Braintree) TransactionLineItem() *TransactionLineItemGateway

func (*Braintree) WebhookNotification

func (g *Braintree) WebhookNotification() *WebhookNotificationGateway

func (*Braintree) WebhookTesting

func (g *Braintree) WebhookTesting() *WebhookTestingGateway

type BraintreeError

type BraintreeError struct {
	ErrorMessage    string
	MerchantAccount *MerchantAccount
	Transaction     *Transaction
	// contains filtered or unexported fields
}

func (*BraintreeError) All

func (e *BraintreeError) All() []ValidationError

func (*BraintreeError) Error

func (e *BraintreeError) Error() string

func (*BraintreeError) For

func (e *BraintreeError) For(name string) *ValidationErrors

func (*BraintreeError) StatusCode

func (e *BraintreeError) StatusCode() int

func (*BraintreeError) UnmarshalXML

func (e *BraintreeError) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type CVVResponseCode

type CVVResponseCode string

CVVResponseCode is the response to the card verification value (CVV) provided by the customer.

const (
	// CVVResponseCodeMatches means the CVV provided matches the information on file with the cardholder's bank.
	CVVResponseCodeMatches CVVResponseCode = "M"

	// CVVResponseCodeDoesNotMatch means the The CVV provided does not match the information on file with the cardholder's bank.
	CVVResponseCodeDoesNotMatch CVVResponseCode = "N"

	// CVVResponseCodeNotVerified means the the card-issuing bank received the CVV but did not verify whether it was correct.
	// This typically happens if the processor declines an authorization before the bank evaluates the CVV.
	CVVResponseCodeNotVerified CVVResponseCode = "U"

	// CVVResponseCodeNotProvided means the no CVV was provided.
	CVVResponseCodeNotProvided CVVResponseCode = "I"

	// CVVResponseCodeIssuerDoesNotParticipate means the the CVV was provided
	// but the card-issuing bank does not participate in card verification.
	CVVResponseCodeIssuerDoesNotParticipate CVVResponseCode = "S"

	// CVVResponseCodeNotApplicable means the the CVV was provided
	// but this type of transaction does not support card verification.
	CVVResponseCodeNotApplicable CVVResponseCode = "A"
)

type ClientTokenGateway

type ClientTokenGateway struct {
	*Braintree
}

ClientTokenGateway represents the provider client token generation.

func (*ClientTokenGateway) Generate

func (g *ClientTokenGateway) Generate(ctx context.Context) (string, error)

Generate generates a new client token.

func (*ClientTokenGateway) GenerateWithCustomer

func (g *ClientTokenGateway) GenerateWithCustomer(ctx context.Context, customerID string) (string, error)

GenerateWithCustomer generates a new client token for the customer id.

func (*ClientTokenGateway) GenerateWithRequest

func (g *ClientTokenGateway) GenerateWithRequest(ctx context.Context, req *ClientTokenRequest) (string, error)

GenerateWithRequest generates a new client token using custom request options.

type ClientTokenRequest

type ClientTokenRequest struct {
	XMLName           string                     `xml:"client-token"`
	CustomerID        string                     `xml:"customer-id,omitempty"`
	MerchantAccountID string                     `xml:"merchant-account-id,omitempty"`
	Options           *ClientTokenRequestOptions `xml:"options,omitempty"`
	Version           int                        `xml:"version"`
}

ClientTokenRequest represents the parameters for the client token request.

type ClientTokenRequestOptions

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

ClientTokenRequestOptions represents options map for the client token request.

type CreditCard

type CreditCard struct {
	XMLName                xml.Name           `xml:"credit-card"`
	CustomerId             string             `xml:"customer-id,omitempty"`
	Token                  string             `xml:"token,omitempty"`
	PaymentMethodNonce     string             `xml:"payment-method-nonce,omitempty"`
	Number                 string             `xml:"number,omitempty"`
	ExpirationDate         string             `xml:"expiration-date,omitempty"`
	ExpirationMonth        string             `xml:"expiration-month,omitempty"`
	ExpirationYear         string             `xml:"expiration-year,omitempty"`
	CVV                    string             `xml:"cvv,omitempty"`
	Options                *CreditCardOptions `xml:"options,omitempty"`
	CreatedAt              *time.Time         `xml:"created-at,omitempty"`
	UpdatedAt              *time.Time         `xml:"updated-at,omitempty"`
	Bin                    string             `xml:"bin,omitempty"`
	CardType               string             `xml:"card-type,omitempty"`
	CardholderName         string             `xml:"cardholder-name,omitempty"`
	CustomerLocation       string             `xml:"customer-location,omitempty"`
	ImageURL               string             `xml:"image-url,omitempty"`
	Default                bool               `xml:"default,omitempty"`
	Expired                bool               `xml:"expired,omitempty"`
	Last4                  string             `xml:"last-4,omitempty"`
	Commercial             string             `xml:"commercial,omitempty"`
	Debit                  string             `xml:"debit,omitempty"`
	DurbinRegulated        string             `xml:"durbin-regulated,omitempty"`
	Healthcare             string             `xml:"healthcare,omitempty"`
	Payroll                string             `xml:"payroll,omitempty"`
	Prepaid                string             `xml:"prepaid,omitempty"`
	CountryOfIssuance      string             `xml:"country-of-issuance,omitempty"`
	IssuingBank            string             `xml:"issuing-bank,omitempty"`
	UniqueNumberIdentifier string             `xml:"unique-number-identifier,omitempty"`
	BillingAddress         *Address           `xml:"billing-address,omitempty"`
	Subscriptions          *Subscriptions     `xml:"subscriptions,omitempty"`
	ProductID              string             `xml:"product-id,omitempty"`
}

func (*CreditCard) AllSubscriptions

func (card *CreditCard) AllSubscriptions() []*Subscription

AllSubscriptions returns all subscriptions for this card, or nil if none present.

func (*CreditCard) GetCustomerId

func (card *CreditCard) GetCustomerId() string

GetCustomerId gets the customer id of the credit card.

func (*CreditCard) GetImageURL

func (card *CreditCard) GetImageURL() string

GetImageURL gets a URL that points to a payment method image file hosted by Braintree.

func (*CreditCard) GetToken

func (card *CreditCard) GetToken() string

GetToken gets the payment method token of the credit card.

func (*CreditCard) IsDefault

func (card *CreditCard) IsDefault() bool

IsDefault returns whether the credit card is the default for the customer.

type CreditCardGateway

type CreditCardGateway struct {
	*Braintree
}

func (*CreditCardGateway) Create

func (g *CreditCardGateway) Create(ctx context.Context, card *CreditCard) (*CreditCard, error)

Create creates a new credit card.

func (*CreditCardGateway) Delete

func (g *CreditCardGateway) Delete(ctx context.Context, card *CreditCard) error

Delete deletes a credit card.

func (*CreditCardGateway) ExpiringBetweenIDs

func (g *CreditCardGateway) ExpiringBetweenIDs(ctx context.Context, fromDate, toDate time.Time) (*SearchResult, error)

ExpiringBetweenIDs finds credit cards that expire between the specified dates, returning the IDs only. Use ExpiringBetweenPage to get pages of credit cards.

func (*CreditCardGateway) ExpiringBetweenPage

func (g *CreditCardGateway) ExpiringBetweenPage(ctx context.Context, fromDate, toDate time.Time, searchResult *SearchResult, page int) (*CreditCardSearchResult, error)

ExpiringBetweenPage gets the page of credit cards that expire between the specified dates. Use ExpiringBetweenIDs to start a search and get a list of IDs, and use its result object to get pages. Page numbers start at 1. Returns a nil result and nil error when no more results are available.

func (*CreditCardGateway) Find

func (g *CreditCardGateway) Find(ctx context.Context, token string) (*CreditCard, error)

Find finds a credit card by payment method token.

func (*CreditCardGateway) Update

func (g *CreditCardGateway) Update(ctx context.Context, card *CreditCard) (*CreditCard, error)

Update updates a credit card.

type CreditCardOptions

type CreditCardOptions struct {
	VerifyCard                    *bool  `xml:"verify-card,omitempty"`
	MakeDefault                   bool   `xml:"make-default,omitempty"`
	FailOnDuplicatePaymentMethod  bool   `xml:"fail-on-duplicate-payment-method,omitempty"`
	VerificationMerchantAccountId string `xml:"verification-merchant-account-id,omitempty"`
	UpdateExistingToken           string `xml:"update-existing-token,omitempty"`
}

type CreditCardSearchResult

type CreditCardSearchResult struct {
	TotalItems int
	TotalIDs   []string

	CurrentPageNumber int
	PageSize          int
	CreditCards       []*CreditCard
}

type CreditCards

type CreditCards struct {
	CreditCard []*CreditCard `xml:"credit-card"`
}

func (*CreditCards) PaymentMethods

func (cards *CreditCards) PaymentMethods() []PaymentMethod

type Customer

type Customer struct {
	XMLName            string                    `xml:"customer"`
	Id                 string                    `xml:"id"`
	GraphQLId          string                    `xml:"global-id"`
	FirstName          string                    `xml:"first-name"`
	LastName           string                    `xml:"last-name"`
	Company            string                    `xml:"company"`
	Email              string                    `xml:"email"`
	Phone              string                    `xml:"phone"`
	Fax                string                    `xml:"fax"`
	Website            string                    `xml:"website"`
	CustomFields       customfields.CustomFields `xml:"custom-fields"`
	CreditCard         *CreditCard               `xml:"credit-card"`
	CreditCards        *CreditCards              `xml:"credit-cards"`
	PayPalAccounts     *PayPalAccounts           `xml:"paypal-accounts"`
	VenmoAccounts      *VenmoAccounts            `xml:"venmo-accounts"`
	AndroidPayCards    *AndroidPayCards          `xml:"android-pay-cards"`
	ApplePayCards      *ApplePayCards            `xml:"apple-pay-cards"`
	PaymentMethodNonce string                    `xml:"payment-method-nonce"`
	Addresses          *Addresses                `xml:"addresses"`
	CreatedAt          *time.Time                `xml:"created-at"`
	UpdatedAt          *time.Time                `xml:"updated-at"`
}

func (*Customer) DefaultCreditCard

func (c *Customer) DefaultCreditCard() *CreditCard

DefaultCreditCard returns the default credit card, or nil

func (*Customer) DefaultPaymentMethod

func (c *Customer) DefaultPaymentMethod() PaymentMethod

DefaultPaymentMethod returns the default payment method, or nil

func (*Customer) PaymentMethods

func (c *Customer) PaymentMethods() []PaymentMethod

PaymentMethods returns a slice of all PaymentMethods this customer has

type CustomerGateway

type CustomerGateway struct {
	*Braintree
}

func (*CustomerGateway) Create

Create creates a new customer from the passed in customer object. If no ID is set, Braintree will assign one.

func (*CustomerGateway) Delete

func (g *CustomerGateway) Delete(ctx context.Context, id string) error

Delete deletes the customer with the given id.

func (*CustomerGateway) Find

func (g *CustomerGateway) Find(ctx context.Context, id string) (*Customer, error)

Find finds the customer with the given id.

func (*CustomerGateway) Search deprecated

Search finds customers matching the search query, returning the first page of results.

Deprecated: Use SearchIDs and SearchPage.

func (*CustomerGateway) SearchIDs

func (g *CustomerGateway) SearchIDs(ctx context.Context, query *SearchQuery) (*SearchResult, error)

SearchIDs finds customers matching the search query, returning the IDs only. Use SearchPage to get pages of customers.

func (*CustomerGateway) SearchPage

func (g *CustomerGateway) SearchPage(ctx context.Context, query *SearchQuery, searchResult *SearchResult, page int) (*CustomerSearchResult, error)

SearchPage gets the page of customers matching the search query. Use SearchIDs to start a search and get a list of IDs, use its result object to get pages. Page numbers start at 1. Returns a nil result and nil error when no more results are available.

func (*CustomerGateway) Update

Update updates any field that is set in the passed customer object. The ID field is mandatory.

type CustomerRequest

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

type CustomerSearchResult

type CustomerSearchResult struct {
	TotalItems int
	TotalIDs   []string

	CurrentPageNumber int
	PageSize          int
	Customers         []*Customer
}

type Decimal

type Decimal struct {
	Unscaled int64
	Scale    int
}

Decimal represents fixed precision numbers

func NewDecimal

func NewDecimal(unscaled int64, scale int) *Decimal

NewDecimal creates a new decimal number equal to unscaled ** 10 ^ (-scale)

func (*Decimal) Cmp

func (x *Decimal) Cmp(y *Decimal) int

Cmp compares x and y and returns:

-1 if x <  y
 0 if x == y
+1 if x >  y

func (*Decimal) MarshalText

func (d *Decimal) MarshalText() (text []byte, err error)

MarshalText outputs a decimal representation of the scaled number

func (*Decimal) String

func (d *Decimal) String() string

String returns string representation of Decimal

func (*Decimal) UnmarshalText

func (d *Decimal) UnmarshalText(text []byte) (err error)

UnmarshalText creates a Decimal from a string representation (e.g. 5.20) Currently only supports decimal strings

type Descriptor

type Descriptor struct {
	Name  string `xml:"name,omitempty"`
	Phone string `xml:"phone,omitempty"`
	URL   string `xml:"url,omitempty"`
}

type Disbursement

type Disbursement struct {
	XMLName            xml.Name         `xml:"disbursement"`
	Id                 string           `xml:"id"`
	ExceptionMessage   string           `xml:"exception-message"`
	DisbursementDate   *date.Date       `xml:"disbursement-date"`
	FollowUpAction     string           `xml:"follow-up-action"`
	Success            bool             `xml:"success"`
	Retry              bool             `xml:"retry"`
	Amount             *Decimal         `xml:"amount"`
	MerchantAccount    *MerchantAccount `xml:"merchant-account"`
	CurrencyIsoCode    string           `xml:"currency-iso-code"`
	SubmerchantAccount bool             `xml:"sub-merchant-account"`
	Status             string           `xml:"status"`
	TransactionIds     []string         `xml:"transaction-ids>item"`
}

func (*Disbursement) Transactions

type DisbursementDetails

type DisbursementDetails struct {
	XMLName                        xml.Name `xml:"disbursement-details"`
	DisbursementDate               string   `xml:"disbursement-date"`
	SettlementAmount               *Decimal `xml:"settlement-amount"`
	SettlementCurrencyIsoCode      string   `xml:"settlement-currency-iso-code"`
	SettlementCurrencyExchangeRate *Decimal `xml:"settlement-currency-exchange-rate"`
	FundsHeld                      bool     `xml:"funds-held"`
	Success                        bool     `xml:"success"`
}

type Discount

type Discount struct {
	XMLName string `xml:"discount"`
	Modification
}

type DiscountGateway

type DiscountGateway struct {
	*Braintree
}

func (*DiscountGateway) All

func (g *DiscountGateway) All(ctx context.Context) ([]Discount, error)

type DiscountList

type DiscountList struct {
	XMLName   string     `xml:"discounts"`
	Discounts []Discount `xml:"discount"`
}

type Dispute

type Dispute struct {
	XMLName           string                       `xml:"dispute"`
	AmountDisputed    *Decimal                     `xml:"amount-disputed"`
	AmountWon         *Decimal                     `xml:"amount-won"`
	CaseNumber        string                       `xml:"case-number"`
	CreatedAt         *time.Time                   `xml:"created-at"`
	CurrencyISOCode   string                       `xml:"currency-iso-code"`
	Evidence          []*DisputeEvidence           `xml:"evidence>evidence"`
	ID                string                       `xml:"id"`
	Kind              DisputeKind                  `xml:"kind"`
	MerchantAccountID string                       `xml:"merchant-account-id"`
	OriginalDisputeID string                       `xml:"original-dispute-id"`
	ProcessorComments string                       `xml:"processor-comments"`
	Reason            DisputeReason                `xml:"reason"`
	ReturnCode        string                       `xml:"return-code"`
	ReceivedDate      string                       `xml:"received-date"`
	ReferenceNumber   string                       `xml:"reference-number"`
	ReplyByDate       string                       `xml:"reply-by-date"`
	Status            DisputeStatus                `xml:"status"`
	StatusHistory     []*DisputeStatusHistoryEvent `xml:"status-history>status-history"`
	Transaction       *DisputeTransaction          `xml:"transaction"`
	UpdatedAt         *time.Time                   `xml:"updated-at"`
}

type DisputeEvidence

type DisputeEvidence struct {
	XMLName           string                  `xml:"evidence"`
	Comment           string                  `xml:"comment"`
	CreatedAt         *time.Time              `xml:"created-at"`
	ID                string                  `xml:"id"`
	SentToProcessorAt string                  `xml:"sent-to-processor-at"`
	URL               string                  `xml:"url"`
	Category          DisputeEvidenceCategory `xml:"category"`
	SequenceNumber    string                  `xml:"sequence-number"`
}

type DisputeEvidenceCategory

type DisputeEvidenceCategory string
const (
	DisputeEvidenceCategoryDeviceId                                   DisputeEvidenceCategory = "DEVICE_ID"
	DisputeEvidenceCategoryDeviceName                                 DisputeEvidenceCategory = "DEVICE_NAME"
	DisputeEvidenceCategoryPriorDigitalGoodsTransactionArn            DisputeEvidenceCategory = "PRIOR_DIGITAL_GOODS_TRANSACTION_ARN"
	DisputeEvidenceCategoryPriorDigitalGoodsTransactionDateTime       DisputeEvidenceCategory = "PRIOR_DIGITAL_GOODS_TRANSACTION_DATE_TIME"
	DisputeEvidenceCategoryDownloadDateTime                           DisputeEvidenceCategory = "DOWNLOAD_DATE_TIME"
	DisputeEvidenceCategoryGeographicalLocation                       DisputeEvidenceCategory = "GEOGRAPHICAL_LOCATION"
	DisputeEvidenceCategoryLegitPaymentsForSameMerchandise            DisputeEvidenceCategory = "LEGIT_PAYMENTS_FOR_SAME_MERCHANDISE"
	DisputeEvidenceCategoryMerchantWebsiteOrAppAccess                 DisputeEvidenceCategory = "MERCHANT_WEBSITE_OR_APP_ACCESS"
	DisputeEvidenceCategoryPriorNonDisputedTransactionArn             DisputeEvidenceCategory = "PRIOR_NON_DISPUTED_TRANSACTION_ARN"
	DisputeEvidenceCategoryPriorNonDisputedTransactionDateTime        DisputeEvidenceCategory = "PRIOR_NON_DISPUTED_TRANSACTION_DATE_TIME"
	DisputeEvidenceCategoryPriorNonDisputedTransactionEmailAddress    DisputeEvidenceCategory = "PRIOR_NON_DISPUTED_TRANSACTION_EMAIL_ADDRESS"
	DisputeEvidenceCategoryPriorNonDisputedTransactionIpAddress       DisputeEvidenceCategory = "PRIOR_NON_DISPUTED_TRANSACTION_IP_ADDRESS"
	DisputeEvidenceCategoryPriorNonDisputedTransactionPhoneNumber     DisputeEvidenceCategory = "PRIOR_NON_DISPUTED_TRANSACTION_PHONE_NUMBER"
	DisputeEvidenceCategoryPriorNonDisputedTransactionPhysicalAddress DisputeEvidenceCategory = "PRIOR_NON_DISPUTED_TRANSACTION_PHYSICAL_ADDRESS"
	DisputeEvidenceCategoryProfileSetupOrAppAccess                    DisputeEvidenceCategory = "PROFILE_SETUP_OR_APP_ACCESS"
	DisputeEvidenceCategoryProofOfAuthorizedSigner                    DisputeEvidenceCategory = "PROOF_OF_AUTHORIZED_SIGNER"
	DisputeEvidenceCategoryProofOfDeliveryEmpAddress                  DisputeEvidenceCategory = "PROOF_OF_DELIVERY_EMP_ADDRESS"
	DisputeEvidenceCategoryProofOfDelivery                            DisputeEvidenceCategory = "PROOF_OF_DELIVERY"
	DisputeEvidenceCategoryProofOfPossessionOrUsage                   DisputeEvidenceCategory = "PROOF_OF_POSSESSION_OR_USAGE"
	DisputeEvidenceCategoryPurchaserEmailAddress                      DisputeEvidenceCategory = "PURCHASER_EMAIL_ADDRESS"
	DisputeEvidenceCategoryPurchaserIpAddress                         DisputeEvidenceCategory = "PURCHASER_IP_ADDRESS"
	DisputeEvidenceCategoryPurchaserName                              DisputeEvidenceCategory = "PURCHASER_NAME"
	DisputeEvidenceCategoryRecurringTransactionArn                    DisputeEvidenceCategory = "RECURRING_TRANSACTION_ARN"
	DisputeEvidenceCategoryRecurringTransactionDateTime               DisputeEvidenceCategory = "RECURRING_TRANSACTION_DATE_TIME"
	DisputeEvidenceCategorySignedDeliveryForm                         DisputeEvidenceCategory = "SIGNED_DELIVERY_FORM"
	DisputeEvidenceCategorySignedOrderForm                            DisputeEvidenceCategory = "SIGNED_ORDER_FORM"
	DisputeEvidenceCategoryTicketProof                                DisputeEvidenceCategory = "TICKET_PROOF"
)

type DisputeGateway

type DisputeGateway struct {
	*Braintree
}

func (*DisputeGateway) Accept

func (g *DisputeGateway) Accept(ctx context.Context, disputeID string) error

func (*DisputeGateway) AddTextEvidence

func (g *DisputeGateway) AddTextEvidence(ctx context.Context, disputeID string, textEvidenceRequest *DisputeTextEvidenceRequest) (*DisputeEvidence, error)

func (*DisputeGateway) Finalize

func (g *DisputeGateway) Finalize(ctx context.Context, disputeID string) error

func (*DisputeGateway) Find

func (g *DisputeGateway) Find(ctx context.Context, disputeID string) (*Dispute, error)

func (*DisputeGateway) RemoveEvidence

func (g *DisputeGateway) RemoveEvidence(ctx context.Context, disputeID string, evidenceId string) error

type DisputeKind

type DisputeKind string
const (
	DisputeKindChargeback     DisputeKind = "chargeback"
	DisputeKindPreArbitration DisputeKind = "pre_arbitration"
	DisputeKindRetrieval      DisputeKind = "retrieval"
)

type DisputeReason

type DisputeReason string
const (
	DisputeReasonCancelledRecurringTransaction DisputeReason = "cancelled_recurring_transaction"
	DisputeReasonCreditNotProcessed            DisputeReason = "credit_not_processed"
	DisputeReasonDuplicate                     DisputeReason = "duplicate"
	DisputeReasonFraud                         DisputeReason = "fraud"
	DisputeReasonGeneral                       DisputeReason = "general"
	DisputeReasonInvalidAccount                DisputeReason = "invalid_account"
	DisputeReasonNotRecognized                 DisputeReason = "not_recognized"
	DisputeReasonProductNotReceived            DisputeReason = "product_not_received"
	DisputeReasonProductUnsatisfactory         DisputeReason = "product_unsatisfactory"
	DisputeReasonTransactionAmountDiffers      DisputeReason = "transaction_amount_differs"
)

type DisputeStatus

type DisputeStatus string
const (
	DisputeStatusAccepted DisputeStatus = "accepted"
	DisputeStatusDisputed DisputeStatus = "disputed"
	DisputeStatusExpired  DisputeStatus = "expired"
	DisputeStatusOpen     DisputeStatus = "open"
	DisputeStatusLost     DisputeStatus = "lost"
	DisputeStatusWon      DisputeStatus = "won"
)

type DisputeStatusHistoryEvent

type DisputeStatusHistoryEvent struct {
	XMLName          string     `xml:"status-history"`
	DisbursementDate string     `xml:"disbursement-date"`
	EffectiveDate    string     `xml:"effective-date"`
	Status           string     `xml:"status"`
	Timestamp        *time.Time `xml:"timestamp"`
}

type DisputeTextEvidenceRequest

type DisputeTextEvidenceRequest struct {
	XMLName        xml.Name                `xml:"evidence"`
	Content        string                  `xml:"comments"`
	Category       DisputeEvidenceCategory `xml:"category,omitempty"`
	SequenceNumber string                  `xml:"sequence-number,omitempty"`
}

type DisputeTransaction

type DisputeTransaction struct {
	XMLName                  string     `xml:"transaction"`
	Amount                   *Decimal   `xml:"amount"`
	CreatedAt                *time.Time `xml:"created-at"`
	ID                       string     `xml:"id"`
	OrderID                  string     `xml:"order-id"`
	PaymentInstrumentSubtype string     `xml:"payment-instrument-subtype"`
	PurchaseOrderNumber      string     `xml:"purchase-order-number"`
}

type Environment

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

func EnvironmentFromName

func EnvironmentFromName(name string) (Environment, error)

func NewEnvironment

func NewEnvironment(baseURL string) Environment

func (Environment) BaseURL

func (e Environment) BaseURL() string

type EscrowStatus

type EscrowStatus string
const (
	EscrowStatusHoldPending    EscrowStatus = "hold_pending"
	EscrowStatusHeld           EscrowStatus = "held"
	EscrowStatusReleasePending EscrowStatus = "release_pending"
	EscrowStatusReleased       EscrowStatus = "released"
	EscrowStatusRefunded       EscrowStatus = "refunded"
)

type GatewayRejectionReason

type GatewayRejectionReason string
const (
	GatewayRejectionReasonApplicationIncomplete GatewayRejectionReason = "application_incomplete"
	GatewayRejectionReasonAVS                   GatewayRejectionReason = "avs"
	GatewayRejectionReasonAVSAndCVV             GatewayRejectionReason = "avs_and_cvv"
	GatewayRejectionReasonCVV                   GatewayRejectionReason = "cvv"
	GatewayRejectionReasonDuplicate             GatewayRejectionReason = "duplicate"
	GatewayRejectionReasonFraud                 GatewayRejectionReason = "fraud"
	GatewayRejectionReasonThreeDSecure          GatewayRejectionReason = "three_d_secure"
	GatewayRejectionReasonUnrecognized          GatewayRejectionReason = "unrecognized"
)

type InvalidResponseError

type InvalidResponseError interface {
	error
	Response() *Response
}

type MerchantAccount

type MerchantAccount struct {
	XMLName                 string                         `xml:"merchant-account,omitempty"`
	Id                      string                         `xml:"id,omitempty"`
	MasterMerchantAccountId string                         `xml:"master-merchant-account-id,omitempty"`
	TOSAccepted             bool                           `xml:"tos_accepted,omitempty"`
	Individual              *MerchantAccountPerson         `xml:"individual,omitempty"`
	Business                *MerchantAccountBusiness       `xml:"business,omitempty"`
	FundingOptions          *MerchantAccountFundingOptions `xml:"funding,omitempty"`
	Status                  string                         `xml:"status,omitempty"`
}

type MerchantAccountBusiness

type MerchantAccountBusiness struct {
	LegalName string   `xml:"legal-name,omitempty"`
	DbaName   string   `xml:"dba-name,omitempty"`
	TaxId     string   `xml:"tax-id,omitempty"`
	Address   *Address `xml:"address,omitempty"`
}

type MerchantAccountFundingOptions

type MerchantAccountFundingOptions struct {
	Destination   string `xml:"destination,omitempty"`
	Email         string `xml:"email,omitempty"`
	MobilePhone   string `xml:"mobile-phone,omitempty"`
	AccountNumber string `xml:"account-number,omitempty"`
	RoutingNumber string `xml:"routing-number,omitempty"`
}

type MerchantAccountGateway

type MerchantAccountGateway struct {
	*Braintree
}

func (*MerchantAccountGateway) Create

Create a sub merchant account.

func (*MerchantAccountGateway) Find

Find finds the merchant account with the specified id.

func (*MerchantAccountGateway) Update

Update a sub merchant account.

type MerchantAccountPerson

type MerchantAccountPerson struct {
	FirstName   string   `xml:"first-name,omitempty"`
	LastName    string   `xml:"last-name,omitempty"`
	Email       string   `xml:"email,omitempty"`
	Phone       string   `xml:"phone,omitempty"`
	DateOfBirth string   `xml:"date-of-birth,omitempty"`
	SSN         string   `xml:"ssn,omitempty"`
	Address     *Address `xml:"address,omitempty"`
}

type Modification

type Modification struct {
	Id                    string     `xml:"id"`
	Amount                *Decimal   `xml:"amount"`
	Description           string     `xml:"description"`
	Kind                  string     `xml:"kind"`
	Name                  string     `xml:"name"`
	NeverExpires          bool       `xml:"never-expires"`
	Quantity              int        `xml:"quantity"`
	NumberOfBillingCycles int        `xml:"number-of-billing-cycles"`
	CurrentBillingCycle   int        `xml:"current-billing-cycle"`
	UpdatedAt             *time.Time `xml:"updated_at"`
}

type ModificationRequest

type ModificationRequest struct {
	Amount                *Decimal `xml:"amount,omitempty"`
	NumberOfBillingCycles int      `xml:"number-of-billing-cycles,omitempty"`
	Quantity              int      `xml:"quantity,omitempty"`
	NeverExpires          bool     `xml:"never-expires,omitempty"`
}

type ModificationsRequest

type ModificationsRequest struct {
	Add               []AddModificationRequest
	Update            []UpdateModificationRequest
	RemoveExistingIDs []string
}

func (ModificationsRequest) MarshalXML

func (m ModificationsRequest) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type MultiField

type MultiField struct {
	XMLName xml.Name
	Type    string   `xml:"type,attr"` // type=array
	Items   []string `xml:"item"`
}

type PayPalAccount

type PayPalAccount struct {
	XMLName       xml.Name              `xml:"paypal-account"`
	CustomerId    string                `xml:"customer-id,omitempty"`
	Token         string                `xml:"token,omitempty"`
	Email         string                `xml:"email,omitempty"`
	ImageURL      string                `xml:"image-url,omitempty"`
	CreatedAt     *time.Time            `xml:"created-at,omitempty"`
	UpdatedAt     *time.Time            `xml:"updated-at,omitempty"`
	Subscriptions *Subscriptions        `xml:"subscriptions,omitempty"`
	Default       bool                  `xml:"default,omitempty"`
	Options       *PayPalAccountOptions `xml:"options,omitempty"`
}

func (*PayPalAccount) AllSubscriptions

func (paypalAccount *PayPalAccount) AllSubscriptions() []*Subscription

AllSubscriptions returns all subscriptions for this paypal account, or nil if none present.

func (*PayPalAccount) GetCustomerId

func (paypalAccount *PayPalAccount) GetCustomerId() string

func (*PayPalAccount) GetImageURL

func (paypalAccount *PayPalAccount) GetImageURL() string

func (*PayPalAccount) GetToken

func (paypalAccount *PayPalAccount) GetToken() string

func (*PayPalAccount) IsDefault

func (paypalAccount *PayPalAccount) IsDefault() bool

type PayPalAccountGateway

type PayPalAccountGateway struct {
	*Braintree
}

func (*PayPalAccountGateway) Delete

func (g *PayPalAccountGateway) Delete(ctx context.Context, paypalAccount *PayPalAccount) error

func (*PayPalAccountGateway) Find

func (*PayPalAccountGateway) Update

func (g *PayPalAccountGateway) Update(ctx context.Context, paypalAccount *PayPalAccount) (*PayPalAccount, error)

type PayPalAccountOptions

type PayPalAccountOptions struct {
	MakeDefault bool `xml:"make-default,omitempty"`
}

type PayPalAccounts

type PayPalAccounts struct {
	PayPalAccount []*PayPalAccount `xml:"paypal-account"`
}

func (*PayPalAccounts) PaymentMethods

func (pp *PayPalAccounts) PaymentMethods() []PaymentMethod

type PayPalDetails

type PayPalDetails struct {
	PayerEmail                    string `xml:"payer-email,omitempty"`
	PaymentID                     string `xml:"payment-id,omitempty"`
	AuthorizationID               string `xml:"authorization-id,omitempty"`
	Token                         string `xml:"token,omitempty"`
	ImageURL                      string `xml:"image-url,omitempty"`
	DebugID                       string `xml:"debug-id,omitempty"`
	PayeeEmail                    string `xml:"payee-email,omitempty"`
	CustomField                   string `xml:"custom-field,omitempty"`
	PayerID                       string `xml:"payer-id,omitempty"`
	PayerFirstName                string `xml:"payer-first-name,omitempty"`
	PayerLastName                 string `xml:"payer-last-name,omitempty"`
	PayerStatus                   string `xml:"payer-status,omitempty"`
	SellerProtectionStatus        string `xml:"seller-protection-status,omitempty"`
	RefundID                      string `xml:"refund-id,omitempty"`
	CaptureID                     string `xml:"capture-id,omitempty"`
	TransactionFeeAmount          string `xml:"transaction-fee-amount,omitempty"`
	TransactionFeeCurrencyISOCode string `xml:"transaction-fee-currency-iso-code,omitempty"`
	Description                   string `xml:"description,omitempty"`
}

type PaymentInstrumentType

type PaymentInstrumentType string
const (
	PaymentInstrumentTypeAndroidPayCard   PaymentInstrumentType = "android_pay_card"
	PaymentInstrumentTypeApplePayCard     PaymentInstrumentType = "apple_pay_card"
	PaymentInstrumentTypeCreditCard       PaymentInstrumentType = "credit_card"
	PaymentInstrumentTypeMasterpassCard   PaymentInstrumentType = "masterpass_card"
	PaymentInstrumentTypePaypalAccount    PaymentInstrumentType = "paypal_account"
	PaymentInstrumentTypeVenmoAccount     PaymentInstrumentType = "venmo_account"
	PaymentInstrumentTypeVisaCheckoutCard PaymentInstrumentType = "visa_checkout_card"
)

type PaymentMethod

type PaymentMethod interface {
	GetCustomerId() string
	GetToken() string
	IsDefault() bool
	GetImageURL() string
}

type PaymentMethodGateway

type PaymentMethodGateway struct {
	*Braintree
}

func (*PaymentMethodGateway) Create

func (g *PaymentMethodGateway) Create(ctx context.Context, paymentMethodRequest *PaymentMethodRequest) (PaymentMethod, error)

func (*PaymentMethodGateway) Delete

func (g *PaymentMethodGateway) Delete(ctx context.Context, token string) error

func (*PaymentMethodGateway) Find

func (*PaymentMethodGateway) Update

func (g *PaymentMethodGateway) Update(ctx context.Context, token string, paymentMethod *PaymentMethodRequest) (PaymentMethod, error)

type PaymentMethodNonce

type PaymentMethodNonce struct {
	Type             string                     `xml:"type"`
	Nonce            string                     `xml:"nonce"`
	Details          *PaymentMethodNonceDetails `xml:"details"`
	ThreeDSecureInfo *ThreeDSecureInfo          `xml:"three-d-secure-info"`
}

type PaymentMethodNonceDetails

type PaymentMethodNonceDetails struct {
	CardType string `xml:"card-type"`
	Last2    string `xml:"last-two"`
}

type PaymentMethodNonceGateway

type PaymentMethodNonceGateway struct {
	*Braintree
}

func (*PaymentMethodNonceGateway) Create

func (*PaymentMethodNonceGateway) Find

type PaymentMethodRequest

type PaymentMethodRequest struct {
	XMLName            xml.Name                     `xml:"payment-method"`
	CustomerId         string                       `xml:"customer-id,omitempty"`
	Token              string                       `xml:"token,omitempty"`
	PaymentMethodNonce string                       `xml:"payment-method-nonce,omitempty"`
	Options            *PaymentMethodRequestOptions `xml:"options,omitempty"`
}

type PaymentMethodRequestOptions

type PaymentMethodRequestOptions struct {
	MakeDefault                   bool   `xml:"make-default,omitempty"`
	FailOnDuplicatePaymentMethod  bool   `xml:"fail-on-duplicate-payment-method,omitempty"`
	VerifyCard                    *bool  `xml:"verify-card,omitempty"`
	VerificationMerchantAccountId string `xml:"verification-merchant-account-id,omitempty"`
}

type Plan

type Plan struct {
	XMLName               string       `xml:"plan"`
	Id                    string       `xml:"id"`
	MerchantId            string       `xml:"merchant-id"`
	BillingDayOfMonth     *int         `xml:"billing-day-of-month"`
	BillingFrequency      *int         `xml:"billing-frequency"`
	CurrencyISOCode       string       `xml:"currency-iso-code"`
	Description           string       `xml:"description"`
	Name                  string       `xml:"name"`
	NumberOfBillingCycles *int         `xml:"number-of-billing-cycles"`
	Price                 *Decimal     `xml:"price"`
	TrialDuration         *int         `xml:"trial-duration"`
	TrialDurationUnit     string       `xml:"trial-duration-unit"`
	TrialPeriod           bool         `xml:"trial-period"`
	CreatedAt             *time.Time   `xml:"created-at"`
	UpdatedAt             *time.Time   `xml:"updated-at"`
	AddOns                AddOnList    `xml:"add-ons"`
	Discounts             DiscountList `xml:"discounts"`
}

type PlanGateway

type PlanGateway struct {
	*Braintree
}

func (*PlanGateway) All

func (g *PlanGateway) All(ctx context.Context) ([]*Plan, error)

All returns all available plans

func (*PlanGateway) Find

func (g *PlanGateway) Find(ctx context.Context, id string) (*Plan, error)

Find returns the plan with the specified id, or nil

type Plans

type Plans struct {
	XMLName string  `xml:"plans"`
	Plan    []*Plan `xml:"plan"`
}

type ProcessorResponseCode

type ProcessorResponseCode int
const (
	ProcessorResponseCodeCardIssuerDeclinedCVV ProcessorResponseCode = 2010
)

func (ProcessorResponseCode) Int

func (rc ProcessorResponseCode) Int() int

func (ProcessorResponseCode) MarshalText

func (rc ProcessorResponseCode) MarshalText() ([]byte, error)

MarshalText returns a string in bytes of the number, or nil in the case it is zero.

func (*ProcessorResponseCode) UnmarshalText

func (rc *ProcessorResponseCode) UnmarshalText(text []byte) error

UnmarshalText fills the response code with the integer value if the text contains one in string form. If the text is zero length, the response code's value is unchanged but unmarshaling is successful.

type ProcessorResponseType

type ProcessorResponseType string
const (
	ProcessorResponseTypeApproved     ProcessorResponseType = "approved"
	ProcessorResponseTypeSoftDeclined ProcessorResponseType = "soft_declined"
	ProcessorResponseTypeHardDeclined ProcessorResponseType = "hard_declined"
)

type RangeField

type RangeField struct {
	XMLName xml.Name
	Is      float64 `xml:"is,omitempty"`
	Min     float64 `xml:"min,omitempty"`
	Max     float64 `xml:"max,omitempty"`
}

type Record

type Record struct {
	XMLName           string   `xml:"record"`
	CardType          string   `xml:"card-type"`
	Count             int      `xml:"count"`
	MerchantAccountId string   `xml:"merchant-account-id"`
	Kind              string   `xml:"kind"`
	AmountSettled     *Decimal `xml:"amount-settled"`
}

type Response

type Response struct {
	*http.Response
	Body []byte
}

type RiskData

type RiskData struct {
	ID       string `xml:"id"`
	Decision string `xml:"decision"`
}

type RiskDataRequest

type RiskDataRequest struct {
	CustomerBrowser string `xml:"customer-browser"`
	CustomerIP      string `xml:"customer-ip"`
}

type SearchQuery

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

func (*SearchQuery) AddMultiField

func (s *SearchQuery) AddMultiField(field string) *MultiField

func (*SearchQuery) AddRangeField

func (s *SearchQuery) AddRangeField(field string) *RangeField

func (*SearchQuery) AddTextField

func (s *SearchQuery) AddTextField(field string) *TextField

func (*SearchQuery) AddTimeField

func (s *SearchQuery) AddTimeField(field string) *TimeField

func (*SearchQuery) MarshalXML

func (s *SearchQuery) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type SearchResult

type SearchResult struct {
	PageSize  int
	PageCount int
	IDs       []string
}

type Settlement

type Settlement struct {
	XMLName string `xml:"settlement_batch_summary"`
	Date    string `xml:"settlement_date"`
}

type SettlementBatchSummary

type SettlementBatchSummary struct {
	XMLName string     `xml:"settlement-batch-summary"`
	Records XMLRecords `xml:"records"`
}

type SettlementGateway

type SettlementGateway struct {
	*Braintree
}

func (*SettlementGateway) Generate

type SignatureError

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

func (SignatureError) Error

func (i SignatureError) Error() string

type Subscription

type Subscription struct {
	XMLName                 string                     `xml:"subscription"`
	Id                      string                     `xml:"id"`
	Balance                 *Decimal                   `xml:"balance"`
	BillingDayOfMonth       string                     `xml:"billing-day-of-month"`
	BillingPeriodEndDate    string                     `xml:"billing-period-end-date"`
	BillingPeriodStartDate  string                     `xml:"billing-period-start-date"`
	CurrentBillingCycle     string                     `xml:"current-billing-cycle"`
	DaysPastDue             string                     `xml:"days-past-due"`
	FailureCount            string                     `xml:"failure-count"`
	FirstBillingDate        string                     `xml:"first-billing-date"`
	MerchantAccountId       string                     `xml:"merchant-account-id"`
	NeverExpires            bool                       `xml:"never-expires"`
	NextBillAmount          *Decimal                   `xml:"next-bill-amount"`
	NextBillingPeriodAmount *Decimal                   `xml:"next-billing-period-amount"`
	NextBillingDate         string                     `xml:"next-billing-date"`
	NumberOfBillingCycles   *int                       `xml:"number-of-billing-cycles"`
	PaidThroughDate         string                     `xml:"paid-through-date"`
	PaymentMethodToken      string                     `xml:"payment-method-token"`
	PlanId                  string                     `xml:"plan-id"`
	Price                   *Decimal                   `xml:"price"`
	Status                  SubscriptionStatus         `xml:"status"`
	TrialDuration           string                     `xml:"trial-duration"`
	TrialDurationUnit       string                     `xml:"trial-duration-unit"`
	TrialPeriod             bool                       `xml:"trial-period"`
	Transactions            *Transactions              `xml:"transactions"`
	Options                 *SubscriptionOptions       `xml:"options"`
	StatusEvents            []*SubscriptionStatusEvent `xml:"status-history>status-event"`
	Descriptor              *Descriptor                `xml:"descriptor"`
	AddOns                  *AddOnList                 `xml:"add-ons"`
	Discounts               *DiscountList              `xml:"discounts"`
	CreatedAt               *time.Time                 `xml:"created-at,omitempty"`
	UpdatedAt               *time.Time                 `xml:"updated-at,omitempty"`
}

type SubscriptionDetails

type SubscriptionDetails struct {
	BillingPeriodStartDate string `xml:"billing-period-start-date"`
	BillingPeriodEndDate   string `xml:"billing-period-end-date"`
}

type SubscriptionGateway

type SubscriptionGateway struct {
	*Braintree
}

func (*SubscriptionGateway) Cancel

func (g *SubscriptionGateway) Cancel(ctx context.Context, subId string) (*Subscription, error)

func (*SubscriptionGateway) Create

func (*SubscriptionGateway) Find

func (g *SubscriptionGateway) Find(ctx context.Context, subId string) (*Subscription, error)

func (*SubscriptionGateway) RetryCharge

RetryCharge retries to charge for a Subscription. All options, including the Subscription ID, are to be provided by the SubscriptionTransactionRequest passed as an argument. Note that the Amount has to be > 0.

func (*SubscriptionGateway) Search deprecated

Search finds subscriptions matching the search query, returning the first page of results. Use SearchNext to get subsequent pages.

Deprecated: Use SearchIDs and SearchPage.

func (*SubscriptionGateway) SearchIDs

func (g *SubscriptionGateway) SearchIDs(ctx context.Context, query *SearchQuery) (*SearchResult, error)

SearchIDs finds subscriptions matching the search query, returning the IDs only. Use SearchPage to get pages of subscriptions.

func (*SubscriptionGateway) SearchNext deprecated

SearchNext finds the next page of Subscriptions matching the search query. Use Search to start a search and get the first page of results. Returns a nil result and nil error when no more results are available.

Deprecated: Use SearchIDs and SearchPage.

func (*SubscriptionGateway) SearchPage

func (g *SubscriptionGateway) SearchPage(ctx context.Context, query *SearchQuery, searchResult *SearchResult, page int) (*SubscriptionSearchResult, error)

SearchPage gets the page of subscriptions matching the search query. Use SearchIDs to start a search and get a list of IDs, and use its result object to get pages. Page numbers start at 1. Returns a nil result and nil error when no more results are available.

func (*SubscriptionGateway) Update

type SubscriptionOptions

type SubscriptionOptions struct {
	DoNotInheritAddOnsOrDiscounts        bool `xml:"do-not-inherit-add-ons-or-discounts,omitempty"`
	ProrateCharges                       bool `xml:"prorate-charges,omitempty"`
	ReplaceAllAddOnsAndDiscounts         bool `xml:"replace-all-add-ons-and-discounts,omitempty"`
	RevertSubscriptionOnProrationFailure bool `xml:"revert-subscription-on-proration-failure,omitempty"`
	StartImmediately                     bool `xml:"start-immediately,omitempty"`
}

type SubscriptionRequest

type SubscriptionRequest struct {
	XMLName               string                `xml:"subscription"`
	Id                    string                `xml:"id,omitempty"`
	BillingDayOfMonth     *int                  `xml:"billing-day-of-month,omitempty"`
	FailureCount          string                `xml:"failure-count,omitempty"`
	FirstBillingDate      string                `xml:"first-billing-date,omitempty"`
	MerchantAccountId     string                `xml:"merchant-account-id,omitempty"`
	NeverExpires          *bool                 `xml:"never-expires,omitempty"`
	NumberOfBillingCycles *int                  `xml:"number-of-billing-cycles,omitempty"`
	Options               *SubscriptionOptions  `xml:"options,omitempty"`
	PaymentMethodNonce    string                `xml:"paymentMethodNonce,omitempty"`
	PaymentMethodToken    string                `xml:"paymentMethodToken,omitempty"`
	PlanId                string                `xml:"planId,omitempty"`
	Price                 *Decimal              `xml:"price,omitempty"`
	TrialDuration         string                `xml:"trial-duration,omitempty"`
	TrialDurationUnit     string                `xml:"trial-duration-unit,omitempty"`
	TrialPeriod           *bool                 `xml:"trial-period,omitempty"`
	Descriptor            *Descriptor           `xml:"descriptor,omitempty"`
	AddOns                *ModificationsRequest `xml:"add-ons,omitempty"`
	Discounts             *ModificationsRequest `xml:"discounts,omitempty"`
}

type SubscriptionSearchResult

type SubscriptionSearchResult struct {
	TotalItems int
	TotalIDs   []string

	CurrentPageNumber int
	PageSize          int
	Subscriptions     []*Subscription
}

type SubscriptionStatus

type SubscriptionStatus string
const (
	SubscriptionStatusActive       SubscriptionStatus = "Active"
	SubscriptionStatusCanceled     SubscriptionStatus = "Canceled"
	SubscriptionStatusExpired      SubscriptionStatus = "Expired"
	SubscriptionStatusPastDue      SubscriptionStatus = "Past Due"
	SubscriptionStatusPending      SubscriptionStatus = "Pending"
	SubscriptionStatusUnrecognized SubscriptionStatus = "Unrecognized"
)

type SubscriptionStatusEvent

type SubscriptionStatusEvent struct {
	Timestamp          time.Time          `xml:"timestamp"`
	Balance            *Decimal           `xml:"balance"`
	Price              *Decimal           `xml:"price"`
	Status             SubscriptionStatus `xml:"status"`
	CurrencyISOCode    string             `xml:"currency-iso-code"`
	User               string             `xml:"user"`
	PlanID             string             `xml:"plan-id"`
	SubscriptionSource string             `xml:"subscription-source"`
}

SubscriptionStatusEvent contains information about what and when something changed about the subscription.

type SubscriptionTransactionOptionsRequest

type SubscriptionTransactionOptionsRequest struct {
	SubmitForSettlement bool `xml:"submit-for-settlement"`
}

type SubscriptionTransactionRequest

type SubscriptionTransactionRequest struct {
	Amount         *Decimal
	SubscriptionID string
	Options        *SubscriptionTransactionOptionsRequest
}

func (*SubscriptionTransactionRequest) MarshalXML

type Subscriptions

type Subscriptions struct {
	Subscription []*Subscription `xml:"subscription"`
}

type TestingGateway

type TestingGateway struct {
	*Braintree
}

TestingGateway exports actions only available in the sandbox environment.

func (*TestingGateway) Settle

func (g *TestingGateway) Settle(ctx context.Context, transactionID string) (*Transaction, error)

Settle changes the transaction's status to settle.

func (*TestingGateway) SettlementConfirm

func (g *TestingGateway) SettlementConfirm(ctx context.Context, transactionID string) (*Transaction, error)

SettlementConfirm changes the transaction's status to settlement_confirm.

func (*TestingGateway) SettlementDecline

func (g *TestingGateway) SettlementDecline(ctx context.Context, transactionID string) (*Transaction, error)

SettlementDecline changes the transaction's status to settlement_decline.

func (*TestingGateway) SettlementPending

func (g *TestingGateway) SettlementPending(ctx context.Context, transactionID string) (*Transaction, error)

SettlementPending changes the transaction's status to settlement_pending.

type TextField

type TextField struct {
	XMLName    xml.Name
	Is         string `xml:"is,omitempty"`
	IsNot      string `xml:"is-not,omitempty"`
	StartsWith string `xml:"starts-with,omitempty"`
	EndsWith   string `xml:"ends-with,omitempty"`
	Contains   string `xml:"contains,omitempty"`
}

type ThreeDSecureEnrolled

type ThreeDSecureEnrolled string
const (
	ThreeDSecureEnrolledYes            ThreeDSecureEnrolled = "Y"
	ThreeDSecureEnrolledNo             ThreeDSecureEnrolled = "N"
	ThreeDSecureEnrolledUnavailable    ThreeDSecureEnrolled = "U"
	ThreeDSecureEnrolledBypass         ThreeDSecureEnrolled = "B"
	ThreeDSecureEnrolledRequestFailure ThreeDSecureEnrolled = "E"
)

type ThreeDSecureInfo

type ThreeDSecureInfo struct {
	Status                 ThreeDSecureStatus   `xml:"status"`
	Enrolled               ThreeDSecureEnrolled `xml:"enrolled"`
	LiabilityShiftPossible bool                 `xml:"liability-shift-possible"`
	LiabilityShifted       bool                 `xml:"liability-shifted"`
}

type ThreeDSecureStatus

type ThreeDSecureStatus string
const (
	ThreeDSecureStatusUnsupportedCard                              ThreeDSecureStatus = "unsupported_card"
	ThreeDSecureStatusLookupError                                  ThreeDSecureStatus = "lookup_error"
	ThreeDSecureStatusLookupEnrolled                               ThreeDSecureStatus = "lookup_enrolled"
	ThreeDSecureStatusLookupNotEnrolled                            ThreeDSecureStatus = "lookup_not_enrolled"
	ThreeDSecureStatusAuthenticateSuccessfulIssuerNotParticipating ThreeDSecureStatus = "authenticate_successful_issuer_not_participating"
	ThreeDSecureStatusAuthenticationUnavailable                    ThreeDSecureStatus = "authentication_unavailable"
	ThreeDSecureStatusAuthenticateSignatureVerificationFailed      ThreeDSecureStatus = "authenticate_signature_verification_failed"
	ThreeDSecureStatusAuthenticateSuccessful                       ThreeDSecureStatus = "authenticate_successful"
	ThreeDSecureStatusAuthenticateAttemptSuccessful                ThreeDSecureStatus = "authenticate_attempt_successful"
	ThreeDSecureStatusAuthenticateFailed                           ThreeDSecureStatus = "authenticate_failed"
	ThreeDSecureStatusAuthenticateUnableToAuthenticate             ThreeDSecureStatus = "authenticate_unable_to_authenticate"
	ThreeDSecureStatusAuthenticateError                            ThreeDSecureStatus = "authenticate_error"
)

type TimeField

type TimeField struct {
	XMLName xml.Name
	Is      time.Time
	Min     time.Time
	Max     time.Time
}

func (TimeField) MarshalXML

func (d TimeField) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Transaction

type Transaction struct {
	XMLName                      string                    `xml:"transaction"`
	Id                           string                    `xml:"id"`
	GraphQLId                    string                    `xml:"global-id"`
	Status                       TransactionStatus         `xml:"status"`
	Type                         string                    `xml:"type"`
	CurrencyISOCode              string                    `xml:"currency-iso-code"`
	Amount                       *Decimal                  `xml:"amount"`
	OrderId                      string                    `xml:"order-id"`
	PaymentMethodToken           string                    `xml:"payment-method-token"`
	PaymentMethodNonce           string                    `xml:"payment-method-nonce"`
	MerchantAccountId            string                    `xml:"merchant-account-id"`
	PlanId                       string                    `xml:"plan-id"`
	SubscriptionId               string                    `xml:"subscription-id"`
	SubscriptionDetails          *SubscriptionDetails      `xml:"subscription"`
	CreditCard                   *CreditCard               `xml:"credit-card"`
	Customer                     *Customer                 `xml:"customer"`
	BillingAddress               *Address                  `xml:"billing"`
	ShippingAddress              *Address                  `xml:"shipping"`
	TaxAmount                    *Decimal                  `xml:"tax-amount"`
	TaxExempt                    bool                      `xml:"tax-exempt"`
	DeviceData                   string                    `xml:"device-data"`
	ServiceFeeAmount             *Decimal                  `xml:"service-fee-amount,attr"`
	CreatedAt                    *time.Time                `xml:"created-at"`
	UpdatedAt                    *time.Time                `xml:"updated-at"`
	DisbursementDetails          *DisbursementDetails      `xml:"disbursement-details"`
	RefundId                     string                    `xml:"refund-id"`
	RefundIds                    *[]string                 `xml:"refund-ids>item"`
	RefundedTransactionId        *string                   `xml:"refunded-transaction-id"`
	ProcessorResponseCode        ProcessorResponseCode     `xml:"processor-response-code"`
	ProcessorResponseText        string                    `xml:"processor-response-text"`
	ProcessorResponseType        ProcessorResponseType     `xml:"processor-response-type"`
	ProcessorAuthorizationCode   string                    `xml:"processor-authorization-code"`
	SettlementBatchId            string                    `xml:"settlement-batch-id"`
	EscrowStatus                 EscrowStatus              `xml:"escrow-status"`
	PaymentInstrumentType        PaymentInstrumentType     `xml:"payment-instrument-type"`
	ThreeDSecureInfo             *ThreeDSecureInfo         `xml:"three-d-secure-info,omitempty"`
	PayPalDetails                *PayPalDetails            `xml:"paypal"`
	VenmoAccountDetails          *VenmoAccountDetails      `xml:"venmo-account"`
	AndroidPayDetails            *AndroidPayDetails        `xml:"android-pay-card"`
	ApplePayDetails              *ApplePayDetails          `xml:"apple-pay"`
	AdditionalProcessorResponse  string                    `xml:"additional-processor-response"`
	RiskData                     *RiskData                 `xml:"risk-data"`
	Descriptor                   *Descriptor               `xml:"descriptor"`
	Channel                      string                    `xml:"channel"`
	CustomFields                 customfields.CustomFields `xml:"custom-fields"`
	AVSErrorResponseCode         AVSResponseCode           `xml:"avs-error-response-code"`
	AVSPostalCodeResponseCode    AVSResponseCode           `xml:"avs-postal-code-response-code"`
	AVSStreetAddressResponseCode AVSResponseCode           `xml:"avs-street-address-response-code"`
	CVVResponseCode              CVVResponseCode           `xml:"cvv-response-code"`
	GatewayRejectionReason       GatewayRejectionReason    `xml:"gateway-rejection-reason"`
	PurchaseOrderNumber          string                    `xml:"purchase-order-number"`
	Disputes                     []*Dispute                `xml:"disputes>dispute"`
	AuthorizationExpiresAt       *time.Time                `xml:"authorization-expires-at"`
}

func (*Transaction) UnmarshalXML

func (t *Transaction) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type TransactionCloneOptions

type TransactionCloneOptions struct {
	SubmitForSettlement bool `xml:"submit-for-settlement"`
}

type TransactionCloneRequest

type TransactionCloneRequest struct {
	XMLName string                   `xml:"transaction-clone"`
	Amount  *Decimal                 `xml:"amount"`
	Channel string                   `xml:"channel"`
	Options *TransactionCloneOptions `xml:"options"`
}

type TransactionGateway

type TransactionGateway struct {
	*Braintree
}

func (*TransactionGateway) CancelRelease

func (g *TransactionGateway) CancelRelease(ctx context.Context, id string) (*Transaction, error)

CancelRelease cancels a pending release of a transaction with the given id from escrow.

func (*TransactionGateway) Clone

Clone clones a transaction.

func (*TransactionGateway) Create

Create initiates a transaction.

func (*TransactionGateway) Find

Find finds the transaction with the specified id.

func (*TransactionGateway) HoldInEscrow

func (g *TransactionGateway) HoldInEscrow(ctx context.Context, id string) (*Transaction, error)

HoldInEscrow holds the transaction with the given id for escrow.

func (*TransactionGateway) Refund

func (g *TransactionGateway) Refund(ctx context.Context, id string, amount ...*Decimal) (*Transaction, error)

A transaction can be refunded if it is settled or settling. If the transaction has not yet begun settlement, use Void() instead. If you do not specify an amount to refund, the entire transaction amount will be refunded.

func (*TransactionGateway) RefundWithRequest

func (g *TransactionGateway) RefundWithRequest(ctx context.Context, id string, refundRequest *TransactionRefundRequest) (*Transaction, error)

RefundWithRequest is similar to Refund, but allows more parameters such as OrderID to be included as part of the refund request.

func (*TransactionGateway) ReleaseFromEscrow

func (g *TransactionGateway) ReleaseFromEscrow(ctx context.Context, id string) (*Transaction, error)

ReleaseFromEscrow submits the transaction with the given id for release from escrow.

func (*TransactionGateway) Search deprecated

Search finds transactions matching the search query, returning the first page of results. Use SearchNext to get subsequent pages.

Deprecated: Use SearchIDs and SearchPage.

func (*TransactionGateway) SearchIDs

func (g *TransactionGateway) SearchIDs(ctx context.Context, query *SearchQuery) (*SearchResult, error)

SearchIDs finds transactions matching the search query, returning the IDs only. Use SearchPage to get pages of transactions.

func (*TransactionGateway) SearchNext deprecated

SearchNext finds the next page of transactions matching the search query. Use Search to start a search and get the first page of results. Returns a nil result and nil error when no more results are available.

Deprecated: Use SearchIDs and SearchPage.

func (*TransactionGateway) SearchPage

func (g *TransactionGateway) SearchPage(ctx context.Context, query *SearchQuery, searchResult *SearchResult, page int) (*TransactionSearchResult, error)

SearchPage gets the page of transactions matching the search query. Use SearchIDs to start a search and get a list of IDs, use its result object to get pages. Page numbers start at 1. Returns a nil result and nil error when no more results are available.

func (*TransactionGateway) Settle

func (g *TransactionGateway) Settle(ctx context.Context, id string) (*Transaction, error)

Settle settles a transaction. This action is only available in the sandbox environment. Deprecated: use the Settle function on the TestingGateway instead. e.g. g.Testing().Settle(id).

func (*TransactionGateway) SubmitForSettlement

func (g *TransactionGateway) SubmitForSettlement(ctx context.Context, id string, amount ...*Decimal) (*Transaction, error)

SubmitForSettlement submits the transaction with the specified id for settlement. If the amount is omitted, the full amount is settled.

func (*TransactionGateway) Void

Void voids the transaction with the specified id if it has a status of authorized or submitted_for_settlement. When the transaction is voided Braintree will do an authorization reversal if possible so that the customer won't have a pending charge on their card

type TransactionLineItem

type TransactionLineItem struct {
	Quantity       *Decimal                `xml:"quantity"`
	Name           string                  `xml:"name"`
	Description    string                  `xml:"description"`
	Kind           TransactionLineItemKind `xml:"kind"`
	UnitAmount     *Decimal                `xml:"unit-amount"`
	UnitTaxAmount  *Decimal                `xml:"unit-tax-amount"`
	TotalAmount    *Decimal                `xml:"total-amount"`
	TaxAmount      *Decimal                `xml:"tax-amount"`
	DiscountAmount *Decimal                `xml:"discount-amount"`
	UnitOfMeasure  string                  `xml:"unit-of-measure"`
	ProductCode    string                  `xml:"product-code"`
	CommodityCode  string                  `xml:"commodity-code"`
	URL            string                  `xml:"url"`
}

type TransactionLineItemGateway

type TransactionLineItemGateway struct {
	*Braintree
}

func (*TransactionLineItemGateway) Find

Find finds the transaction line items with the specified transaction id.

type TransactionLineItemKind

type TransactionLineItemKind string
const (
	TransactionLineItemKindDebit  TransactionLineItemKind = "debit"
	TransactionLineItemKindCredit TransactionLineItemKind = "credit"
)

type TransactionLineItemRequest

type TransactionLineItemRequest struct {
	Name           string                  `xml:"name"`
	Description    string                  `xml:"description,omitempty"`
	Kind           TransactionLineItemKind `xml:"kind"`
	Quantity       *Decimal                `xml:"quantity"`
	UnitAmount     *Decimal                `xml:"unit-amount"`
	UnitTaxAmount  *Decimal                `xml:"unit-tax-amount,omitempty"`
	TotalAmount    *Decimal                `xml:"total-amount"`
	TaxAmount      *Decimal                `xml:"tax-amount,omitempty"`
	DiscountAmount *Decimal                `xml:"discount-amount,omitempty"`
	UnitOfMeasure  string                  `xml:"unit-of-measure,omitempty"`
	ProductCode    string                  `xml:"product-code,omitempty"`
	CommodityCode  string                  `xml:"commodity-code,omitempty"`
	URL            string                  `xml:"url,omitempty"`
}

type TransactionLineItemRequests

type TransactionLineItemRequests []*TransactionLineItemRequest

func (TransactionLineItemRequests) MarshalXML

func (rs TransactionLineItemRequests) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type TransactionLineItems

type TransactionLineItems []*TransactionLineItem

func (*TransactionLineItems) UnmarshalXML

func (ls *TransactionLineItems) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type TransactionOptions

type TransactionOptions struct {
	SubmitForSettlement              bool                                   `xml:"submit-for-settlement,omitempty"`
	StoreInVault                     bool                                   `xml:"store-in-vault,omitempty"`
	StoreInVaultOnSuccess            bool                                   `xml:"store-in-vault-on-success,omitempty"`
	AddBillingAddressToPaymentMethod bool                                   `xml:"add-billing-address-to-payment-method,omitempty"`
	StoreShippingAddressInVault      bool                                   `xml:"store-shipping-address-in-vault,omitempty"`
	HoldInEscrow                     bool                                   `xml:"hold-in-escrow,omitempty"`
	TransactionOptionsPaypalRequest  *TransactionOptionsPaypalRequest       `xml:"paypal,omitempty"`
	SkipAdvancedFraudChecking        bool                                   `xml:"skip_advanced_fraud_checking,omitempty"`
	ThreeDSecure                     *TransactionOptionsThreeDSecureRequest `xml:"three-d-secure,omitempty"`
}

type TransactionOptionsPaypalRequest

type TransactionOptionsPaypalRequest struct {
	CustomField       string
	PayeeEmail        string
	Description       string
	SupplementaryData map[string]string
}

func (TransactionOptionsPaypalRequest) MarshalXML

type TransactionOptionsThreeDSecureRequest

type TransactionOptionsThreeDSecureRequest struct {
	Required bool `xml:"required"`
}

type TransactionRefundRequest

type TransactionRefundRequest struct {
	XMLName string   `xml:"transaction"`
	Amount  *Decimal `xml:"amount"`
	OrderID string   `xml:"order-id,omitempty"`
}

type TransactionRequest

type TransactionRequest struct {
	XMLName             string                      `xml:"transaction"`
	CustomerID          string                      `xml:"customer-id,omitempty"`
	Type                string                      `xml:"type,omitempty"`
	Amount              *Decimal                    `xml:"amount"`
	OrderId             string                      `xml:"order-id,omitempty"`
	PaymentMethodToken  string                      `xml:"payment-method-token,omitempty"`
	PaymentMethodNonce  string                      `xml:"payment-method-nonce,omitempty"`
	MerchantAccountId   string                      `xml:"merchant-account-id,omitempty"`
	PlanId              string                      `xml:"plan-id,omitempty"`
	CreditCard          *CreditCard                 `xml:"credit-card,omitempty"`
	Customer            *CustomerRequest            `xml:"customer,omitempty"`
	BillingAddress      *Address                    `xml:"billing,omitempty"`
	ShippingAddress     *Address                    `xml:"shipping,omitempty"`
	TaxAmount           *Decimal                    `xml:"tax-amount,omitempty"`
	TaxExempt           bool                        `xml:"tax-exempt,omitempty"`
	DeviceData          string                      `xml:"device-data,omitempty"`
	Options             *TransactionOptions         `xml:"options,omitempty"`
	ServiceFeeAmount    *Decimal                    `xml:"service-fee-amount,attr,omitempty"`
	RiskData            *RiskDataRequest            `xml:"risk-data,omitempty"`
	Descriptor          *Descriptor                 `xml:"descriptor,omitempty"`
	Channel             string                      `xml:"channel,omitempty"`
	CustomFields        customfields.CustomFields   `xml:"custom-fields,omitempty"`
	PurchaseOrderNumber string                      `xml:"purchase-order-number,omitempty"`
	TransactionSource   TransactionSource           `xml:"transaction-source,omitempty"`
	LineItems           TransactionLineItemRequests `xml:"line-items,omitempty"`
}

type TransactionSearchResult

type TransactionSearchResult struct {
	TotalItems int
	TotalIDs   []string

	CurrentPageNumber int
	PageSize          int
	Transactions      []*Transaction
}

type TransactionSource

type TransactionSource string
const (
	TransactionSourceRecurringFirst TransactionSource = "recurring_first"
	TransactionSourceRecurring      TransactionSource = "recurring"
	TransactionSourceMOTO           TransactionSource = "moto"
	TransactionSourceMerchant       TransactionSource = "merchant"
)

type TransactionStatus

type TransactionStatus string
const (
	TransactionStatusAuthorizationExpired   TransactionStatus = "authorization_expired"
	TransactionStatusAuthorizing            TransactionStatus = "authorizing"
	TransactionStatusAuthorized             TransactionStatus = "authorized"
	TransactionStatusGatewayRejected        TransactionStatus = "gateway_rejected"
	TransactionStatusFailed                 TransactionStatus = "failed"
	TransactionStatusProcessorDeclined      TransactionStatus = "processor_declined"
	TransactionStatusSettled                TransactionStatus = "settled"
	TransactionStatusSettlementConfirmed    TransactionStatus = "settlement_confirmed"
	TransactionStatusSettlementDeclined     TransactionStatus = "settlement_declined"
	TransactionStatusSettlementPending      TransactionStatus = "settlement_pending"
	TransactionStatusSettling               TransactionStatus = "settling"
	TransactionStatusSubmittedForSettlement TransactionStatus = "submitted_for_settlement"
	TransactionStatusVoided                 TransactionStatus = "voided"
	TransactionStatusUnrecognized           TransactionStatus = "unrecognized"
)

type Transactions

type Transactions struct {
	Transaction []*Transaction `xml:"transaction"`
}

type UpdateModificationRequest

type UpdateModificationRequest struct {
	ModificationRequest
	ExistingID string `xml:"existing-id,omitempty"`
}

type ValidationError

type ValidationError struct {
	Code      string
	Attribute string
	Message   string
}

func (*ValidationError) UnmarshalXML

func (e *ValidationError) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type ValidationErrors

type ValidationErrors struct {
	Object           string
	ValidationErrors []ValidationError
	Children         map[string]*ValidationErrors
}

func (*ValidationErrors) All

func (r *ValidationErrors) All() []ValidationError

func (*ValidationErrors) AllDeep

func (r *ValidationErrors) AllDeep() []ValidationError

func (*ValidationErrors) For

func (*ValidationErrors) ForIndex

func (r *ValidationErrors) ForIndex(i int) *ValidationErrors

func (*ValidationErrors) On

func (r *ValidationErrors) On(name string) []ValidationError

func (*ValidationErrors) UnmarshalXML

func (r *ValidationErrors) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type VenmoAccount

type VenmoAccount struct {
	XMLName           xml.Name       `xml:"venmo-account"`
	CustomerId        string         `xml:"customer-id"`
	Token             string         `xml:"token"`
	Username          string         `xml:"username"`
	VenmoUserID       string         `xml:"venmo-user-id"`
	SourceDescription string         `xml:"source-description"`
	ImageURL          string         `xml:"image-url"`
	CreatedAt         *time.Time     `xml:"created-at"`
	UpdatedAt         *time.Time     `xml:"updated-at"`
	Subscriptions     *Subscriptions `xml:"subscriptions"`
	Default           bool           `xml:"default"`
}

func (*VenmoAccount) AllSubscriptions

func (v *VenmoAccount) AllSubscriptions() []*Subscription

AllSubscriptions returns all subscriptions for this venmo account, or nil if none present.

func (*VenmoAccount) GetCustomerId

func (v *VenmoAccount) GetCustomerId() string

func (*VenmoAccount) GetImageURL

func (v *VenmoAccount) GetImageURL() string

func (*VenmoAccount) GetToken

func (v *VenmoAccount) GetToken() string

func (*VenmoAccount) IsDefault

func (v *VenmoAccount) IsDefault() bool

type VenmoAccountDetails

type VenmoAccountDetails struct {
	Token             string `xml:"token,omitempty"`
	Username          string `xml:"username,omitempty"`
	VenmoUserID       string `xml:"venmo-user-id,omitempty"`
	SourceDescription string `xml:"source-description,omitempty"`
	ImageURL          string `xml:"image-url,omitempty"`
}

type VenmoAccounts

type VenmoAccounts struct {
	VenmoAccount []*VenmoAccount `xml:"venmo-account"`
}

func (*VenmoAccounts) PaymentMethods

func (v *VenmoAccounts) PaymentMethods() []PaymentMethod

type WebhookNotification

type WebhookNotification struct {
	XMLName   xml.Name        `xml:"notification"`
	Timestamp time.Time       `xml:"timestamp"`
	Kind      string          `xml:"kind"`
	Subject   *webhookSubject `xml:"subject"`
}

func (*WebhookNotification) AccountUpdaterDailyReport

func (n *WebhookNotification) AccountUpdaterDailyReport() *AccountUpdaterDailyReport

func (*WebhookNotification) Disbursement

func (n *WebhookNotification) Disbursement() *Disbursement

func (*WebhookNotification) Dispute

func (n *WebhookNotification) Dispute() *Dispute

func (*WebhookNotification) MerchantAccount

func (n *WebhookNotification) MerchantAccount() *MerchantAccount

type WebhookNotificationGateway

type WebhookNotificationGateway struct {
	*Braintree
	// contains filtered or unexported fields
}

func (*WebhookNotificationGateway) Parse

func (w *WebhookNotificationGateway) Parse(signature, payload string) (*WebhookNotification, error)

func (*WebhookNotificationGateway) ParseRequest

func (*WebhookNotificationGateway) Verify

func (w *WebhookNotificationGateway) Verify(challenge string) (string, error)

type WebhookTestingGateway

type WebhookTestingGateway struct {
	*Braintree
	// contains filtered or unexported fields
}

WebhookTestingGateway exports actions only available in the sandbox environment.

func (*WebhookTestingGateway) Request

func (g *WebhookTestingGateway) Request(kind, id string) (*http.Request, error)

Request simulates an incoming webhook notification request

func (*WebhookTestingGateway) SamplePayload

func (g *WebhookTestingGateway) SamplePayload(kind, id string) string

SamplePayload builds a sample payload of the given kind, different kind of notifications are defined as constants in webhook_notification.go id represents an id used in XML subject of the specified kind

func (*WebhookTestingGateway) SignPayload

func (g *WebhookTestingGateway) SignPayload(payload string) (string, error)

SignPayload signs payload and returns HMAC signature

type XMLRecords

type XMLRecords struct {
	XMLName string   `xml:"records"`
	Type    []Record `xml:"record"`
}

Directories

Path Synopsis
examples
subscription command
transaction command
transaction_3ds command

Jump to

Keyboard shortcuts

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