flutterpluginspaypaltokenbraintree

Braintree integration for PayPal payments in Flutter


I have to integrate PayPal payments in Flutter and the only plugin that seems to have this kind of functionality is flutter_braintree. But the documentation there is not so detailed, so I am kind of confused how to use this plugin to have real payments. My mission is to have this kind of flow: click on a PayPal button in the app and then proceed with PayPal paying to a predefined IBAN. I tried to examine the PayPal and Braintree documentations, but since there is nothing mentioned for Flutter, I am a little bit confused. Please help me what's the right direction to go in order to fulfil my requirements. I have the following questions:

  1. How to use this plugin and make real payments? What do I need - a client token as far as I see, but I am going to generate this in Flutter?
  2. Where should I put the IBAN that I want the money to be transferred to?
  3. Am I supposed to use some kind of webviews for the PayPal, or this plugin is enough?

Thank you in advance, I am really stuck on this topic and can't find a solution.


Solution

  • Generate clientToken in php | nodejs see: https://developers.braintreepayments.com/reference/request/client-token/generate/php

    $clientToken = $gateway->clientToken()->generate([
      "customerId" => '21534539348326'//create customer in panel 
    ]);`
    

    Generate paymentNonce in app flutter:

    BraintreePayment braintreePayment = new BraintreePayment();
        var data = await braintreePayment.showDropIn(
            nonce: clientNonce,
             amount: "2.0", 
            inSandbox: true,
        );
        print("Response of the payment $data");
    

    // exe: Generate transaction in php | nodejs see: https://github.com/braintree/braintree_php

    $result = $gateway->transaction()->sale([
      'amount' => '1000.00',
      'paymentMethodNonce' => 'nonceFromTheClient',
      'options' => [ 'submitForSettlement' => true ]
    ]);