Giter VIP home page Giter VIP logo

Comments (4)

crookedneighbor avatar crookedneighbor commented on August 26, 2024

ApplePay: https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/javascript/v3#apple-pay
GooglePay: https://developers.braintreepayments.com/guides/drop-in/setup-and-integration/javascript/v3#google-pay

If you need additional help, contact our support team: https://help.braintreepayments.com/

from braintree_php_example.

atta1234 avatar atta1234 commented on August 26, 2024

that's confused me,,,,
currently i have on front end,,,so what's the next step, to include that button same ui,,,
and secondly when i use crdit card 42424 4242 etc the transaction working , but when i select paypal ,
then it show this error "PayPal pending payments are not supported"

<script src="https://js.braintreegateway.com/web/dropin/1.13.0/js/dropin.min.js"></script>
    <script>
        var form = document.querySelector('#payment-form');
        var client_token = "{{ $token }}";
        braintree.dropin.create({
          authorization: client_token,
          selector: '#bt-dropin',
          paypal: {
            flow: 'vault'
          }
        }, function (createErr, instance) {
          if (createErr) {
            console.log('Create Error', createErr);
            return;
          }
          form.addEventListener('submit', function (event) {
            event.preventDefault();
            instance.requestPaymentMethod(function (err, payload) {
              if (err) {
                console.log('Request Payment Method Error', err);
                return;
              }
              // Add the nonce to the form and submit
              document.querySelector('#nonce').value = payload.nonce;
              form.submit();
            });
          });
        });
    </script>

from braintree_php_example.

atta1234 avatar atta1234 commented on August 26, 2024

sir can you please help,
i have added the google code above that one like this but not showing,,, and the token will be same for all,? or i have to do seprate back end for google pay? very confused please help,,,

@csrf
Amount
                    <div class="bt-drop-in-wrapper">
                        <div id="bt-dropin"></div>
                    </div>
                </section>

                <input id="nonce" name="payment_method_nonce" type="hidden" />
                <button class="button" type="submit"><span>Test Transaction</span></button>
            </form>
        </div>
    </div>
  </div>
 <!--  <div class="phonnumber">
      <p class="number">Need assistance? Call 1-800-669-4268</p>
  </div> -->
</div>

@endsection
@section('page-js')


<script src="https://js.braintreegateway.com/web/dropin/1.13.0/js/dropin.min.js"></script>
    <script>
        var form = document.querySelector('#payment-form');
        var client_token = "{{ $token }}";


      braintree.dropin.create({
          authorization: client_token,
  container: '#bt-dropin',
  googlePay: {
    googlePayVersion: 2,
    merchantId: 'merchant-id-from-google',
    transactionInfo: {
      totalPriceStatus: 'FINAL',
      totalPrice: '123.45',
      currencyCode: 'USD'
    },
    cardRequirements: {
      // We recommend collecting and passing billing address information with all Google Pay transactions as a best practice.
      billingAddressRequired: true
    }
  }
});




        braintree.dropin.create({
          authorization: client_token,
          selector: '#bt-dropin',
          paypal: {
            flow: 'vault'
          }
        },




         function (createErr, instance) {
          if (createErr) {
            console.log('Create Error', createErr);
            return;
          }
          form.addEventListener('submit', function (event) {
            event.preventDefault();
            instance.requestPaymentMethod(function (err, payload) {
              if (err) {
                console.log('Request Payment Method Error', err);
                return;
              }
              // Add the nonce to the form and submit
              document.querySelector('#nonce').value = payload.nonce;
              form.submit();
            });
          });
        });
    </script>

my backend function

public function index()
      {

    $gateway = new Braintree\Gateway([
        'environment' => 'sandbox',
        'merchantId' => 'tq7vsrgd2zjczk2t',
        'publicKey' => '',
        'privateKey' => ''
       ]);
   $token = $gateway->ClientToken()->generate();
      	$title="Home Page";
       return view('index',compact('title','token'));
       }
   public function checkout(Request $request){
      $gateway = new Braintree\Gateway([
        'environment' => 'sandbox',
        'merchantId' => 'tq7vsrgd2zjczk2t',
        'publicKey' => '',
        'privateKey' => ''
      ]);

       $amount = $request->amount;
       $nonce = $request->payment_method_nonce;
       $result = $gateway->transaction()->sale([
       'amount' => $amount,
       'paymentMethodNonce' => $nonce,
       'customer' => [
           'firstName' => 'Tony',
           'lastName' => 'Stark',
           'email' => '[email protected]',
       ],
       'options' => [
           'submitForSettlement' => true
       ]
   ]);

      // echo '<pre>';
      //  print_r($result);
      //  exit();


   if ($result->success) {
       $transaction = $result->transaction;
       // header("Location: transaction.php?id=" . $transaction->id);

       return back()->with('success_message', 'Transaction successful. The ID is:'. $transaction->id);
   } else {
       $errorString = "";

       foreach ($result->errors->deepAll() as $error) {
           $errorString .= 'Error: ' . $error->code . ": " . $error->message . "\n";
       }

       // $_SESSION["errors"] = $errorString;
       // header("Location: index.php");
       return back()->withErrors('An error occurred with the message: '.$result->message);
   }
 }


from braintree_php_example.

hollabaq86 avatar hollabaq86 commented on August 26, 2024

I'm locking this issue - please contact Braintree Support for assistance. Also, it is good security practice to never publicly share private keys (even for a sandbox account). You should rotate the API keys for your account.

from braintree_php_example.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.