SkillAgentSearch skills...

AuthorizeCIM

Authorize.net CIM, AIM, and ARB Functions for Go Language

Install / Use

/learn @hunterlong/AuthorizeCIM
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

alt tag

Authorize.net CIM, AIM, and ARB for Go Language

Build Status Code Climate Coverage Status GoDoc Go Report Card

Give your Go Language applications the ability to store and retrieve credit cards from Authorize.net CIM, AIM, and ARB API. This golang package lets you create recurring subscriptions, AUTH only transactions, voids, refunds, and other functionality connected to the Authorize.net API.


Features

customer := AuthorizeCIM.Customer{
        ID: "13838",
    }

customerInfo := customer.Info()

paymentProfiles := customerInfo.PaymentProfiles()
shippingProfiles := customerInfo.ShippingProfiles()
subscriptions := customerInfo.Subscriptions()

Usage

  • Import package
go get gopkg.in/hunterlong/authorizecim.v1
import "gopkg.in/hunterlong/authorizecim.v1"
Or Shorten the Package Name
import auth "gopkg.in/hunterlong/authorizecim.v1"
// auth.SetAPIInfo(apiName,apiKey,"test")

Set Authorize.net API Keys

You can get Sandbox Access at: https://developer.authorize.net/hello_world/sandbox/

apiName := "auth_name_here"
apiKey := "auth_transaction_key_here"
AuthorizeCIM.SetAPIInfo(apiName,apiKey,"test")
// use "live" to do transactions on production server

Included API References

:white_check_mark: Set API Creds

func main() {

    apiName := "PQO38FSL"
    apiKey := "OQ8NFBAPA9DS"
    apiMode := "test"

    AuthorizeCIM.SetAPIInfo(apiName,apiKey,apiMode)

}

Payment Transactions

:white_check_mark: chargeCard

newTransaction := AuthorizeCIM.NewTransaction{
		Amount: "15.90",
		CreditCard: CreditCard{
			CardNumber:     "4007000000027",
			ExpirationDate: "10/23",
		},
	}
response, err := newTransaction.Charge()
if response.Approved() {

}

:white_check_mark: authorizeCard

newTransaction := AuthorizeCIM.NewTransaction{
		Amount: "100.00",
		CreditCard: CreditCard{
			CardNumber:     "4012888818888",
			ExpirationDate: "10/27",
		},
	}
response, err := newTransaction.AuthOnly()
if response.Approved() {

}

:white_check_mark: capturePreviousCard

oldTransaction := AuthorizeCIM.PreviousTransaction{
		Amount: "49.99",
		RefId:  "AUTHCODEHERE001",
	}
response, err := oldTransaction.Capture()
if response.Approved() {

}

:white_check_mark: captureAuthorizedCardChannel

newTransaction := AuthorizeCIM.NewTransaction{
		Amount: "38.00",
		CreditCard: CreditCard{
			CardNumber:     "4012888818888",
			ExpirationDate: "10/24",
		},
		AuthCode: "YOURAUTHCODE",
	}
response, err := newTransaction.Charge()
if response.Approved() {

}

:white_check_mark: refundTransaction

newTransaction := AuthorizeCIM.NewTransaction{
		Amount: "15.00",
		CreditCard: CreditCard{
			CardNumber:     "4012888818888",
			ExpirationDate: "10/24",
		},
		RefTransId: "0392482938402",
	}
response, err := newTransaction.Refund()
if response.Approved() {

}

:white_check_mark: voidTransaction

oldTransaction := AuthorizeCIM.PreviousTransaction{
		RefId: "3987324293834",
	}
response, err := oldTransaction.Void()
if response.Approved() {

}

:white_medium_square: updateSplitTenderGround

:white_medium_square: debitBankAccount

:white_medium_square: creditBankAccount

:white_check_mark: chargeCustomerProfile

customer := AuthorizeCIM.Customer{
		ID: "49587345",
		PaymentID: "84392124324",
	}

newTransaction := AuthorizeCIM.NewTransaction{
		Amount: "35.00",
	}

response, err := newTransaction.ChargeProfile(customer)

if response.Ok() {

}

:white_medium_square: chargeTokenCard

:white_medium_square: creditAcceptPaymentTransaction

:white_medium_square: getAccessPaymentPage

:white_medium_square: getHostedPaymentPageRequest

Transaction Responses

response.Ok()                   // bool
response.Approved()             // bool
response.Message()              // string
response.ErrorMessage()         // string
response.TransactionID()        // string
response.AVS()                  // [avsResultCode,cavvResultCode,cvvResultCode]

Fraud Management

:white_check_mark: getUnsettledTransactionListRequest

transactions := AuthorizeCIM.UnsettledBatchList()
fmt.Println("Unsettled Count: ", transactions.Count)

:white_check_mark: updateHeldTransactionRequest

