User Tools

Site Tools


whmcs-gift_card_v2_api

This is an old revision of the document!


Table of Contents

WHMCS Gift Card Module v2 API Documentation

API Base URL

index.php?m=giftcard&action=api&apikey=KEY&apipass=PASS

Where apikey/apipass is the respective key/pass found in the module

Generate Card based on quantity (Mode 0)

Required Variables

URL Variable Explaination
&apimode 0
&quantity integer larger than 0
&gctemplate is the Listing ID of the Card template you wish to use to generate the cards

Optional Variables

URL Variable Explaination
&pending when set to 1. All generated cards will set to pending
&priceoverride integer larger than 0 -when used, it will override the card's face value

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&gctemplate=1&apimode=0&quantity=10

Return (Success)

JSON, giftcardcode,giftcardcode,giftcardcode

["GC-1","GC2","GC3"]

Return (Fail)

JSON, fail:msg

["fail:gctemplate ID don't exist"]
["fail:quantity not valid"]
["fail:pending can only be 1"]
["fail:priceoverride must be positive integer larger than 0"]

Generate Card and assign to All Active Client (Mode 1)

Required Variables

URL Variable Explaination
&apimode 1
&gctemplate is the Listing ID of the Card template you wish to use to generate the cards

Optional Variables

URL Variable Explaination
&pending when set to 1. All generated cards will set to pending
&priceoverride integer larger than 0 -when used, it will override the card's face value
&notifyemail when set to 1. An email notification is sent to the client regarding gift card assigned

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&gctemplate=1&apimode=0

Return (Success)

JSON, giftcardcode:card value:clientid,giftcardcode:card value:clientid

["GC-1:123:1","GC2:123:2","GC3:123:3"]

Return (Fail)

JSON, fail:msg

["fail:gctemplate  ID don't exist"]
["fail:pending can only be 1"]
["fail:priceoverride must be positive integer larger than 0"]
["fail:notifyemail can only be 1"]

Generate Card and assign to All Clients (Active+Inactive) (Mode 2)

Required Variables

URL Variable Explaination
&apimode 2
&gctemplate is the Listing ID of the Card template you wish to use to generate the cards

Optional Variables

URL Variable Explaination
&pending when set to 1. All generated cards will set to pending
&priceoverride integer larger than 0 -when used, it will override the card's face value
&notifyemail when set to 1. An email notification is sent to the client regarding gift card assigned

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&gctemplate=1&apimode=2

Return (Success)

JSON, giftcardcode:card value:clientid

["GC-1:123:1","GC2:123:2","GC3:123:3"]

Return (Fail)

JSON, fail:msg

["fail:gctemplate  ID don't exist"]
["fail:pending can only be 1"]
["fail:priceoverride must be positive integer larger than 0"]
["fail:notifyemail can only be 1"]

Generate Card and assign to All Inactive Client (Mode 3)

Required Variables

URL Variable Explaination
&apimode 3
&gctemplate is the Listing ID of the Card template you wish to use to generate the cards

Optional Variables

URL Variable Explaination
&pending when set to 1. All generated cards will set to pending
&priceoverride integer larger than 0 -when used, it will override the card's face value
&notifyemail when set to 1. An email notification is sent to the client regarding gift card assigned

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&gctemplate=1&apimode=3

Return (Success)

JSON, giftcardcode:card value:clientid

["GC-1:123:1","GC2:123:2","GC3:123:3"]

Return (Fail)

JSON, fail:msg

["fail:gctemplate  ID don't exist"]
["fail:pending can only be 1"]
["fail:priceoverride must be positive integer larger than 0"]
["fail:notifyemail can only be 1"]

Generate Card and assign to specific client (Mode 4)

Required Variables

URL Variable Explaination
&apimode 4
&gctemplate is the Listing ID of the Card template you wish to use to generate the cards
&clientid the client id you want to assign the card to

Optional Variables

URL Variable Explaination
&pending when set to 1. All generated cards will set to pending
&priceoverride integer larger than 0 -when used, it will override the card's face value
&notifyemail when set to 1. An email notification is sent to the client regarding gift card assigned

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&gctemplate=1&apimode=4&clientid=2

Return (Success)

JSON, giftcardcode:card value:clientid

["GC-1:123:1"]

Return (Fail)

JSON, fail:msg

["fail:gctemplate ID don't exist"]
["fail:pending can only be 1"]
["fail:priceoverride must be positive integer larger than 0"]
["fail:notifyemail can only be 1"]
["fail:Client ID invalid"]

Generate Card and assign to All Active Client in a client group (Mode 5)

Required Variables

URL Variable Explaination
&apimode 5
&gctemplate is the Listing ID of the Card template you wish to use to generate the cards
&clientgroupid the client group id

Optional Variables

URL Variable Explaination
&pending when set to 1. All generated cards will set to pending
&priceoverride integer larger than 0 -when used, it will override the card's face value
&notifyemail when set to 1. An email notification is sent to the client regarding gift card assigned

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&gctemplate=1&apimode=5&clientgroupid=1

