Você está na página 1de 15

Version 1

check for updates!


this quick crash
course will get you
started

jump start
credit card processing
by amy hoy, thomas fuchs &
sponsored by freckle time tracking dieter komendera
Version 1
check for updates!

PART 1: How it Works


Flow & Terms

by amy hoy, thomas fuchs &


sponsored by freckle time tracking dieter komendera
card processing lifecycle: 10,000 ft view freckle
time tracking rethought

you collect the billing info the processing gateway


1 from your customer 2b
checks the card and passes
it along

3 your merchant services


2a you send it to the provider will attempt
processing gateway to charge the card

money appears in
4 your corporate
devil's in the details bank account

1 You decide how much data to collect; in reality,


only the card number and expiration date are truly
required

2a You'll use an API over a secure HTTPS connection 2b Address Verification Service (AVS) happens
to talk to your gateway; code your own interface here, if you use it.
or use any number of handy libraries
card processing lifecycle: key actions freckle
time tracking rethought

authorize auth = @gateway.authorize(money_in_cents, card_obj, options) #activemerchant


You attempt to place a hold on the credit card. If successful, you can either continue the charge or the hold
will expire after a period of time.

Hold succeeded! You receive an authorization code.

Your App Gateway Hold failed!

capture @gateway.capture(money_in_cents, auth, options) #activemerchant


You finalize the hold—you "capture" the money. You supply the authorization code to complete the transaction.
AUTH CODE

Your App Gateway Merch. Service Corp. Bank Acct

purchase @gateway.purchase(money_in_cents, cc_object, options) #activemerchant


authorize + capture in one request

void @gateway.void(auth, options) #activemerchant


Kill a successful hold, instead of waiting days for it to expire.

Hold removed!
Your App Gateway
other actions freckle
time tracking rethought

transactions managing data


Storing credit cards securely is a major hassle. In the
credit US, you'll have to comply with very stringent security
You return money to / place money on the provided requirements before the credit card banks will allow
credit card. A credit, rather than a debit. you to do it. It's much easier to let your processing
gateway do it for you—they're the experts.

store
Store credit card details (number, expiration date,
billing address) for a new customer.

update
Update credit card details (number, expiration date,
billing address) for an existing customer.
three ways to validate cards freckle
time tracking rethought

Checksum verification WHEN: 1 you collect the card


Checksum verification checks the likelihood
that the credit card number is real by means of RELIABILITY: LOW
an algorithm called Luhn10. But, this doesn't
INVASIVENESS: NON-INVASIVE
mean it's a usable card. However, it's a good
first defense. YOUR COST: NONE

Address Verification (AVS) WHEN: 2 you submit the card to the


AVS is meant to check the billing address processing gateway
provided against the address the credit card
RELIABILITY: LOW
company has. However, it's not useful for non-
US customers, and it's very typical for a INVASIVENESS: NON-INVASIVE
genuine card owner to enter information that
is slightly incorrect. AVS is, therefore, not the
YOUR COST: FEES MAY APPLY
silver bullet it's meant to be.

Test charge and/or real charge WHEN: 3 you charge a token amount, &
If you want to verify a card for later billing, reverse it
your best bet is to perform a test charge:
charge a small amount (ideally $1.00) to the RELIABILITY: HIGH
card, & if it comes back OK, void the INVASIVENESS: INVASIVE
transaction. If you'll be charging the customer
immediately, & you're in a low-fraud market, YOUR COST: FEES MAY APPLY
the best way to ensure a card can be charged
is to charge it.
Version 1
check for updates!

PART 2: ActiveMerchant
& JavaScript

by amy hoy, thomas fuchs &


sponsored by freckle time tracking dieter komendera
using activemerchant with ruby freckle
time tracking rethought

activemerchant rocks online resources


activemerchant is by far the most popular way of handling any kind
of credit card transactions with Ruby and Ruby on Rails.
supported gateways
To get started with activemerchant:
how to install activemerchant
1 Check the supported gateways list (linked right) to
be sure you've got / will be using one of the many github repository
supported credit card processing gateway services.
peepcode book (recommended!)
2 Download and install activemerchant as a rubygem
(recommended) or a Rails plugin (instructions linked SaaS railskit (recommended!)
right).

3 Configure your gateway.yml file, like so:

development:
login: 'abcdef'
password: '123456'
production:
login: 'xyz123'
password: '654321'
test:
login: 'demo'
password: 'password'
using activemerchant with ruby freckle
time tracking rethought

4 Enter the Ruby interactive console (irb). Type: 5 Set activemerchant to test mode:
require 'rubygems'
ActiveMerchant::Billing::Base.mode = :test
require 'active_merchant'

creating activemerchant objects


online resources
@creditcard =
ActiveMerchant::Billing::CreditCard.new({
:number => '4111111111111111',
:year => 2010,
:month => 1,
:verification_value => '123',
:type =>'visa',
:first_name => 'John',
:last_name => 'Doe' })

@gateway =
ActiveMerchant::Billing::Base.gateway('authorize_net')
.new(config_from_file('gateway.yml'))
using activemerchant with ruby freckle
time tracking rethought

6 Create a new gateway, new credit card, and create a test charge and then void it
(remember, you should be in dev mode!)

require 'rubygems'
require 'active_merchant'

ActiveMerchant::Billing::Base.mode = :test

@gateway =
ActiveMerchant::Billing::Base.gateway('authorize_net')
.new(config_from_file('gateway.yml'))

