Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
/.idea
/.idea
.vscode
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ if response.Approved() {
```go
oldTransaction := AuthorizeCIM.PreviousTransaction{
Amount: "49.99",
RefId: "AUTHCODEHERE001",
RefID: "AUTHCODEHERE001",
}
response, err := oldTransaction.Capture()
if response.Approved() {
Expand Down Expand Up @@ -149,7 +149,7 @@ newTransaction := AuthorizeCIM.NewTransaction{
CardNumber: "4012888818888",
ExpirationDate: "10/24",
},
RefTransId: "0392482938402",
RefTransID: "0392482938402",
}
response, err := newTransaction.Refund()
if response.Approved() {
Expand All @@ -161,7 +161,7 @@ if response.Approved() {
:white_check_mark: voidTransaction
```go
oldTransaction := AuthorizeCIM.PreviousTransaction{
RefId: "3987324293834",
RefID: "3987324293834",
}
response, err := oldTransaction.Void()
if response.Approved() {
Expand Down Expand Up @@ -227,7 +227,7 @@ fmt.Println("Unsettled Count: ", transactions.Count)
```go
oldTransaction := AuthorizeCIM.PreviousTransaction{
Amount: "49.99",
RefId: "39824723983",
RefID: "39824723983",
}

response, err := oldTransaction.Approve()
Expand Down Expand Up @@ -718,7 +718,7 @@ for _, v := range batches {
:white_check_mark: getTransactionDetails
```go
oldTransaction := AuthorizeCIM.PreviousTransaction{
RefId: "60019493304",
RefID: "60019493304",
}
response := oldTransaction.Info()

Expand Down
58 changes: 29 additions & 29 deletions _examples/new_transaction/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package main

import (
auth "github.com/hunterlong/authorizecim"
"os"
"fmt"
"os"

auth "github.com/hunterlong/authorizecim"
)

var newTransactionId string
Expand All @@ -13,7 +14,7 @@ func main() {
apiName := os.Getenv("apiName")
apiKey := os.Getenv("apiKey")

auth.SetAPIInfo(apiName,apiKey,"test")
auth.SetAPIInfo(apiName, apiKey, "test")

if auth.IsConnected() {
fmt.Println("Connected to Authorize.net!")
Expand All @@ -26,41 +27,40 @@ func main() {

func ChargeCustomer() {

newTransaction := auth.NewTransaction{
Amount: "13.75",
CreditCard: auth.CreditCard{
CardNumber: "4012888818888",
ExpirationDate: "08/25",
CardCode: "393",
},
BillTo: &auth.BillTo{
FirstName: "Timmy",
LastName: "Jimmy",
Address: "1111 green ct",
City: "los angeles",
State: "CA",
Zip: "43534",
Country: "USA",
PhoneNumber: "8885555555",
},
}
response := newTransaction.Charge()
newTransaction := auth.NewTransaction{
Amount: "13.75",
CreditCard: auth.CreditCard{
CardNumber: "4012888818888",
ExpirationDate: "08/25",
CardCode: "393",
},
BillTo: &auth.BillTo{
FirstName: "Timmy",
LastName: "Jimmy",
Address: "1111 green ct",
City: "los angeles",
State: "CA",
Zip: "43534",
Country: "USA",
PhoneNumber: "8885555555",
},
}
response := newTransaction.Charge()

if response.Approved() {
newTransactionId = response.TransactionID()
fmt.Println("Transaction was Approved! #",response.TransactionID())
}
if response.Approved() {
newTransactionId = response.TransactionID()
fmt.Println("Transaction was Approved! #", response.TransactionID())
}
}


func VoidTransaction() {

newTransaction := auth.PreviousTransaction{
RefId: newTransactionId,
RefID: newTransactionId,
}
response := newTransaction.Void()
if response.Approved() {
fmt.Println("Transaction was Voided!")
}

}
}
5 changes: 1 addition & 4 deletions authorizecim.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package AuthorizeCIM

import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
Expand Down Expand Up @@ -58,9 +57,7 @@ func SendRequest(input []byte) ([]byte, error) {
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body = bytes.TrimPrefix(body, []byte("\xef\xbb\xbf"))
if showLogs {
fmt.Println(string(body))
}

return body, err
}

Expand Down
6 changes: 3 additions & 3 deletions customer_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func ValidatePaymentProfile(customer Customer) (*ValidateCustomerPaymentProfileR
MerchantAuthentication: GetAuthentication(),
CustomerProfileID: customer.ID,
CustomerPaymentProfileID: customer.PaymentID,
ValidationMode: testMode,
ValidationMode: "testMode",
},
}
jsoned, err := json.Marshal(action)
Expand Down Expand Up @@ -166,7 +166,7 @@ func CreateProfile(profile Profile) (*CustomProfileResponse, error) {
CreateCustomerProfile: CreateCustomerProfile{
MerchantAuthentication: GetAuthentication(),
Profile: profile,
ValidationMode: testMode,
ValidationMode: "testMode",
},
}
jsoned, err := json.Marshal(action)
Expand Down Expand Up @@ -225,7 +225,7 @@ func UpdatePaymentProfile(profile Profile) (*MessagesResponse, error) {
Payment: profile.PaymentProfiles.Payment,
CustomerPaymentProfileID: profile.PaymentProfileId,
},
ValidationMode: testMode,
ValidationMode: "testMode",
},
}
dat, err := MessageResponder(action)
Expand Down
8 changes: 5 additions & 3 deletions customer_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ func init() {
}

func TestSetAPIInfo(t *testing.T) {
apiName := os.Getenv("apiName")
apiKey := os.Getenv("apiKey")
//apiMode := os.Getenv("mode")
apiName := os.Getenv("AUTHORIZE_ID")
apiKey := os.Getenv("AUTHORIZE_TRANSACTION_KEY")
// apiMode := os.Getenv("AUTHORIZE_API_ENVIRONMENT")

SetAPIInfo(apiName, apiKey, "test")

t.Log("API Info Set")
}

Expand Down
4 changes: 2 additions & 2 deletions fraud_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func SendTransactionUpdate(tranx PreviousTransaction, method string) (*Transacti
action := UpdateHeldTransactionRequest{
UpdateHeldTransaction: UpdateHeldTransaction{
MerchantAuthentication: GetAuthentication(),
RefID: tranx.RefId,
RefID: tranx.RefID,
HeldTransactionRequest: HeldTransactionRequest{
Action: method,
RefTransID: tranx.RefId,
RefTransID: tranx.RefID,
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions fraud_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ func TestGetUnsettledTransactions(t *testing.T) {
t.Fail()
}

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

func TestApproveTransaction(t *testing.T) {
oldTransaction := PreviousTransaction{
Amount: "49.99",
RefId: "39824723983",
RefID: "39824723983",
}

response, err := oldTransaction.Approve()
Expand All @@ -35,7 +35,7 @@ func TestApproveTransaction(t *testing.T) {
func TestDeclineTransaction2(t *testing.T) {
oldTransaction := PreviousTransaction{
Amount: "49.99",
RefId: "39824723983",
RefID: "39824723983",
}

response, err := oldTransaction.Decline()
Expand Down
40 changes: 19 additions & 21 deletions payment_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func (tranx NewTransaction) ChargeProfile(profile Customer) (*TransactionRespons
new = TransactionRequest{
TransactionType: "authCaptureTransaction",
Amount: tranx.Amount,
LineItems: tranx.LineItems,
Profile: &Profile{
CustomerProfileId: profile.ID,
PaymentProfile: &PaymentProfile{
Expand Down Expand Up @@ -53,7 +54,7 @@ func (tranx NewTransaction) Refund() (*TransactionResponse, error) {
new = TransactionRequest{
TransactionType: "refundTransaction",
Amount: tranx.Amount,
RefTransId: tranx.RefTransId,
RefTransID: tranx.RefTransID,
}
response, err := SendTransactionRequest(new)
return response, err
Expand All @@ -63,7 +64,7 @@ func (tranx PreviousTransaction) Void() (*TransactionResponse, error) {
var new TransactionRequest
new = TransactionRequest{
TransactionType: "voidTransaction",
RefTransId: tranx.RefId,
RefTransID: tranx.RefID,
}
response, err := SendTransactionRequest(new)
return response, err
Expand All @@ -73,7 +74,7 @@ func (tranx PreviousTransaction) Capture() (*TransactionResponse, error) {
var new TransactionRequest
new = TransactionRequest{
TransactionType: "priorAuthCaptureTransaction",
RefTransId: tranx.RefId,
RefTransID: tranx.RefID,
}
response, err := SendTransactionRequest(new)
return response, err
Expand Down Expand Up @@ -128,16 +129,16 @@ func SendTransactionRequest(input TransactionRequest) (*TransactionResponse, err
}

type NewTransaction struct {
Amount string `json:"amount,omitempty"`
InvoiceId string `json:"invoiceId,omitempty"`
RefTransId string `json:"refTransId,omitempty"`
CreditCard CreditCard `json:"payment,omitempty"`
AuthCode string `json:"authCode,omitempty"`
BillTo *BillTo `json:"omitempty"`
Amount string `json:"amount,omitempty"`
RefTransID string `json:"refTransId,omitempty"`
CreditCard CreditCard `json:"payment,omitempty"`
AuthCode string `json:"authCode,omitempty"`
BillTo *BillTo `json:"billTo,omitempty"`
LineItems map[string]*LineItem `json:"lineItems,omitempty"`
}

type PreviousTransaction struct {
RefId string `json:"refTransId,omitempty"`
RefID string `json:"refTransId,omitempty"`
Amount string `json:"amount,omitempty"`
}

Expand Down Expand Up @@ -204,10 +205,6 @@ type CreditCard struct {
CardCode string `json:"cardCode,omitempty"`
}

type LineItems struct {
LineItem []LineItem `json:"lineItem,omitempty"`
}

type LineItem struct {
ItemID string `json:"itemId,omitempty"`
Name string `json:"name,omitempty"`
Expand Down Expand Up @@ -261,13 +258,14 @@ type UserField struct {
}

type TransactionRequest struct {
TransactionType string `json:"transactionType,omitempty"`
Amount string `json:"amount,omitempty"`
Payment *Payment `json:"payment,omitempty"`
RefTransId string `json:"refTransId,omitempty"`
AuthCode string `json:"authCode,omitempty"`
Profile *Profile `json:"profile,omitempty"`
LineItems *LineItems `json:"lineItems,omitempty"`
TransactionType string `json:"transactionType,omitempty"`
Amount string `json:"amount,omitempty"`
Payment *Payment `json:"payment,omitempty"`
RefTransID string `json:"refTransId,omitempty"`
InvoiceNumber string `json:"invoiseNumber,omitempty"`
AuthCode string `json:"authCode,omitempty"`
Profile *Profile `json:"profile,omitempty"`
LineItems map[string]*LineItem `json:"lineItems,omitempty"`
//Tax Tax `json:"tax,omitempty"`
//Duty Duty `json:"duty,omitempty"`
//Shipping Shipping `json:"shipping,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions payment_transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func TestAuthOnlyCard(t *testing.T) {
func TestCaptureAuth(t *testing.T) {
oldTransaction := PreviousTransaction{
Amount: "49.99",
RefId: previousAuth,
RefID: previousAuth,
}
response, err := oldTransaction.Capture()
if err != nil {
Expand Down Expand Up @@ -212,7 +212,7 @@ func TestRefundCard(t *testing.T) {
CardNumber: "4012888818888",
ExpirationDate: "10/24",
},
RefTransId: "0392482938402",
RefTransID: "0392482938402",
}
response, err := newTransaction.Refund()
if err != nil {
Expand All @@ -227,7 +227,7 @@ func TestRefundCard(t *testing.T) {

func TestVoidCard(t *testing.T) {
newTransaction := PreviousTransaction{
RefId: previousCharged,
RefID: previousCharged,
}
response, err := newTransaction.Void()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion transaction_reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (tranx PreviousTransaction) Info() (*FullTransaction, error) {
new := GetTransactionDetailsRequest{
GetTransactionDetails: GetTransactionDetails{
MerchantAuthentication: GetAuthentication(),
TransID: tranx.RefId,
TransID: tranx.RefID,
},
}
jsoned, err := json.Marshal(new)
Expand Down
2 changes: 1 addition & 1 deletion transaction_reporting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestGetTransactionList(t *testing.T) {
func TestGetTransactionDetails(t *testing.T) {

newTransaction := PreviousTransaction{
RefId: "60019493304",
RefID: "60019493304",
}
response, err := newTransaction.Info()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions xcleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestDeleteSecondCustomerProfile(t *testing.T) {
func TestDeclineTransaction(t *testing.T) {
oldTransaction := PreviousTransaction{
//Amount: "49.99",
RefId: heldTransactionId,
RefID: heldTransactionId,
}

response, err := oldTransaction.Decline()
Expand All @@ -144,7 +144,7 @@ func TestDeclineTransaction(t *testing.T) {
}

if response.Approved() {
t.Log("DECLINED the previous transasction that was on Hold. ID #", oldTransaction.RefId)
t.Log("DECLINED the previous transasction that was on Hold. ID #", oldTransaction.RefID)
t.Log(response.TransactionID())
} else {
t.Log(response.ErrorMessage())
Expand Down