Skip to content

Commit

Permalink
added failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Mar 13, 2017
1 parent 89a66d9 commit 659effe
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 60 deletions.
79 changes: 29 additions & 50 deletions customer_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestCreateCustomerProfile(t *testing.T) {
newCustomerProfileId = response.CustomerProfileID
t.Log("New Customer Profile Created #", response.CustomerProfileID)
} else {
t.Fail()
t.Log(response.ErrorMessage())
}

Expand All @@ -50,6 +51,11 @@ func TestGetProfileIds(t *testing.T) {
for _, p := range profiles {
t.Log("Profile ID #", p)
}

if len(profiles) == 0 {
t.Fail()
}

t.Log(profiles)
}

Expand All @@ -68,6 +74,7 @@ func TestUpdateCustomerProfile(t *testing.T) {
t.Log("Customer Profile was Updated")
} else {
t.Log(response.ErrorMessage())
t.Fail()
}

}
Expand Down Expand Up @@ -102,6 +109,7 @@ func TestCreateCustomerPaymentProfile(t *testing.T) {
t.Log("Created new Payment Profile #", response.CustomerPaymentProfileID, "for Customer ID: ", response.CustomerProfileId)
} else {
t.Log(response.ErrorMessage())
t.Fail()
}

}
Expand All @@ -118,6 +126,10 @@ func TestGetCustomerPaymentProfile(t *testing.T) {

t.Log("Customer Payment Profiles", paymentProfiles)

if len(paymentProfiles) == 0 {
t.Fail()
}

}

func TestGetCustomerPaymentProfileList(t *testing.T) {
Expand All @@ -140,6 +152,7 @@ func TestValidateCustomerPaymentProfile(t *testing.T) {
t.Log("Customer Payment Profile is VALID")
} else {
t.Log(response.ErrorMessage())
t.Fail()
}

}
Expand Down Expand Up @@ -176,25 +189,11 @@ func TestUpdateCustomerPaymentProfile(t *testing.T) {
t.Log("Customer Payment Profile was Updated")
} else {
t.Log(response.ErrorMessage())
t.Fail()
}

}

func TestDeleteCustomerPaymentProfile(t *testing.T) {
customer := Customer{
ID: newCustomerProfileId,
PaymentID: newCustomerPaymentId,
}

response := customer.DeletePaymentProfile()

if response.Approved() {
t.Log("Payment Profile was Deleted")
} else {
t.Log(response.ErrorMessage())
}
}

