Last active
August 29, 2015 14:21
-
-
Save SeraphimSerapis/b2e895e8af319b6433c4 to your computer and use it in GitHub Desktop.
Hosted Fields combined
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HostedFields = React.createClass({ | |
componentDidMount: function() { | |
this.initBraintree(); | |
}, | |
initBraintree() { | |
braintree.setup(clientToken, 'custom', { | |
id: 'hosted', | |
hostedFields: { | |
onFieldEvent: function (event) { | |
if (event.type === 'fieldStateChange') { | |
var type = ''; | |
if (event.card) { | |
type = event.card.type.replace('-', ''); | |
} | |
$('#card-type').text(type); | |
} | |
}, | |
number: { | |
selector: '#card-number' | |
}, | |
cvv: { | |
selector: '#cvv' | |
}, | |
expirationDate: { | |
selector: '#expiration-date' | |
} | |
} | |
}); | |
}, | |
render: function() { | |
return ( | |
<form action="/pay" id="hosted"> | |
<FieldCardNumber /> | |
<FieldCVV /> | |
<FieldExpirationDate /> | |
<FieldCardType /> | |
<FieldSubmit /> | |
</form> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment