All Projects → hunterlong → AuthorizeCIM

hunterlong / AuthorizeCIM

Licence: MIT license
Authorize.net CIM, AIM, and ARB Functions for Go Language

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to AuthorizeCIM

tokensubscription.com
⏰💰🤠 Set-it-and-forget-it token subscriptions on the Ethereum mainnet. #Winner #WyoHackathon
Stars: ✭ 81 (+125%)
Mutual labels:  subscription, transaction
J2pay
Multi-gateway payment processing library for java
Stars: ✭ 125 (+247.22%)
Mutual labels:  transaction, credit-card
Apphudsdk
Build, Measure and Grow iOS subscription business
Stars: ✭ 93 (+158.33%)
Mutual labels:  subscription
Purchases Flutter
Flutter in-app purchases and subscriptions made easy. iOS and Android support.
Stars: ✭ 181 (+402.78%)
Mutual labels:  subscription
Follow Github Organisation
Get notified when a new repository is created in a GitHub organisation
Stars: ✭ 143 (+297.22%)
Mutual labels:  subscription
Flare
Flare is a service that notify changes of HTTP endpoints
Stars: ✭ 110 (+205.56%)
Mutual labels:  subscription
Vue Supply
Create resources that can automatically be activated and deactivated when used (like subscriptions)
Stars: ✭ 162 (+350%)
Mutual labels:  subscription
Alfa
Effortless React State Management.
Stars: ✭ 86 (+138.89%)
Mutual labels:  subscription
Final Form
🏁 Framework agnostic, high performance, subscription-based form state management
Stars: ✭ 2,787 (+7641.67%)
Mutual labels:  subscription
Awesome Rss
Puts an RSS/Atom subscribe button back in URL bar
Stars: ✭ 125 (+247.22%)
Mutual labels:  subscription
Graphene Django Subscriptions
This package adds support to Subscription's requests and its integration with websockets using Channels package.
Stars: ✭ 173 (+380.56%)
Mutual labels:  subscription
The Economist Ebooks
经济学人(含音频)、纽约客、自然、新科学人、卫报、科学美国人、连线、大西洋月刊、新闻周刊、国家地理等英语杂志免费下载、订阅(kindle推送),支持epub、mobi、pdf格式, 每周更新. The Economist 、The New Yorker 、Nature、The Atlantic 、New Scientist、The Guardian、Scientific American、Wired、Newsweek magazines, free download and subscription for kindle, mobi、epub、pdf format.
Stars: ✭ 3,471 (+9541.67%)
Mutual labels:  subscription
Graphql Live Query
Realtime GraphQL Live Queries with JavaScript
Stars: ✭ 112 (+211.11%)
Mutual labels:  subscription
Laraplans
SaaS style recurring plans for Laravel.
Stars: ✭ 163 (+352.78%)
Mutual labels:  subscription
Ytcc
Command line tool to keep track of your favorite playlists on YouTube and many other places.
Stars: ✭ 92 (+155.56%)
Mutual labels:  subscription
Amazon Mws
Amazon MWS NodeJS Wrapper
Stars: ✭ 196 (+444.44%)
Mutual labels:  subscription
Chip
A drop-in subscription billing UI for Laravel
Stars: ✭ 91 (+152.78%)
Mutual labels:  subscription
Woocommerce Subscriptions Importer Exporter
Import your subscribers to WooCommerce from a CSV. Or export your subscription data from WooCommerce to CSV.
Stars: ✭ 117 (+225%)
Mutual labels:  subscription
Saas Boilerplate
SaaS boilerplate built in Laravel, Bootstrap 4 and VueJs.
Stars: ✭ 152 (+322.22%)
Mutual labels:  subscription
mongodb-replica-set
Run MongoDB Atlas locally for testing
Stars: ✭ 42 (+16.67%)
Mutual labels:  transaction

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

Set API Creds

func main() {

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

    AuthorizeCIM.SetAPIInfo(apiName,apiKey,apiMode)

}

Payment Transactions

chargeCard

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

}

authorizeCard

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

}

capturePreviousCard

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

}

captureAuthorizedCardChannel

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

}

refundTransaction

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

}

voidTransaction

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

}

◻️ updateSplitTenderGround

◻️ debitBankAccount

◻️ creditBankAccount

chargeCustomerProfile

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

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

response, err := newTransaction.ChargeProfile(customer)

if response.Ok() {

}

◻️ chargeTokenCard

