Integrating Paypal payments in Flutter app

15,137

Solution 1

You can achieve this using WebView. PayPal provides some APIs to do transaction. Using those APIs you can achieve this.

Read this article

Paypal Payment Gateway Integration in Flutter

This article demonstrates the steps you need to follow.

Solution 2

Braintree is the payment processor provided by Paypal to accept safe and secure payments with feature Drop-in UI and custom UI design. It also provides the Apple Pay, Google Pay feature to accept the payments.

  1. Open Braintree Sandbox Account

  2. Get the tokenization key from Braintree account

  3. Add the flutter_braintree dependencies in your pubspec.yaml file

    dependencies:
    flutter_braintree: ^0.5.3+1

  4. Create custom UI

Paypal Credit card: accept the followings from user

a. Card Number

b. Expiration Month

c. Expiration Year

Create a Braintree Request

final request = BraintreeCreditCardRequest(

  card number: '4115511771161116',

  expiration month: '02',

  expiration year: '2020',

);

Ask Braintree to tokenization it

BraintreePaymentMethodNonce result = await Braintree.tokenizeCreditCard(

   '<Insert your tokenization key>',

   request,

);

For PayPal

create Paypal request

final request = BraintreePayPalRequest(amount: '50.00');

then launch Paypal Request

BraintreePaymentMethodNonce result = await Braintree.requestPaypalNonce(

   "Insert your tokenization key or client token here",

   request,

);
  1. Get the NONCE from Braintree after successful payment and get the failure message on cancel the Paypal Payment by the user.

  2. Save this NONCE for future reference in your database

Share:
15,137
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin about 2 years

    I just started on my Flutter journey and need to integrate Paypal payments into my app. However, there seems to be no standard Flutter API provided by Paypal and I couldn't find an acceptable answer anywhere.

  • Satria Suria
    Satria Suria over 2 years
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review