@creditcard =
ActiveMerchant::Billing::CreditCard.new({ Remembe
r, all
:number => '4111111111111111', "money" i
:year => 2010, s in cents
$1.00 = !
:month => 1, 100
:verification_value => '123',
:type =>'visa',
:first_name => 'John',
:last_name => 'Doe' })

response = @gateway.authorize(100, @credit_card)


response.success? || @gateway.void(response.authorization).success?
JavaScript card detection & validation freckle
time tracking rethought

Pre-process Card Data var Credit


CARDS: {
card = {

This script by Thomas Fuchs: Visa: /^4[


MasterCard
0-9]{12}(?
:[0-9]{3})
: /^5[1-5] ?$/,
DinersClub [0-9]{14}$
detects card types (Visa, etc.) Amex: /^3[
: /^3(?:0[0-
5]|[68][0-
/ ,
47][0-9]{1 9])[0-9]{1
Discover: 3}$/, 1}$/,
detects test card numbers },
/^6(?:011|
5[0-9]{2})
[0-9]{12}$
TEST_NUMBE /
validates card numbers using '305693090
R S : $w('378282
246310005
25904 3852 3714496353
Luhn10 checksums ' 6011000990
139424 555
0 0 0 0023237 60
1111111111
98431 3787
344..
'411111111 5 5 5555555444 1117 '+
1111111 40 4 51051051
has a handy strip() function to ), 1288888888
1881 42222
2 2 2
05105100 '
+
validate: 22222'
remove white space & dashes return Cre
f u nction(num
ber){
ditcard.ve
&& !!Credi r ifyLuhn10(
tcard.type number)
&& !Credit (number)
card.isTes
}, tNumber(nu
mber);
verifyLuhn
Download the full source var mul =
return ($A
10: functi
[1,2]; num
on(Requires
b
number){ Prototype
e r = $A(Cre
(number).i ditcard.st
return a + nject(0,fu rip(number
$A((parseI n c t ion(a,n,in )).rev..
This library was created during our development.injeof freckle
ct(0, func time nttracking.
( n ) * m u l[index%2]
dex){
}, tion(b,o){ ).toString
return b + ())
isTestNumb parseInt(o
er: functi ) }) })...
return Cre on(number)
ditcard.TE {
},.... ST_NUMBERS
.include(C
reditcard.
strip(...
Version 1
check for updates!

PART 3: Getting Your


Accounts

by amy hoy, thomas fuchs &


sponsored by freckle time tracking dieter komendera
accounts you'll need freckle
time tracking rethought

corporate bank account cc processing gateway


Your corporate bank account is where your Gateways serve three purposes:
money will go after credit card they offer address verification (AVS)
transactions have cleared. You'll
specifically want a corporate account; it will they pass on your CC
be difficult to sign up for a merchant processing requests to the
account without one. merchant bank service, acting
as your interface, and
merchant bank account
The merchant bank account is a confusing they will store your customer's
beast. It is a bank account, but not one you credit cards in a secure manner
can ever access directly. which you really don't want to
try and implement on your
The merchant bank account is where the own.
actual credit card transactions occur, and In some cases, you can get extra
the merchant services provider is the services from your processing gateway,
company that holds the agreements with such as eCheck processing (using the
the credit card companies themselves account numbers on the bottom of
(Visa, Mastercard, Amex, etc.) checks) and automated recurring
billing (e.g. monthly billing).
set up checklist freckle
time tracking rethought

in preparation merchants & gateways


incorporate. apply for a merchant account.
Forming an LLC is a good idea for any Merchant accounts vary little in terms of
business endeavor. We used & would features, so you'll be comparing mainly on
recommend HBS (delawareinc.com) to basis of price and service. Be sure to ask
incorporate in Delaware. If you cannot for a table of all fees, requirements for
form an LLC, file for a sole proprietorship acceptance, and which card types are
license from your state and/or county. included. Your local bank may be a simple
choice.
file for an Employer Identification
Number (EIN). You will need your letters of incorporation,
The EIN, or TIN (Tax ID Number), etc., is EIN/TIN proof, govt-issued photo ID, proof
essentially a Social Security Number for of address, and a bank letter or canceled
your new business. Some incorporation check.
services (like HBS) will do this for you.
apply for a credit card processor.
The big 2 available for small business are
apply for a corporate bank acct. TrustCommerce and Authorize.net.
It's easiest to do this in person at a local Compare based on the friendliness of their
branch: take your letters of incorporation, APIs & documentation, special features
your EIN/TIN proof, proof of address, and like recurring billing, schedule of fees,
govt-issued photo ID with you (passport is rates, and customer service.
best).
You'll need all of the same paperwork
you've been accumulating, plus your
merchant account information.
activemerchant peepcode PDF excellent
70 amazing pages, absolutely resources we use
packed with information on and recommend
activemerchant. We read it cover to
cover and it helped us tremendously,
in the way that API docs never can.

ick!
cl
And it's only $9!

Software as a Service (SaaS) Rails Kit I bought both the


The SaaS Rails Kit is a combination library, peepcode PDF & SaaS
application code & data model setup that helps you Rails Kit with my own
get a SaaS app off the ground in no time. money, and
ick! recommend them
cl It may sound expensive at $249, but we estimate that unreservedly.
it saved us at least 20-25 hours. At our billing rate,
In the interest of full
that's about $2,100 to $2,600. And it helped us
disclosure: I became a
launch freckle at least a week sooner. To say we're Rails Kit affiliate because
delighted with the savings... well, it's an I was so pleased with the
understatement. SaaS RK.

sponsored by freckle time tracking

Você também pode gostar