Skip to content

dorjoosoft/GodotCafebazaar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GodotCafebazaar:

Godot CafeBazaar plugin implemented based on Godot 3.2.2+ android plugin standards.

New release upgrades to work on Godot 3.5.1+ projects as well.
This plugin uses Cafebazaar Poolakey sdk.

prerequisite:

Install Custom builds for Android using official godot engine documention.

Installation:

Download latest release from release page and extract content to [your_project_path]/android/plugins folder.

Enable plugin on export dialog.

Enable plugin

From "Project>Project settings" dialog do steps 1 and 2 as you see in below image:

Enable plugin

Note: You have to activate your VPN before build after this settings by now!

Note: This plugin just works on your build on device.

Connect to plugin in Godot:
Download cafebazaar.gd  file and add it to your games common folder and add it to your Autoload.

Enable plugin

Send a Purchase request:

Read comments for more information!

func sendPurchaseRequest(p1 , p2, p3):
	# Send a purchase request
	var productId = p1    #for example: "powerUp1" 
	var requestCode = p2  #for example: 1234
	var payload = p3		  #for example: "kl97AS#@fasdfg"
	Cafebazaar.Plugin.purchase(productId, requestCode, payload); 
	#productId -> This is the product id that you have defined inside of the developers panel.
	#requestCode -> This is just a random integer but, it's a good practice to make this a constant property.
	#payload -> This can be an empty string or anything else that you wish, but it's a good practice to actually pass in some data to help you to verify the purchase.

 

Handle Purchase result:

Add this codes to handle purchase result 

func _ready():
	# Handle purchase result [currently handle success result] 
	Cafebazaar.Plugin.connect("purchase_succeed", self, "purchase_succeed")
func purchase_succeed(resultCode):
	var pResult = JSON.parse(resultCode)
	# result["productId"] contains your product id registered in CafeBazaar panel.
	print(pResult.result["productId"])

 

Consume purchase:

Note: on purchase success event the consume method is called automatically in plugin purchase flow by now and you can send user to buy that item again. I'll make this method separated on next plugin update.