flutter plugin for Cafebazaar android market (only works on android)
ارتباط با برنامه کافه بازار
- رفتن به صفحه اپلیکیشن
//launches application page on bazaar app if bazaar is installed
CafebazaarMarket.showProgramPage();
- گذاشتن کامنت و امتیاز دادن به برنامه
//launches comment bazaar dialog
CafebazaarMarket.setComment();
- رفتن به صفحه برنامه نویس
//launches developer page on bazaar
CafebazaarMarket.showDeveloperPage("your_id");
- رفتن به صفحه ورود کافه بازار
//launches bazaar login page
CafebazaarMarket.showCafebazzarLogin();
بررسی اپدیت بودن برنامه
- بررسی اپدیت بودن برنامه در صورت موجود بودن نسخه جدید
bool isUpdateAvailable = await CafebazaarMarket.isUpdateAvailable();
if(isUpdateAvailable) {
CafebazaarMarket.showProgramPage();
//or just show a dialog ask if user wants to update then call CafebazaarMarket.showProgramPage(); }
بخش پرداخت کافه بازار
- جهت استفاده از پرداخت درون برنامه ای به صورت زیر عمل کنید.
- این خط رو به فایل مانیفست برنامه اظافه کنید
- Adding the com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR permission to your AndroidManifest.xml file
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />
- این خط رو در قسمت initState اظافه کنید
use async and await
await CafebazaarMarket.initPay(rsaKey:"Your RSA Key From CafeBazaar");
- این خط رو در قسمت dispose اظافه کنید
- Important: Remember to unbind from the In-app Billing service when you are done with your Activity. If you don’t unbind, the open service connection could cause your device’s performance to degrade. This example shows how to perform the unbind operation on a service connection to In-app Billing called mServiceConn by overriding the activity’s onDestroy method.
await CafebazaarMarket.disposePayment();
Map<String,dynamic> result = await CafebazaarMarket.launchPurchaseFlow(
sku: "wm2", consumption: false,payload:"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
// after pay you get some data from Cafebazaar, if you get response code -1005 the payment is canceled by the user and if get code 0 the payment is Success
-
sku
: your product id on CafeBazaar -
consumption
: if your product is not a subscriber type you must consume it, For product consumption, set the consumption to true
*consumption
:
زمانی که محصول شما از نوع اشتراکی نباشد و از نوع مصرفی باشد باید ان را مصرف کنید تا در خرید ها بعدی کاربر بتواند ان را دوباره خریداری کند برای مصرف یک محصول
consumption
را به صورت
true
.تنظیم کنید
4.payload
: The developerPayload
String is used to specify any additional arguments that you want Bazaar to send back along with the purchase information.
- Result If pay is success
'{
"isSuccess": "true",
"response":"0",
"message":"Success (response: 0:OK)",
"purchase":{
"orderId":"12999763169054705758.1371079406387615",
"packageName":"com.example.app",
"productId":"exampleSku",
"purchaseTime":1345678900000,
"purchaseState":0,
"developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
"purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
}
}'
Map<String,dynamic> result = CafebazaarMarket.getPurchase(sku:"your product sku") // you can find sku(product id) in your application in-app section
// you get the payment details if you consumption the product result is null
Result
'{
"orderId":"12999763169054705758.1371079406387615",
"packageName":"com.example.app",
"productId":"exampleSku",
"purchaseTime":1345678900000,
"purchaseState":0,
"developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
"purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
}'
- Security Recommendation: When you send a purchase request, create a String token that uniquely identifies this purchase request and include this token in the developerPayload.You can use a randomly generated string as the token. When you receive the purchase response from Bazaar, make sure to check the returned data signature, the orderId, and the developerPayload String. For added security, you should perform the checking on your own secure server. Make sure to verify that the orderId is a unique value that you have not previously processed, and the developerPayload String matches the token that you sent previously with the purchase request.
bool result = await CafebazaarMarket.verifyDeveloperPayload("your developerPayload");