◻️ creditAcceptPaymentTransaction

◻️ getAccessPaymentPage

◻️ 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

getUnsettledTransactionListRequest

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

updateHeldTransactionRequest

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

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

	if response.Ok() {

	}

Recurring Billing

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

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)
	}

ARBGetSubscriptionRequest

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

subscriptionInfo := sub.Info()

ARBGetSubscriptionStatusRequest

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

subscriptionInfo, err := sub.Status()

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

ARBUpdateSubscriptionRequest

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

response, err := subscription.Update()

if response.Ok() {

}

ARBCancelSubscriptionRequest

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

subscriptionInfo, err := sub.Cancel()

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

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)

createCustomerProfileRequest

customer := AuthorizeCIM.Profile{
		MerchantCustomerID: "86437",
		Email:              "[email protected]",
		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.CustomerPaymentProfileID)
} else {
       fmt.Println(response.ErrorMessage())
   }

getCustomerProfileRequest

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

customerInfo, err := customer.Info()

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

getCustomerProfileIdsRequest

profiles, _ := AuthorizeCIM.GetProfileIds()
fmt.Println(profiles)

updateCustomerProfileRequest

customer := AuthorizeCIM.Profile{
		MerchantCustomerID: "13838",
		CustomerProfileId: "13838",
		Description: "Updated Account",
		Email:       "[email protected]",
	}

	response := customer.Update()

if response.Ok() {

}

deleteCustomerProfileRequest

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

	response, err := customer.Delete()

if response.Ok() {

}

Customer Payment Profile

createCustomerPaymentProfileRequest

paymentProfile := AuthorizeCIM.CustomerPaymentProfile{
		CustomerProfileID: "32948234232",
		PaymentProfile: PaymentProfile{
			BillTo: BillTo{
				FirstName: "okokk",
				LastName: "okok",
				Address: "1111 white ct",
				City: "los angeles",
				Country: "USA",
				PhoneNumber: "8885555555",
			},
			Payment: Payment{
				CreditCard: CreditCard{
					CardNumber: "5424000000000015",
					ExpirationDate: "04/22",
				},
			},
			DefaultPaymentProfile: "true",
		},
	}

response, err := paymentProfile.Add()

if response.Ok() {

} else {
    fmt.Println(response.ErrorMessage())
}

getCustomerPaymentProfileRequest

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

response, err := customer.Info()

paymentProfiles := response.PaymentProfiles()

getCustomerPaymentProfileListRequest

profileIds := AuthorizeCIM.GetPaymentProfileIds("2017-03","cardsExpiringInMonth")

validateCustomerPaymentProfileRequest

customerProfile := AuthorizeCIM.Customer{
		ID: "127723778",
		PaymentID: "984583934",
	}

response, err := customerProfile.Validate()

if response.Ok() {

}

updateCustomerPaymentProfileRequest

customer := AuthorizeCIM.Profile{
		CustomerProfileId:  "3838238293",
		PaymentProfileId: "83929382739",
		Email:              "[email protected]",
		PaymentProfiles: &PaymentProfiles{
			Payment: Payment{
				CreditCard: CreditCard{
					CardNumber: "4007000000027",
					ExpirationDate: "01/26",
				},
			},
			BillTo: &BillTo{
				FirstName:   "newname",
				LastName:    "golang",
				Address:     "2841 purple ct",
				City:        "los angeles",
				State:		  "CA",
				Zip:            "93939",
				Country:     "USA",
				PhoneNumber: "8885555555",
			},
		},
	}

response, err := customer.UpdatePaymentProfile()

if response.Ok() {
    fmt.Println("Customer Payment Profile was Updated")
} else {
    fmt.Println(response.ErrorMessage())
}

deleteCustomerPaymentProfileRequest

customer := AuthorizeCIM.Customer{
		ID: "3724823472",
		PaymentID: "98238472349",
	}

response, err := customer.DeletePaymentProfile()

if response.Ok() {
    fmt.Println("Payment Profile was Deleted")
} else {
    fmt.Println(response.ErrorMessage())
}

Customer Shipping Profile

createCustomerShippingAddressRequest

customer := AuthorizeCIM.Profile{
		MerchantCustomerID: "86437",
		CustomerProfileId:  "7832642387",
		Email:              "[email protected]",
		Shipping: &Address{
			FirstName:   "My",
			LastName:    "Name",
			Company:     "none",
			Address:     "1111 yellow ave.",
			City:        "Los Angeles",
			State:       "CA",
			Zip:         "92039",
			Country:     "USA",
			PhoneNumber: "8885555555",
		},
	}

