简体   繁体   中英

Does anyone know how to create a paypal donate button using flutter?

我正在尝试使用 Flutter 创建一个具有 Paypal 捐赠按钮的应用程序,但 Paypal 只提供捐赠按钮的 html 代码,所以有人知道如何使用 Flutter 创建吗?

You could create your own button with a Container - decoration - radius , a background color and so on (or just an image with a FlatButton on top), but that is not recommended. App Store Guidelines prohibit any third party payment solutions. So you could only use it in the Play Store with Android Apps.

Now what you can do is use In-App Purchases to handle such donations. There is an easy package here .

Set everything like in the example and just call this to start a purchase flow:

List<IAPProduct> _productIds = [];
...
@override initState() { 
    super.initState(); 
    init(); 
} 

init() async { 
    IAPResponse response = await FlutterIap.fetchProducts(["com.example.testiap"]); 
    List<IAPProduct> productIds = response.products; 
    if (!mounted) 
        return; 
    setState(() {
        _productIds = productIds; 
    }); 
}

Then call this, anywhere you like:

FlutterIap.buy(_productIds.first.productIdentifier);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM