Giter VIP home page Giter VIP logo

Comments (7)

patrickml avatar patrickml commented on August 26, 2024

@kirkthaker

What you will do is call the client side api to tokenize the credit card like so


 Meteor.call('getClientToken', function (err, res) {
     //Client side API call
      var client = new braintree.api.Client({clientToken: res});

      client.tokenizeCard({
        number: form.billing.card.number,
        cardholderName: form.billing.card.name,
        expirationMonth: form.billing.card.exp.split('/')[0],
        expirationYear: form.billing.card.exp.split('/')[1],
        // CVV if required
        cvv: form.billing.card.cvv,
        // Address if AVS is on
        billingAddress: {
          postalCode: form.billing.card.zip
        }
      }, function (err, nonce) {
        if(err) {
          console.log('ERROR', err)
          return false;
        } else if(nonce) {
             console.log('SUCCESS', nonce)
        }
      });

    });

from braintree.

kirkthaker avatar kirkthaker commented on August 26, 2024

I tried using the code, but I get the following error:

"Exception in delivering result of invoking 'getClientToken': ReferenceError: braintree is not defined"

(in reference to the "new.braintree.api" part):

var client = new braintree.api.Client({clientToken: res});

Is there another package I have to install with this? I already have

<script src="https://js.braintreegateway.com/v2/braintree.js"></script> 

in my head.html file.

Thank you for helping!

from braintree.

patrickml avatar patrickml commented on August 26, 2024

Here this is how I generate the client token in our system (Meteor.methods (server side))


/**
   * Create a client token so we can create a secure token
   */
  createClientToken : function () {

    var bt = BrainTreeConnect({
      environment: process.env.PRODUCTION && Braintree.Environment.Production || Braintree.Environment.Sandbox,
      merchantId: Meteor.settings.BRAIN_TREE.MERCHANT_ID,
      publicKey:  Meteor.settings.BRAIN_TREE.PUBLIC_KEY,
      privateKey: Meteor.settings.BRAIN_TREE.PRIVATE_KEY
    });

    return bt.clientToken.generate({
      customerId : Meteor.users.findOne(this.userId).profile.billing.customerId
    }).clientToken;
  },

from braintree.

patrickml avatar patrickml commented on August 26, 2024

Also are you calling var client = new braintree.api.Client({clientToken: res}); on the client side or on the server side?

from braintree.

patrickml avatar patrickml commented on August 26, 2024

@kirkthaker any luck?

from braintree.

kirkthaker avatar kirkthaker commented on August 26, 2024

I fixed it! You were right - it was a matter of calling it on the client side, not the server side.

Thanks!

from braintree.

patrickml avatar patrickml commented on August 26, 2024

Awesome. I'm glad to here it! Let me know if you have any other questions
On Mon, Aug 3, 2015 at 12:15 PM kirkthaker [email protected] wrote:

I fixed it! You were right - it was a matter of calling it on the client
side, not the server side.

Thanks!


Reply to this email directly or view it on GitHub
#9 (comment).

from braintree.

Related Issues (16)

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.