Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an unchecked error in SendTransactionRequest #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion customer_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ type Profile struct {

type PaymentProfiles struct {
CustomerType string `json:"customerType,omitempty"`
Payment Payment `json:"payment,omitempty"`
BillTo *BillTo `json:"billTo,omitempty"`
Payment Payment `json:"payment,omitempty"`
PaymentId string `json:"paymentProfileId,omitempty"`
}

Expand Down
59 changes: 35 additions & 24 deletions payment_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func (tranx NewTransaction) Charge() (*TransactionResponse, error) {
Payment: &Payment{
CreditCard: tranx.CreditCard,
},
Order: tranx.Order,
BillTo: tranx.BillTo,
AuthCode: tranx.AuthCode,
}
Expand Down Expand Up @@ -53,7 +54,7 @@ func (tranx NewTransaction) Refund() (*TransactionResponse, error) {
new = TransactionRequest{
TransactionType: "refundTransaction",
Amount: tranx.Amount,
RefTransId: tranx.RefTransId,
RefId: tranx.RefId,
}
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,
RefId: 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,
RefId: tranx.RefId,
}
response, err := SendTransactionRequest(new)
return response, err
Expand Down Expand Up @@ -111,14 +112,18 @@ func SendTransactionRequest(input TransactionRequest) (*TransactionResponse, err
action := CreatePayment{
CreateTransactionRequest: CreateTransactionRequest{
MerchantAuthentication: GetAuthentication(),
TransactionRequest: input,
RefId: input.RefId,
TransactionRequest: input,
},
}
jsoned, err := json.Marshal(action)
if err != nil {
return nil, err
}
response, err := SendRequest(jsoned)
if err != nil {
return nil, err
}
var dat TransactionResponse
err = json.Unmarshal(response, &dat)
if err != nil {
Expand All @@ -129,10 +134,10 @@ func SendTransactionRequest(input TransactionRequest) (*TransactionResponse, err

type NewTransaction struct {
Amount string `json:"amount,omitempty"`
InvoiceId string `json:"invoiceId,omitempty"`
RefTransId string `json:"refTransId,omitempty"`
RefId string `json:"-"`
CreditCard CreditCard `json:"payment,omitempty"`
AuthCode string `json:"authCode,omitempty"`
Order *Order `json:"order,omitempty"`
BillTo *BillTo `json:"omitempty"`
}

Expand Down Expand Up @@ -190,7 +195,7 @@ type CreatePayment struct {

type CreateTransactionRequest struct {
MerchantAuthentication MerchantAuthentication `json:"merchantAuthentication,omitempty"`
RefID string `json:"refId,omitempty"`
RefId string `json:"refId,omitempty"`
TransactionRequest TransactionRequest `json:"transactionRequest,omitempty"`
}

Expand Down Expand Up @@ -261,23 +266,29 @@ 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"`
//Tax Tax `json:"tax,omitempty"`
//Duty Duty `json:"duty,omitempty"`
//Shipping Shipping `json:"shipping,omitempty"`
//PoNumber string `json:"poNumber,omitempty"`
//Customer Customer `json:"customer,omitempty"`
BillTo *BillTo `json:"billTo,omitempty"`
ShipTo *Address `json:"shipTo,omitempty"`
CustomerIP string `json:"customerIP,omitempty"`
//TransactionSettings TransactionSettings `json:"transactionSettings,omitempty"`
//UserFields UserFields `json:"userFields,omitempty"`
TransactionType string `json:"transactionType,omitempty"`
Amount string `json:"amount,omitempty"`
Payment *Payment `json:"payment,omitempty"`
RefId string `json:"-"`
AuthCode string `json:"authCode,omitempty"`
Profile *Profile `json:"profile,omitempty"`
Order *Order `json:"order,omitempty"`
LineItems *LineItems `json:"lineItems,omitempty"`
Tax *Tax `json:"tax,omitempty"`
Duty *Duty `json:"duty,omitempty"`
Shipping *Shipping `json:"shipping,omitempty"`
PoNumber *string `json:"poNumber,omitempty"`
Customer *Customer `json:"customer,omitempty"`
BillTo *BillTo `json:"billTo,omitempty"`
ShipTo *Address `json:"shipTo,omitempty"`
CustomerIP string `json:"customerIP,omitempty"`
TransactionSettings *TransactionSettings `json:"transactionSettings,omitempty"`
UserFields *UserFields `json:"userFields,omitempty"`
}

type Order struct {
InvoiceNumber string `json:"invoiceNumber,omitempty"`
Description string `json:"description,omitempty"`
}

type Address struct {
Expand Down
1 change: 1 addition & 0 deletions recurring_billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type Subscription struct {
Amount string `json:"amount,omitempty"`
TrialAmount string `json:"trialAmount,omitempty"`
Payment *Payment `json:"payment,omitempty"`
Order *Order `json:"order,omitempty"`
BillTo *BillTo `json:"billTo,omitempty"`
SubscriptionId string `json:"subscriptionId,omitempty"`
Profile *CustomerProfiler `json:"profile,omitempty"`
Expand Down