CafeBazaar In-App Billing package for flutter this package is just for android applications and not work on ios
This plugin is just for Android applications
cafebazaar_flutter: <Last Version>
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" />
import 'package:cafebazaar_flutter/cafebazaar_flutter.dart';
CafebazaarFlutter.showProgramPage("packageName") // Replace "package Name" with Your application Package Name. you can find package name on gradle file
CafebazaarFlutter.setComment("packageName") // Replace "package Name" with Your application Package Name. you can find package name on gradle file
CafebazaarFlutter.showDeveloperPage("developerId") // Replace "developerId" with Your developerId in CafeBazaar
CafebazaarFlutter.showCafebazzarLogin()
For use In-app purchases on your application use below code جهت استفاده از پرداخت درون برنامه ای به صورت زیر عملکنید.
initState
use async and await
await CafebazaarFlutter.initPay(rsaKey:"Your RSA Key From CafeBazaar");
launchPurchaseFlow
method on the In-app Billing pluginMap<String,dynamic> result = await CafebazaarFlutter.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.
'{
"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 = CafebazaarFlutter.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"
}'
bool result = await CafebazaarFlutter.verifyDeveloperPayload("your developerPayload");
await CafebazaarFlutter.dispose();
Author: irdeveloper89
Source Code: https://github.com/irdeveloper89/cafebazaar_flutter
#flutter #dart #mobile-apps