func TestCreateCustomerShippingProfile(t *testing.T) {

customer := Profile{
Expand All @@ -219,6 +218,9 @@ func TestCreateCustomerShippingProfile(t *testing.T) {
if response.Approved() {
newCustomerShippingId = response.CustomerAddressID
t.Log("New Shipping Added: #", response.CustomerAddressID)
} else {
t.Log(response.ErrorMessage())
t.Fail()
}
}

Expand All @@ -234,6 +236,10 @@ func TestGetCustomerShippingProfile(t *testing.T) {

t.Log("Customer Shipping Profiles", shippingProfiles)

if shippingProfiles[0].Zip != "92039" {
t.Fail()
}

}

func TestUpdateCustomerShippingProfile(t *testing.T) {
Expand All @@ -258,23 +264,11 @@ func TestUpdateCustomerShippingProfile(t *testing.T) {

if response.Approved() {
t.Log("Shipping Address Profile was updated")
}

}

func TestDeleteCustomerShippingProfile(t *testing.T) {
customer := Customer{
ID: newCustomerProfileId,
ShippingID: newCustomerShippingId,
}

response := customer.DeleteShippingProfile()

if response.Approved() {
t.Log("Shipping Profile was Deleted")
} else {
t.Log(response.ErrorMessage())
t.Fail()
}

}

func TestAcceptProfilePage(t *testing.T) {
Expand All @@ -287,14 +281,14 @@ func TestCreateCustomerProfileFromTransaction(t *testing.T) {

func TestCreateSubscriptionCustomerProfile(t *testing.T) {
subscription := Subscription{
Name: "New Customer Subscription",
Amount: "12.00",
TrialAmount: "0.00",
Name: "New Customer Subscription",
Amount: "7.00",
//TrialAmount: "0.00",
PaymentSchedule: &PaymentSchedule{
StartDate: CurrentDate(),
TotalOccurrences: "9999",
TrialOccurrences: "0",
Interval: IntervalMonthly(),
//TrialOccurrences: "0",
Interval: IntervalMonthly(),
},
Profile: &CustomerProfiler{
CustomerProfileID: newCustomerProfileId,
Expand All @@ -310,6 +304,7 @@ func TestCreateSubscriptionCustomerProfile(t *testing.T) {
t.Log("Customer #", response.CustomerProfileId(), " Created a New Subscription: ", response.SubscriptionID)
} else {
t.Log(response.ErrorMessage(), "\n")
t.Fail()
}

}
Expand All @@ -333,19 +328,3 @@ func TestGetCustomerProfile(t *testing.T) {
t.Log("Customer Subscription IDs", subscriptions)

}

func TestDeleteCustomerProfile(t *testing.T) {

customer := Customer{
ID: newCustomerProfileId,
}

response := customer.DeleteProfile()

if response.Approved() {
t.Log("Customer was Deleted")
} else {
t.Log(response.ErrorMessage())
}

}
2 changes: 1 addition & 1 deletion fraud_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
func TestGetUnsettledTransactions(t *testing.T) {
transactions := UnsettledBatchList()

t.Log("Count Unsettled: ", transactions.Count)
t.Log("Count Unsettled: ", transactions.Count())
t.Log(transactions.List())
}

Expand Down
8 changes: 5 additions & 3 deletions payment_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,11 @@ type Tax struct {
}

type Customer struct {
ID string `json:"id,omitempty"`
PaymentID string `json:"id,omitempty"`
ShippingID string `json:"id,omitempty"`
ID string `json:"id,omitempty"`
Email string `json:"email,omitempty"`
PaymentID string `json:"paymentId,omitempty"`
ShippingID string `json:"shippingId,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
}

type TransactionSettings struct {
Expand Down
12 changes: 12 additions & 0 deletions payment_transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestChargeCard(t *testing.T) {
t.Log("AVS CVV Result Code: ", response.AVS().cvvResultCode+"\n")
} else {
t.Log(response.ErrorMessage(), "\n")
t.SkipNow()
}
}

Expand All @@ -41,6 +42,8 @@ func TestAuthOnlyCard(t *testing.T) {
t.Log("#", response.TransactionID(), "Transaction was AUTHORIZED $", newTransaction.Amount, "\n")
} else {
t.Log(response.ErrorMessage(), "\n")
t.Log(response.Message(), "\n")
t.SkipNow()
}
}

Expand All @@ -54,6 +57,8 @@ func TestCaptureAuth(t *testing.T) {
t.Log("#", response.TransactionID(), "Transaction was CAPTURED $", oldTransaction.Amount, "\n")
} else {
t.Log(response.ErrorMessage(), "\n")
t.Log(response.Message(), "\n")
t.SkipNow()
}
}

Expand All @@ -73,6 +78,8 @@ func TestChargeCardChannel(t *testing.T) {
t.Log("#", response.TransactionID(), "Transaction was Charged Through Channel (AuthCode) $", newTransaction.Amount, "\n")
} else {
t.Log(response.ErrorMessage(), "\n")
t.Log(response.Message(), "\n")
t.SkipNow()
}
}

Expand All @@ -90,6 +97,8 @@ func TestRefundCard(t *testing.T) {
t.Log("#", response.TransactionID(), "Transaction was REFUNDED $", newTransaction.Amount, "\n")
} else {
t.Log(response.ErrorMessage(), "\n")
t.Log(response.Message(), "\n")
t.SkipNow()
}
}

Expand All @@ -102,6 +111,7 @@ func TestVoidCard(t *testing.T) {
t.Log("#", response.TransactionID(), "Transaction was VOIDED $", newTransaction.Amount, "\n")
} else {
t.Log(response.ErrorMessage(), "\n")
t.SkipNow()
}
}

Expand All @@ -125,5 +135,7 @@ func TestChargeCustomerProfile(t *testing.T) {
t.Log("#", response.TransactionID(), "Customer was Charged $", newTransaction.Amount, "\n")
} else {
t.Log(response.ErrorMessage(), "\n")
t.Log(response.Message(), "\n")
t.SkipNow()
}
}
4 changes: 4 additions & 0 deletions recurring_billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package AuthorizeCIM

import (
"encoding/json"
"fmt"
)

func (response SubscriptionResponse) Approved() bool {
Expand Down Expand Up @@ -87,8 +88,10 @@ type Subscription struct {
TrialAmount string `json:"trialAmount,omitempty"`
Payment *Payment `json:"payment,omitempty"`
BillTo *BillTo `json:"billTo,omitempty"`
ShipTo *BillTo `json:"shipTo,omitempty"`
SubscriptionId string `json:"subscriptionId,omitempty"`
Profile *CustomerProfiler `json:"profile,omitempty"`
Customer *Customer `json:"customer,omitempty"`
}

type BillTo struct {
Expand Down Expand Up @@ -137,6 +140,7 @@ func SendSubscription(sub Subscription) (SubscriptionResponse, interface{}) {
},
}
jsoned, err := json.Marshal(action)
fmt.Println(string(jsoned))
if err != nil {
panic(err)
}
Expand Down
63 changes: 58 additions & 5 deletions recurring_billing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ var newSubscriptionId string

func TestCreateSubscription(t *testing.T) {
subscription := Subscription{
Name: "New Subscription",
Amount: "9.00",
TrialAmount: "0.00",
Name: "New Subscription",
Amount: "9.00",
//TrialAmount: "0.00",
PaymentSchedule: &PaymentSchedule{
StartDate: CurrentDate(),
TotalOccurrences: "9999",
TrialOccurrences: "0",
Interval: IntervalMonthly(),
//TrialOccurrences: "0",
Interval: IntervalMonthly(),
},
Payment: &Payment{
CreditCard: CreditCard{
Expand All @@ -27,6 +27,10 @@ func TestCreateSubscription(t *testing.T) {
FirstName: "Hunter",
LastName: "Long",
},
Customer: &Customer{
ID: "273287",
Email: "info@newemailuser.com",
},
}

response := subscription.Charge()
Expand Down Expand Up @@ -131,3 +135,52 @@ func TestGetCardExpiringSubscriptionList(t *testing.T) {
t.Log("Amount of Cards Expiring This Month: ", subscriptionList.Count())

}

func TestDeleteCustomerShippingProfile(t *testing.T) {
customer := Customer{
ID: newCustomerProfileId,
ShippingID: newCustomerShippingId,
}

response := customer.DeleteShippingProfile()

if response.Approved() {
t.Log("Shipping Profile was Deleted")
} else {
t.Log(response.ErrorMessage())
t.Fail()
}
}

func TestDeleteCustomerPaymentProfile(t *testing.T) {
customer := Customer{
ID: newCustomerProfileId,
PaymentID: newCustomerPaymentId,
}

response := customer.DeletePaymentProfile()

if response.Approved() {
t.Log("Payment Profile was Deleted")
} else {
t.Log(response.ErrorMessage())
t.Fail()
}
}

func TestDeleteCustomerProfile(t *testing.T) {

customer := Customer{
ID: newCustomerProfileId,
}

response := customer.DeleteProfile()

if response.Approved() {
t.Log("Customer was Deleted")
} else {
t.Log(response.ErrorMessage())
t.Fail()
}

}
4 changes: 4 additions & 0 deletions transaction_reporting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func TestGetUnSettledBatchList(t *testing.T) {
t.Log("Transaction ID: #", v.TransID, "\n")
}

if len(batches) == 0 {
t.Fail()
}

}

func TestGetBatchStatistics(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion transaction_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ func (transx TransactionResponse) TransactionID() string {
}

func (transx TransactionResponse) Message() string {
return transx.Response.Message.Messages.Message[0].Text
return transx.Response.Errors[0].ErrorText
}

func (transx TransactionResponse) AVS() AVS {
Expand Down

0 comments on commit 659effe

Please sign in to comment.