Search code examples
flutterpaypal

How to make Paypal paying inside Flutter app


Right now I am using the package 'flutter_braintree' from https://pub.dev/packages/flutter_braintree. But it does not work. Whenever I press next in the PayPal window in which you select the Payment method, it loads for 1 second and then I get redirected to my App.

See link: https://i.sstatic.net/nzAL2.jpg

RaisedButton(
  onPressed: () async {

  final request = BraintreePayPalRequest(amount: '13.37', currencyCode: "EUR");

  BraintreePaymentMethodNonce result = 
  await Braintree.requestPaypalNonce(
  tokenizationKey,
  request,
  );
  if (result != null) {
     showNonce(result);
  } else {
     print('PayPal flow was canceled.');
  }
  }
  ),

How you can help me:

  1. Maybe you know why it gets canceled
  2. Maybe you know another package which is better

Thanks in advance for your help!


Solution

  • You will need to use the Paypal REST API. Currently, there is no Dart package for PayPal. That means, that you will have to call manually. This is the official documentation: Documentation. By the way, you will need to create a PayPal-business account to use PayPal properly. If you don't know how to make HTTP calls inside Flutter, you should learn to do that first. A tutorial on doing this