Return (Success)

JSON, giftcardcode:card value:clientid

["GC-1:123:1","GC2:123:2","GC3:123:3"]

Return (Fail)

JSON, fail:msg

["fail:gctemplate  ID don't exist"]
["fail:pending can only be 1"]
["fail:priceoverride must be positive integer larger than 0"]
["fail:notifyemail can only be 1"]
["fail:Client group ID is invalid"]

Generate Card and assign to All Client (Active & Inactive) in a client group (Mode 6)

Required Variables

URL Variable Explaination
&apimode 6
&gctemplate is the Listing ID of the Card template you wish to use to generate the cards
&clientgroupid the client group id

Optional Variables

URL Variable Explaination
&pending when set to 1. All generated cards will set to pending
&priceoverride integer larger than 0 -when used, it will override the card's face value
&notifyemail when set to 1. An email notification is sent to the client regarding gift card assigned

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&gctemplate=1&apimode=6&clientgroupid=1

Return (Success)

JSON, giftcardcode:card value:clientid

["GC-1:123:1","GC2:123:2","GC3:123:3"]

Return (Fail)

JSON, fail:msg

["fail:gctemplate  ID don't exist"]
["fail:pending can only be 1"]
["fail:priceoverride must be positive integer larger than 0"]
["fail:notifyemail can only be 1"]
["fail:Client group ID is invalid"]

Generate Card and assign to All Inactive Client in a client group (Mode 7)

Required Variables

URL Variable Explaination
&apimode 7
&gctemplate is the Listing ID of the Card template you wish to use to generate the cards
&clientgroupid the client group id

Optional Variables

URL Variable Explaination
&pending when set to 1. All generated cards will set to pending
&priceoverride integer larger than 0 -when used, it will override the card's face value
&notifyemail when set to 1. An email notification is sent to the client regarding gift card assigned

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&gctemplate=1&apimode=7&clientgroupid=1

Return (Success)

JSON, giftcardcode:card value:clientid

["GC-1:123:1","GC2:123:2","GC3:123:3"]

Return (Fail)

JSON, fail:msg

["fail:gctemplate  ID don't exist"]
["fail:pending can only be 1"]
["fail:priceoverride must be positive integer larger than 0"]
["fail:notifyemail can only be 1"]
["fail:Client group ID is invalid"]

Check Gift Card Status (Mode 10)

Required Variables

URL Variable Explaination
&apimode 10
&giftcard urlencode(the gift card)

Optional Variables

URL Variable Explaination

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&apimode=10&giftcard=abccd

Return (Success)

JSON, success:gift card:status:expiry time:expiry mode:gift card value:buyer id:redeemer id:order id:invoice id:allow self redemption:master card:subcards:onetime use

{"success":"GC-12345:redeemed:31536000:7days:20:0:1:0:0:0:0:0:1"}

Return (Fail)

JSON, fail:msg

["fail:Gift Card not exist"]

Redeem a Gift Card to a client (Mode 11)

Required Variables

URL Variable Explaination
&apimode 11
&clientid the client id
&giftcard urlencode(the gift card)

Optional Variables

URL Variable Explaination

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&apimode=11&client=1&giftcard=abccd

Return (Success)

JSON, success:msg

["success:deposited to client]

Return (Fail)

JSON, fail:msg

["fail:Client ID invalid"]
["fail:Gift Card not exist"]
["fail:Gift Card Invalid"]
["fail:Card not allow to self redemption"]
["fail:Card already used"]
["fail:Card Expired"]
["fail:Unable to deposit"]

Modify Gift Card (Mode 12)

Required Variables

URL Variable Explaination
&apimode 12
&giftcard urlencode(the gift card) Must not be redeemed or voided

Optional Variables

URL Variable Explaination
&setvalue positive integer for new gift value
&setexpiry 0-6 (never/24 hours/7 days/30 days/90days/180 days/365 days) for expiry mode
&setstatus 0/1/9 (Pending/Approved/Void)
&setselfredeem 1 to enable self redemption, 0 to disable
&setmaster 1 to enable splitting for the card, 0 to disable
&resetdate 1 to reset the creation date to today
&setassign Client ID to assign the card to
&setonetime (new in 2.31) 1 to enable one time use, 0 to disable

Sample API URL

index.php?m=giftcard&action=api&apikey=123&apipass=DEF&apimode=12&client=1&giftcard=abccd

Return (Success)

JSON, success:msg

["success:gift card updated]

Return (Fail)

JSON, fail:msg

["fail:Gift Card already redeemded"]
["fail:Gift Card is void"]
["fail:setvalue must be positive integer larger than 0"]
["fail:setexpiry must be between 0-6"]
["fail:setstatus must be between 0,1,9"]
["fail:setselfredeem must be between 0 or 1"]
["fail:setmaster must be between 0 or 1"]
["fail:resetdate must be 1"]
["fail:clientid invalid"]
whmcs-gift_card_v2_api.1528485053.txt.gz · Last modified: 2018/06/08 20:10 by wiki