CasperVend 2/API: Difference between revisions
No edit summary |
|||
(27 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{|align=right | |||
|__TOC__ | |||
|} | |||
[[File:German_flag.gif]] [[CasperVend 2/API/DE | Schaue hier in Deutsch!]] | |||
== '''<span style="color:#00528c">Introduction</span>''' == | |||
Starting from the 12th of June 2012, CasperVend2 has a read-only API which is designed to help creators with scripting knowledge to create plugins for our vendors. | Starting from the 12th of June 2012, CasperVend2 has a read-only API which is designed to help creators with scripting knowledge to create plugins for our vendors. | ||
== Messages == | You cannot issue commands with the API, that's why it's read-only. | ||
== '''Legal stuff''' == | |||
Please make sure that any usage of our brands or trademarks is in line with our [https://wiki.casperdns.com/index.php/Brand_Usage brand usage policy]. | |||
== '''<span style="color:#00528c">Messages </span>''' == | |||
API messages are sent via linked message. They are sent on the following events: | API messages are sent via linked message. They are sent on the following events: | ||
#'''On Update''' - Vendor scrolled, rezzed, reset, or region restarted | #'''On Update''' - Vendor scrolled, rezzed, reset, or region restarted | ||
#'''Discount notification''' - When discounts are changed or vendor signs in | |||
#'''Transaction Completed''' - When a product has been successfully purchased from a vendor. | #'''Transaction Completed''' - When a product has been successfully purchased from a vendor. | ||
== On Update == | ==== On Update ==== | ||
---- | |||
This event occurs when a vendor is scrolled, reset, updated, rezzed, or the region is restarted. | This event occurs when a vendor is scrolled, reset, updated, rezzed, or the region is restarted. | ||
It provides information on the currently displayed product. | It provides information on the currently displayed product. | ||
Line 15: | Line 27: | ||
The following linked message is sent on the vendor concerned: | The following linked message is sent on the vendor concerned: | ||
llMessageLinked(LINK_SET, PRODUCT_PRICE, PRODUCT_NAME, PRODUCT_TEXTURE_KEY); | <syntaxhighlight lang="lsl">llMessageLinked(LINK_SET, PRODUCT_PRICE, PRODUCT_NAME, PRODUCT_TEXTURE_KEY);</syntaxhighlight> | ||
Please note that the characters ":", "@" and "|" are removed from the product name. | |||
==== Discount Notification ==== | |||
---- | |||
This event occurs when discounts are changed on the vendor, and is also sent on signin. | |||
The following linked message is sent on the vendor concerned: | |||
<syntaxhighlight lang="lsl">llMessageLinked(LINK_SET, -20, (string)GENERAL_DISCOUNT+","+(string)GROUP_DISCOUNT, (string)PRICE_OVERRIDE);</syntaxhighlight> | |||
If price override is -1, it is disabled. GENERAL_DISCOUNT and GROUP_DISCOUNT are percentages. | |||
== Transaction Completed == | ==== Transaction Completed ==== | ||
---- | |||
This event occurs when a transaction has been successfully completed, and the item delivered. | This event occurs when a transaction has been successfully completed, and the item delivered. | ||
Line 25: | Line 49: | ||
The following linked message is sent on '''BOTH the vendor used to purchase the product, and the dropbox used to deliver the item''' | The following linked message is sent on '''BOTH the vendor used to purchase the product, and the dropbox used to deliver the item''' | ||
<syntaxhighlight lang="lsl"> | |||
llMessageLinked(LINK_SET, -10, TRANSACTION_ID + ":" + PURCHASER_KEY + ":" + PURCHASER_NAME + ":" + RECIPIENT_NAME + ":" + AMOUNT_PAID + ":" + GIFT_CARD_USED + ":" + MODE + ":" + PRODUCT_ID + ":" + ITEM_NAME, RECIPIENT_KEY); | |||
</syntaxhighlight> | |||
== '''<span style="color:#00528c">Redelivery Terminal</span>''' == | |||
Since version 2.4 of the terminal, it's possible to customise the generation of redelivery URLs. | |||
To customise the redelivery terminal, there are two options: | |||
: 1. With the regular terminal (v2.4 or up), you can add a merchant UUID to the description in order to get it to generate a redelivery page for that MERCHANT. The format is: | |||
:: MERCHANT:<user key> | |||
:: for example | |||
:: MERCHANT:d1cd5b71-6209-4595-9bf0-771bf689ce00 | |||
:: for the CasperTech store. | |||
: 2. Use the extra script added to the vendor packs as of 2017-11-12. The script is called "8) Redelivery Link Generator v2.4 for HUDs", and you can send a linked message to it as follows: | |||
:: <syntaxhighlight lang="lsl">key user = "put the user's UUID here"; | |||
key merchant = "put the merchant's UUID here"; | |||
llMessageLinked( LINK_THIS, 0, "REDELIVER|"+(string)merchant, user );</syntaxhighlight> | |||
: Note that for security reasons, the URL is sent directly to the user. It's not possible to intercept the URL. The user must be on the same region as the script. | |||
== '''<span style="color:#00528c">Fields</span>''' == | |||
#'''TRANSACTION_ID''' - This is your CasperVend transactionID. This is used to uniquely identify this transaction. | |||
#'''PURCHASER_KEY''' - This is the key (''UUID'') of the avatar who has purchased the product - ''NOT THE RECIPIENT''. | |||
#'''PURCHASER_NAME''' - This is the avatar name (not display name or username) of the person purchasing the product. | |||
#'''RECIPIENT_NAME''' - This is the avatar name (not display name or username) of the person receiving the product. | |||
#'''AMOUNT_PAID''' - This is the amount that was paid for the item, in Linden Dollars. | |||
#'''GIFT_CARD_USED''' - This is 1 if a gift card was used for this transaction, 0 if not. | |||
#'''MODE''' - ''"norm"'' if a regular transaction. ''"lucky"'' if a lucky chair win. ''"midni"'' if a midnight madness win. | |||
#'''PRODUCT_ID''' - The CasperVend product ID of the product. You should use this rather than the item name, since the item name can change, but the product ID won't. | |||
#'''ITEM_NAME''' - The inventory item name that was delivered. | |||
#'''RECIPIENT_KEY''' - This is the key (''UUID'') of the avatar who has received the product. | |||
= '''<span style="color:#00528c">Script Samples</span>''' = | |||
=== IM Owner After Sale === | |||
---- | |||
Drop this script into your dropboxes to receive a nice IM whenever anyone buys anything. Kinda redundant because it does this anyway, but a good example. | |||
<syntaxhighlight lang="lsl"> | |||
default | |||
{ | |||
link_message(integer source, integer num, string str, key id) | |||
{ | |||
if (num==-10) | |||
{ | |||
list tmp = llParseStringKeepNulls(str,[":"],[]); | |||
string TransactionID = llList2String(tmp,0); | |||
key PurchaserKey = llList2Key(tmp,1); | |||
string PurchaserName = llList2String(tmp,2); | |||
string RecipientName = llList2String(tmp,3); | |||
integer amountPaid = llList2Integer(tmp,4); | |||
integer giftCardUsed = llList2Integer(tmp,5); | |||
string mode = llList2String(tmp,6); | |||
integer productID = llList2Integer(tmp,7); | |||
string itemName = llList2String(tmp,8); | |||
key RecipientKey = id; | |||
string sendText = "Hello! "+PurchaserName+" just bought a '"+itemName+"' from you"; | |||
if (giftCardUsed==1) | |||
{ | |||
sendText+=" (worth L$"+(string)amountPaid+"), using a gift card"; | |||
} | |||
else | |||
{ | |||
sendText+=" for L$"+(string)amountPaid; | |||
} | |||
if (RecipientKey!=PurchaserKey) | |||
{ | |||
sendText+=", as a gift for "+RecipientName; | |||
} | |||
if (mode=="lucky") | |||
{ | |||
sendText="Hello! "+PurchaserName+" just won a "+itemName+" from your lucky chair"; | |||
} | |||
sendText+="! You can view the full transaction details here: https://status.casperdns.com/?transaction="+TransactionID+"&t="+(string)llGetUnixTime(); | |||
llInstantMessage(llGetOwner(),sendText); | |||
} | |||
} | |||
} | |||
</syntaxhighlight> |
Latest revision as of 20:01, 18 April 2018
Introduction
Starting from the 12th of June 2012, CasperVend2 has a read-only API which is designed to help creators with scripting knowledge to create plugins for our vendors.
You cannot issue commands with the API, that's why it's read-only.
Legal stuff
Please make sure that any usage of our brands or trademarks is in line with our brand usage policy.
Messages
API messages are sent via linked message. They are sent on the following events:
- On Update - Vendor scrolled, rezzed, reset, or region restarted
- Discount notification - When discounts are changed or vendor signs in
- Transaction Completed - When a product has been successfully purchased from a vendor.
On Update
This event occurs when a vendor is scrolled, reset, updated, rezzed, or the region is restarted. It provides information on the currently displayed product.
The following linked message is sent on the vendor concerned:
llMessageLinked(LINK_SET, PRODUCT_PRICE, PRODUCT_NAME, PRODUCT_TEXTURE_KEY);
Please note that the characters ":", "@" and "|" are removed from the product name.
Discount Notification
This event occurs when discounts are changed on the vendor, and is also sent on signin.
The following linked message is sent on the vendor concerned:
llMessageLinked(LINK_SET, -20, (string)GENERAL_DISCOUNT+","+(string)GROUP_DISCOUNT, (string)PRICE_OVERRIDE);
If price override is -1, it is disabled. GENERAL_DISCOUNT and GROUP_DISCOUNT are percentages.
Transaction Completed
This event occurs when a transaction has been successfully completed, and the item delivered. It provides information on the transaction.
The following linked message is sent on BOTH the vendor used to purchase the product, and the dropbox used to deliver the item
llMessageLinked(LINK_SET, -10, TRANSACTION_ID + ":" + PURCHASER_KEY + ":" + PURCHASER_NAME + ":" + RECIPIENT_NAME + ":" + AMOUNT_PAID + ":" + GIFT_CARD_USED + ":" + MODE + ":" + PRODUCT_ID + ":" + ITEM_NAME, RECIPIENT_KEY);
Redelivery Terminal
Since version 2.4 of the terminal, it's possible to customise the generation of redelivery URLs.
To customise the redelivery terminal, there are two options:
- 1. With the regular terminal (v2.4 or up), you can add a merchant UUID to the description in order to get it to generate a redelivery page for that MERCHANT. The format is:
- MERCHANT:<user key>
- for example
- MERCHANT:d1cd5b71-6209-4595-9bf0-771bf689ce00
- for the CasperTech store.
- 2. Use the extra script added to the vendor packs as of 2017-11-12. The script is called "8) Redelivery Link Generator v2.4 for HUDs", and you can send a linked message to it as follows:
key user = "put the user's UUID here"; key merchant = "put the merchant's UUID here"; llMessageLinked( LINK_THIS, 0, "REDELIVER|"+(string)merchant, user );
- Note that for security reasons, the URL is sent directly to the user. It's not possible to intercept the URL. The user must be on the same region as the script.
Fields
- TRANSACTION_ID - This is your CasperVend transactionID. This is used to uniquely identify this transaction.
- PURCHASER_KEY - This is the key (UUID) of the avatar who has purchased the product - NOT THE RECIPIENT.
- PURCHASER_NAME - This is the avatar name (not display name or username) of the person purchasing the product.
- RECIPIENT_NAME - This is the avatar name (not display name or username) of the person receiving the product.
- AMOUNT_PAID - This is the amount that was paid for the item, in Linden Dollars.
- GIFT_CARD_USED - This is 1 if a gift card was used for this transaction, 0 if not.
- MODE - "norm" if a regular transaction. "lucky" if a lucky chair win. "midni" if a midnight madness win.
- PRODUCT_ID - The CasperVend product ID of the product. You should use this rather than the item name, since the item name can change, but the product ID won't.
- ITEM_NAME - The inventory item name that was delivered.
- RECIPIENT_KEY - This is the key (UUID) of the avatar who has received the product.
Script Samples
IM Owner After Sale
Drop this script into your dropboxes to receive a nice IM whenever anyone buys anything. Kinda redundant because it does this anyway, but a good example.
default
{
link_message(integer source, integer num, string str, key id)
{
if (num==-10)
{
list tmp = llParseStringKeepNulls(str,[":"],[]);
string TransactionID = llList2String(tmp,0);
key PurchaserKey = llList2Key(tmp,1);
string PurchaserName = llList2String(tmp,2);
string RecipientName = llList2String(tmp,3);
integer amountPaid = llList2Integer(tmp,4);
integer giftCardUsed = llList2Integer(tmp,5);
string mode = llList2String(tmp,6);
integer productID = llList2Integer(tmp,7);
string itemName = llList2String(tmp,8);
key RecipientKey = id;
string sendText = "Hello! "+PurchaserName+" just bought a '"+itemName+"' from you";
if (giftCardUsed==1)
{
sendText+=" (worth L$"+(string)amountPaid+"), using a gift card";
}
else
{
sendText+=" for L$"+(string)amountPaid;
}
if (RecipientKey!=PurchaserKey)
{
sendText+=", as a gift for "+RecipientName;
}
if (mode=="lucky")
{
sendText="Hello! "+PurchaserName+" just won a "+itemName+" from your lucky chair";
}
sendText+="! You can view the full transaction details here: https://status.casperdns.com/?transaction="+TransactionID+"&t="+(string)llGetUnixTime();
llInstantMessage(llGetOwner(),sendText);
}
}
}