Skip to content

Instantly share code, notes, and snippets.

View SeraphimSerapis's full-sized avatar

Tim Messerschmidt SeraphimSerapis

View GitHub Profile
@SeraphimSerapis
SeraphimSerapis / .gitlab-ci.yml
Created October 12, 2020 10:05
GitLab CI Home Assistant config validation
stage: homeassistant
variables:
PYTHONPATH: "/usr/src/app:$PYTHONPATH"
before_script:
- python -m homeassistant --version
- mv mock_secrets.yaml secrets.yaml
script:
- |
python -m homeassistant \
--config . \
result = Braintree::Transaction.sale(
:amount => "10.00",
:payment_method_nonce => "nonce-from-the-client"
)
@SeraphimSerapis
SeraphimSerapis / mp2.rb
Created May 20, 2015 23:38
marketplace2
result = Braintree::Transaction.sale(
:amount => "10.00",
:payment_method_nonce => "nonce-from-the-client",
:merchant_account_id => "provider_sub_merchant_account",
:service_fee_amount => "1.00"
)
@SeraphimSerapis
SeraphimSerapis / token.rb
Created May 19, 2015 23:33
Sale from token
Braintree::Transaction.sale(
:payment_method_token => "the_token",
:amount => "10.00"
)
@SeraphimSerapis
SeraphimSerapis / customer.rb
Created May 19, 2015 23:08
Create a new customer
result = Braintree::Customer.create(
:first_name => "John",
:last_name => "Doe",
:payment_method_nonce => params[:payment_method_nonce]
)
if result.success?
puts result.customer.id
puts result.customer.credit_cards[0].token
end
@SeraphimSerapis
SeraphimSerapis / vault.rb
Created May 19, 2015 22:36
Store a payment method for future usage
Braintree::Transaction.sale(
:amount => "100.00",
:payment_method_nonce => "nonce-from-the-client",
:options => {
:store_in_vault_on_success => true
}
)
@SeraphimSerapis
SeraphimSerapis / styles.css
Created May 18, 2015 22:45
Field validation with CSS
.braintree-hosted-fields-focused {
border-color: blue;
}
.braintree-hosted-fields-invalid {
border-color: red;
}
.braintree-hosted-fields-valid {
border-color: green;
@SeraphimSerapis
SeraphimSerapis / render.js
Created May 18, 2015 22:29
Rendering instruction
React.render(
<HostedFields />, document.getElementById('fields')
);
@SeraphimSerapis
SeraphimSerapis / index.jade
Last active August 29, 2015 14:21
Jade template
h1 Hosted Fields with React
div#fields
script.
var clientToken = '#{clientToken}';
script(type='text/jsx' src='javascripts/index.js')
@SeraphimSerapis
SeraphimSerapis / fields.js
Last active August 29, 2015 14:21
Hosted Fields combined
var HostedFields = React.createClass({
componentDidMount: function() {
this.initBraintree();
},
initBraintree() {
braintree.setup(clientToken, 'custom', {
id: 'hosted',
hostedFields: {
onFieldEvent: function (event) {
if (event.type === 'fieldStateChange') {