response, err := customer.CreateShipping()

if response.Ok() {
    fmt.Println("New Shipping Added: #",response.CustomerAddressID)
} else {
    fmt.Println(response.ErrorMessage())
}

getCustomerShippingAddressRequest

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

response, err := customer.Info()

shippingProfiles := response.ShippingProfiles()

fmt.Println("Customer Shipping Profiles", shippingProfiles)

updateCustomerShippingAddressRequest

customer := AuthorizeCIM.Profile{
		CustomerProfileId:  "398432389",
		CustomerAddressId: "848388438",
		Shipping: &Address{
			FirstName:   "My",
			LastName:    "Name",
			Company:     "none",
			Address:     "1111 yellow ave.",
			City:        "Los Angeles",
			State:       "CA",
			Zip:         "92039",
			Country:     "USA",
			PhoneNumber: "8885555555",
		},
	}

response, err := customer.UpdateShippingProfile()

if response.Ok() {
    fmt.Println("Shipping Profile was updated")
}

deleteCustomerShippingAddressRequest

customer := AuthorizeCIM.Customer{
		ID: "128749382",
		ShippingID: "34892734829",
	}

	response, err := customer.DeleteShippingProfile()

	if response.Ok() {
		fmt.Println("Shipping Profile was Deleted")
	} else {
		fmt.Println(response.ErrorMessage())
	}

◻️ getHostedProfilePageRequest

◻️ createCustomerProfileFromTransactionRequest

Transaction Reporting

getSettledBatchListRequest

list := AuthorizeCIM.Range{
		Start: LastWeek(),
		End:   Now(),
	}

batches := list.SettledBatch().List()

for _, v := range batches {
    t.Log("Batch ID: ", v.BatchID, "\n")
    t.Log("Payment Method: ", v.PaymentMethod, "\n")
    t.Log("State: ", v.SettlementState, "\n")
}

getUnSettledBatchListRequest

batches := AuthorizeCIM.UnSettledBatch().List()

for _, v := range batches {
    t.Log("Status: ",v.TransactionStatus, "\n")
    t.Log("Amount: ",v.Amount, "\n")
    t.Log("Transaction ID: #",v.TransID, "\n")
}

getTransactionListRequest

list := AuthorizeCIM.Range{
		BatchId: "6933560",
	}

batches := list.Transactions().List()

for _, v := range batches {
    t.Log("Transaction ID: ", v.TransID, "\n")
    t.Log("Amount: ", v.Amount, "\n")
    t.Log("Account: ", v.AccountNumber, "\n")
}

getTransactionDetails

oldTransaction := AuthorizeCIM.PreviousTransaction{
		RefId: "60019493304",
	}
response := oldTransaction.Info()

fmt.PrintLn("Transaction Status: ",response.TransactionStatus,"\n")

getBatchStatistics

list := AuthorizeCIM.Range{
		BatchId: "6933560",
	}

batch := list.Statistics()

fmt.PrintLn("Refund Count: ", batch.RefundCount, "\n")
fmt.PrintLn("Charge Count: ", batch.ChargeCount, "\n")
fmt.PrintLn("Void Count: ", batch.VoidCount, "\n")
fmt.PrintLn("Charge Amount: ", batch.ChargeAmount, "\n")
fmt.PrintLn("Refund Amount: ", batch.RefundAmount, "\n")

getMerchantDetails

info := AuthorizeCIM.GetMerchantDetails()

fmt.PrintLn("Test Mode: ", info.IsTestMode, "\n")
fmt.PrintLn("Merchant Name: ", info.MerchantName, "\n")
fmt.PrintLn("Gateway ID: ", info.GatewayID, "\n")

ToDo

  • Organize and refactor some areas
  • Add Bank Account Support
  • Make tests fail if transactions fail (skipping 'duplicate transaction')

Authorize.net CIM Documentation

http://developer.authorize.net/api/reference/#customer-profiles

Authorize.net Sandbox Access

https://developer.authorize.net/hello_world/sandbox/

License

This golang package is release under MIT license. Feel free to submit a Pull Request if you have updates!

This software gets reponses in JSON, but Authorize.net currently says "JSON Support is in BETA, please contact us if you intend to use it in production." Make sure you test in sandbox mode!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].