Comments (7)
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.
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.
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.
Also are you calling var client = new braintree.api.Client({clientToken: res});
on the client side or on the server side?
from braintree.
@kirkthaker any luck?
from braintree.
I fixed it! You were right - it was a matter of calling it on the client side, not the server side.
Thanks!
from braintree.
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)
- Export Braintree.js Only to Server
- Do we also need the client SDK along with this package? HOT 2
- Cannot call method 'baseUrl' of undefined HOT 4
- TypeError: undefined is not a function HOT 4
- Possible way to use Braintree web-hooks? HOT 5
- Update README.md (webhooks, remove un-needed code)
- Remove `new` from braintree.js
- _ is not defined at BrainTreeConnect HOT 1
- Does this support the v.zero package from Braintree? HOT 3
- Error: braintree is not defined HOT 3
- Globally Settings BT Settings
- Does this run with Cordova? HOT 2
- Running Braintree version 1.27?
- Meteor 1.3 HOT 3
- BrainTreeConnect is undefined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from braintree.