Skip to content

Instantly share code, notes, and snippets.

View alexanmtz's full-sized avatar
🎯
Focusing

Alexandre Magno alexanmtz

🎯
Focusing
View GitHub Profile
@alexanmtz
alexanmtz / checkout-form.js
Created September 12, 2018 18:10
A example of a simple CheckoutForm with React
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { injectStripe } from 'react-stripe-elements'
class CheckoutForm extends Component {
constructor (props) {
super(props)
this.handleSubmit = this.handleSubmit.bind(this)
this.onChange = this.onChange.bind(this)
@alexanmtz
alexanmtz / heroku_env_copy.sh
Created August 1, 2018 11:10 — forked from nabucosound/heroku_env_copy.sh
Script to copy environment variables from an existing heroku app to another one
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@alexanmtz
alexanmtz / credit_card.rb
Last active August 25, 2022 19:44
Erro ao chamar send_email: *** ActiveRecord::RecordInvalid Exception: A validação falhou: User é obrigatório(a)
class Payment::PostProcessing::CreditCard
def initialize(transaction)
@transaction = transaction
end
def after_payment(order)
@order = order
register_amount_paid
@order.pay!
save_credit_card
@alexanmtz
alexanmtz / SparkPost cURL Create (POST) Transmissions API Example
Created December 21, 2017 19:18 — forked from bdeanindy/SparkPost cURL Create (POST) Transmissions API Example
cURL POST Example to send an email using the SparkPost Transmissions API
curl \
-H "Content-Type: application/json" \
-H "Authorization: <REPLACE_WITH_YOUR_API_KEY>" \
-X POST -d '{"options":{"open_tracking":true,"click_tracking":true},"return_path":"bounces@<REPLACE_WITH_YOUR_SENDING_DOMAIN_HERE>","metadata":{"some_useful_metadata":"testing_sparkpost"},"substitution_data":{"signature":"<REPLACE_WITH_YOUR_FIRST_AND_LAST_NAME>"},"recipients":[{"address":{"email":"<REPLACE_WITH_YOUR_EMAIL_ADDRESS>","tags":["learning"],"substitution_data":{"customer_type":"Platinum","first_name":"<REPLACE_WITH_YOUR_FIRST_NAME>"}}}],"content":{"from":{"name":"Awesome Company","email":"testing@<REPLACE_WITH_YOUR_SENDING_DOMAIN>"},"subject":"My first SparkPost Transmission","reply_to":"Awesome Company ","text":"Hi {{address.first_name}}\r\nYou have just sent your first email through SparkPost!\r\nCongratulations,\r\n{{signature}}","html":"<strong>Hi {{address.first_name}},</strong><p>You have just sent your first email through SparkPost!</p><p>Congratulations!</p>{{signature}}"}}' \
https://api.sparkpos

Integrating Stripe with Rails (Concise)

This written tutorial is a concise version of this tutorial, which covers building a payment system into a Rails app using Stripe.js. It assumes a basic familiarity with Ruby on Rails, Git and the command-line.

What's covered

  • Setting up a basic Rails app with a scaffold generator
  • Integrating Stripe charges
  • Deploying to Heroku
@alexanmtz
alexanmtz / order_pay.rb
Last active February 21, 2017 14:36
Paying a order with application fee and connected account on stripe
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
Stripe::Order.create(
:currency => 'usd',
:email => 'jenny@example.com',
:items => [
{
:type => 'sku',
@alexanmtz
alexanmtz / plaid+managed.md
Created February 10, 2017 13:51 — forked from matthewarkin/plaid+managed.md
Plaid and Managed Accounts

Ensuring Valid External Accounts with Stripe and Plaid

When adding a bank account to a customer in Stripe, Stripe forces you to verify the bank account (either through microdeposits or through Plaid. This is useful because you don't want to withdraw money from a bank account that a user does not own. However when it comes to sending money to bank accounts, Stripe does not require you to verify the account. After all why would you send money to an account that you're not in control of. But lets face it, users make mistakes and its not uncommon for them to type their routing or account number which can significantly delay their transfers.

One way to prevent this is to get their routing and account number directly from their bank and avoid the possibility of user error. This is where Plaid comes in. Plaid provides instant ACH verification by having the user log into their bank account (similiar to what you may done if you've ever used Mint). The u

@alexanmtz
alexanmtz / overlay.scss
Created February 5, 2017 17:05
Overlay with CSS animations
@media screen and (max-width: 480px) {
html {
/*
* Overlay effect
*
*/
.overlay{
position:fixed;
width:100%;
height:100%;
@alexanmtz
alexanmtz / flex-navigation.scss
Created February 5, 2017 17:02
Flex navigation
/*
* Mobile styles
*
*/
@media screen and (max-width: 1000px) {
html {
&.no-scroll {
overflow: hidden;
}
@alexanmtz
alexanmtz / overlay.js
Created February 5, 2017 16:57
Overlay navigation with javascript
(function() {
var triggerBttn = document.getElementById( 'js-trigger-overlay' ),
overlay = document.querySelector( 'div.overlay' ),
body = document.querySelector( 'body' );
var transEndEventNames = {
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'transitionend',
'OTransition': 'oTransitionEnd',
'msTransition': 'MSTransitionEnd',
'transition': 'transitionend'