Skip to content

Commit

Permalink
Removed print, added struct fields
Browse files Browse the repository at this point in the history
  • Loading branch information
gee-m committed Sep 30, 2016
1 parent c0a890d commit 8db24b8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 36 deletions.
3 changes: 0 additions & 3 deletions braintree.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package braintree
import (
"bytes"
"encoding/xml"
"fmt"
"log"
"net/http"
)
Expand Down Expand Up @@ -69,15 +68,13 @@ 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
}
}

url := g.MerchantURL() + "/" + path
fmt.Println(url)

if g.Logger != nil {
g.Logger.Printf("> %s %s\n%s", method, url, buf.String())
Expand Down
58 changes: 31 additions & 27 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
28 changes: 22 additions & 6 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8db24b8

Please sign in to comment.