From 8db24b86cc3e0f44ae3d80d938a606d6d4335fbc Mon Sep 17 00:00:00 2001 From: Guillaume Merindol Date: Fri, 30 Sep 2016 10:08:11 -0400 Subject: [PATCH] Removed print, added struct fields --- braintree.go | 3 --- subscription.go | 58 ++++++++++++++++++++++++++----------------------- transaction.go | 28 +++++++++++++++++++----- 3 files changed, 53 insertions(+), 36 deletions(-) diff --git a/braintree.go b/braintree.go index b58af914..5d226f85 100644 --- a/braintree.go +++ b/braintree.go @@ -3,7 +3,6 @@ package braintree import ( "bytes" "encoding/xml" - "fmt" "log" "net/http" ) @@ -69,7 +68,6 @@ func (g *Braintree) execute(method, path string, xmlObj interface{}) (*Response, if err != nil { return nil, err } - fmt.Println(string(xmlBody)) _, err = buf.Write(xmlBody) if err != nil { return nil, err @@ -77,7 +75,6 @@ func (g *Braintree) execute(method, path string, xmlObj interface{}) (*Response, } url := g.MerchantURL() + "/" + path - fmt.Println(url) if g.Logger != nil { g.Logger.Printf("> %s %s\n%s", method, url, buf.String()) diff --git a/subscription.go b/subscription.go index 3c492175..6407221c 100644 --- a/subscription.go +++ b/subscription.go @@ -12,33 +12,37 @@ const ( ) type Subscription struct { - XMLName string `xml:"subscription"` - Id string `xml:"id,omitempty"` - Balance *Decimal `xml:"balance,omitempty"` - BillingDayOfMonth string `xml:"billing-day-of-month,omitempty"` - BillingPeriodEndDate string `xml:"billing-period-end-date,omitempty"` - BillingPeriodStartDate string `xml:"billing-period-start-date,omitempty"` - CurrentBillingCycle string `xml:"current-billing-cycle,omitempty"` - DaysPastDue string `xml:"days-past-due,omitempty"` - Discounts []interface{} `xml:"discounts,omitempty"` - FailureCount string `xml:"failure-count,omitempty"` - FirstBillingDate string `xml:"first-billing-date,omitempty"` - MerchantAccountId string `xml:"merchant-account-id,omitempty"` - NeverExpires *nullable.NullBool `xml:"never-expires,omitempty"` - NextBillAmount *Decimal `xml:"next-bill-amount,omitempty"` - NextBillingPeriodAmount *Decimal `xml:"next-billing-period-amount,omitempty"` - NextBillingDate string `xml:"next-billing-date,omitempty"` - NumberOfBillingCycles *nullable.NullInt64 `xml:"number-of-billing-cycles,omitempty"` - PaidThroughDate string `xml:"paid-through-date,omitempty"` - PaymentMethodToken string `xml:"payment-method-token,omitempty"` - PlanId string `xml:"plan-id,omitempty"` - Price *Decimal `xml:"price,omitempty"` - Status string `xml:"status,omitempty"` - TrialDuration string `xml:"trial-duration,omitempty"` - TrialDurationUnit string `xml:"trial-duration-unit,omitempty"` - TrialPeriod *nullable.NullBool `xml:"trial-period,omitempty"` - Transactions *Transactions `xml:"transactions,omitempty"` - Options *SubscriptionOptions `xml:"options,omitempty"` + XMLName string `xml:"subscription"` + Id string `xml:"id,omitempty"` + Balance *Decimal `xml:"balance,omitempty"` + + BillingDayOfMonth string `xml:"billing-day-of-month,omitempty"` + BillingPeriodEndDate string `xml:"billing-period-end-date,omitempty"` + BillingPeriodStartDate string `xml:"billing-period-start-date,omitempty"` + CurrentBillingCycle string `xml:"current-billing-cycle,omitempty"` + DaysPastDue string `xml:"days-past-due,omitempty"` + Discounts []interface{} `xml:"discounts,omitempty"` + FailureCount string `xml:"failure-count,omitempty"` + FirstBillingDate string `xml:"first-billing-date,omitempty"` + MerchantAccountId string `xml:"merchant-account-id,omitempty"` + CurrencyISOCode string `xml:"currency-iso-code,omitempty` + + NeverExpires *nullable.NullBool `xml:"never-expires,omitempty"` + NextBillAmount *Decimal `xml:"next-bill-amount,omitempty"` + NextBillingPeriodAmount *Decimal `xml:"next-billing-period-amount,omitempty"` + NextBillingDate string `xml:"next-billing-date,omitempty"` + + NumberOfBillingCycles *nullable.NullInt64 `xml:"number-of-billing-cycles,omitempty"` + PaidThroughDate string `xml:"paid-through-date,omitempty"` + PaymentMethodToken string `xml:"payment-method-token,omitempty"` + PlanId string `xml:"plan-id,omitempty"` + Price *Decimal `xml:"price,omitempty"` + Status string `xml:"status,omitempty"` + TrialDuration string `xml:"trial-duration,omitempty"` + TrialDurationUnit string `xml:"trial-duration-unit,omitempty"` + TrialPeriod *nullable.NullBool `xml:"trial-period,omitempty"` + Transactions *Transactions `xml:"transactions,omitempty"` + Options *SubscriptionOptions `xml:"options,omitempty"` // AddOns []interface{} `xml:"add-ons,omitempty"` // Descriptor interface{} `xml:"descriptor,omitempty"` // struct with name, phone Descriptor *Descriptor `xml:"descriptor,omitempty"` diff --git a/transaction.go b/transaction.go index da1cfc64..f0414929 100644 --- a/transaction.go +++ b/transaction.go @@ -7,10 +7,13 @@ import ( ) type Transaction struct { - XMLName string `xml:"transaction"` - Id string `xml:"id,omitempty"` - CustomerID string `xml:"customer-id,omitempty"` - Status string `xml:"status,omitempty"` + XMLName string `xml:"transaction"` + Id string `xml:"id,omitempty"` + CustomerID string `xml:"customer-id,omitempty"` + + Status string `xml:"status,omitempty"` + StatusHistory *StatusHistory `xml:"status-history,omitempty"` + Type string `xml:"type,omitempty"` Amount *Decimal `xml:"amount"` CurrencyISOCode string `xml:"currency-iso-code,omitempty"` @@ -38,8 +41,21 @@ type Transaction struct { ProcessorAuthorizationCode string `xml:"processor-authorization-code,omitempty"` SettlementBatchId string `xml:"settlement-batch-id,omitempty"` - SubscriptionID string `xml:"subscription-id,omitempty"` - Descriptor *Descriptor `xml:"descriptor,omitempty"` + SubscriptionID string `xml:"subscription-id,omitempty"` + Descriptor *Descriptor `xml:"descriptor,omitempty"` + PaymentInstrumentType string `xml:"payment-instrument-type,omitempty"` +} + +type StatusHistory struct { + Events []StatusEvent `xml:"status-event"` +} + +type StatusEvent struct { + Amount string `xml:"amount"` + User string `xml:"user"` + TransactionSource string `xml:"transaction-source"` + Timestamp string `xml:"timestamp"` + Status string `xml:"status"` } type Descriptor struct {