oldTransaction := AuthorizeCIM.PreviousTransaction{
		Amount: "49.99",
		RefId:  "39824723983",
	}

	response, err := oldTransaction.Approve()
	//response := oldTransaction.Decline()

	if response.Ok() {

	}

Recurring Billing

:white_check_mark: ARBCreateSubscriptionRequest

subscription := AuthorizeCIM.Subscription{
		Name:        "New Subscription",
		Amount:      "9.00",
		TrialAmount: "0.00",
		PaymentSchedule: &PaymentSchedule{
			StartDate:        CurrentDate(),
			TotalOccurrences: "9999",
			TrialOccurrences: "0",
			Interval: AuthorizeCIM.IntervalMonthly(),
		},
		Payment: &Payment{
			CreditCard: CreditCard{
				CardNumber:     "4007000000027",
				ExpirationDate: "10/23",
			},
		},
		BillTo: &BillTo{
			FirstName: "Test",
			LastName:  "User",
		},
	}

response, err := subscription.Charge()

if response.Approved() {
    fmt.Println("New Subscription ID: ",response.SubscriptionID)
}
For Intervals, you can use simple methods
AuthorizeCIM.IntervalWeekly()      // runs every week (7 days)
AuthorizeCIM.IntervalMonthly()     // runs every Month
AuthorizeCIM.IntervalQuarterly()   // runs every 3 months
AuthorizeCIM.IntervalYearly()      // runs every 1 year
AuthorizeCIM.IntervalDays("15")    // runs every 15 days
AuthorizeCIM.IntervalMonths("6")   // runs every 6 months

:white_check_mark: ARBCreateSubscriptionRequest from Customer Profile

subscription := AuthorizeCIM.Subscription{
		Name:        "New Customer Subscription",
		Amount:      "12.00",
		TrialAmount: "0.00",
		PaymentSchedule: &PaymentSchedule{
			StartDate:        CurrentDate(),
			TotalOccurrences: "9999",
			TrialOccurrences: "0",
			Interval: AuthorizeCIM.IntervalDays("15"),
		},
		Profile: &CustomerProfiler{
			CustomerProfileID: "823928379",
			CustomerPaymentProfileID: "183949200",
			//CustomerShippingProfileID: "310282443",
		},
	}

	response, err := subscription.Charge()

	if response.Approved() {
		newSubscriptionId = response.SubscriptionID
		fmt.Println("Customer #",response.CustomerProfileId(), " Created a New Subscription: ", response.SubscriptionID)
	}

:white_check_mark: ARBGetSubscriptionRequest

sub := AuthorizeCIM.SetSubscription{
		Id: "2973984693",
	}

subscriptionInfo := sub.Info()

:white_check_mark: ARBGetSubscriptionStatusRequest

sub := AuthorizeCIM.SetSubscription{
		Id: "2973984693",
	}

subscriptionInfo, err := sub.Status()

fmt.Println("Subscription ID has status: ",subscriptionInfo.Status)

:white_check_mark: ARBUpdateSubscriptionRequest

subscription := AuthorizeCIM.Subscription{
		Payment: Payment{
			CreditCard: CreditCard{
				CardNumber:     "5424000000000015",
				ExpirationDate: "06/25",
			},
		},
		SubscriptionId: newSubscriptionId,
	}

response, err := subscription.Update()

if response.Ok() {

}

:white_check_mark: ARBCancelSubscriptionRequest

sub := AuthorizeCIM.SetSubscription{
		Id: "2973984693",
	}

subscriptionInfo, err := sub.Cancel()

fmt.Println("Subscription ID has been canceled: ", sub.Id, "\n")

:white_check_mark: ARBGetSubscriptionListRequest

inactive := AuthorizeCIM.SubscriptionList("subscriptionInactive")
fmt.Println("Amount of Inactive Subscriptions: ", inactive.Count())

active := AuthorizeCIM.SubscriptionList("subscriptionActive")
fmt.Println("Amount of Active Subscriptions: ", active.Count())

Customer Profile (CIM)

:white_check_mark: createCustomerProfileRequest

customer := AuthorizeCIM.Profile{
		MerchantCustomerID: "86437",
		Email:              "info@emailhereooooo.com",
		PaymentProfiles: &PaymentProfiles{
			CustomerType: "individual",
			Payment: Payment{
				CreditCard: CreditCard{
					CardNumber:     "4007000000027",
					ExpirationDate: "10/23",
				},
			},
		},
	}

	response, err := customer.Create()

if response.Ok() {
    fmt.Println("New Customer Profile Created #",response.CustomerProfileID)
    fmt.Println("New Customer Payment Profile Created #",response.Cu

Related Skills

View on GitHub
GitHub Stars37
CategoryDevelopment
Updated1y ago
Forks23

Languages

Go

Security Score

80/100

Audited on Jan 30, 2025

No findings