SlideShare a Scribd company logo
1 of 37
Download to read offline
Payments integration
Stripe & Taxamo
About me
Grzegorz Unijewski
Ruby on Rails Developer
grzegorz.unijewski@netguru.co
2/37
Agenda
3/37
● What is Stripe & Taxamo?
● Services integration based on my case
● Useful stuff
What is Stripe & Taxamo?
1.
4/37
Stripe
5/37
● Online payments platform
● Developer friendly documentation
● Paid per transaction
● Maintained Ruby client
● 1.4% + 20p for EU cards (2.9% for non-EU)
Stripe
6/37
Taxamo
7/37
● Global, real-time VAT & tax solution
● Paid monthly/annually
● €25/month or €19/month (up to €10k payments/month)
Taxamo
8/37
Case: subscriptions
2.
9/37
Subscriptions
10/37
● Purchase
● Annulment
● Renewal
Integration - preparing
11/37
# Gemfile
gem 'stripe'
# config/initializer/stripe.rb
Stripe.api_key = AppConfig.stripe.api_key # secret token
# Examples:
# list charges
Stripe::Charge.list()
# retrieve single charge
Stripe::Charge.retrieve(
"ch_123456789",
)
Integration - preparing
# Required data
:user # resource owner
:plan # subscription plan type
:tax_percent # tax rate
:stripe_token # stripe transaction key
:taxamo_token # taxamo transaction key
# Required column in User model
create_table "users", force: :cascade do |t|
[...]
t.string "stripe_cid"
end
12/37
Integration - preparing
13/37
URL:
https://api.taxamo.com/app/v1/webhooks/s
tripe?public_token=taxamo_public_key
Integration - preparing
14/37
For the payment form use Stripe.js or
ember-stripe-service.
Examples of good confirmation data:
● Credit card’s country & IP address
● Billing country & IP address
● Billing country & credit card’s country
Subscriptions
15/37
● Purchase
● Annulment
● Renewal
Subscription - purchase
16/37
# create_transaction
# delete_other_subscriptions if previous_subscriptions?
# grant_plan
Subscription - purchase
17/37
# create_transaction
## update_card if user.stripe_cid.present?
customer = Stripe::Customer.retrieve(user.stripe_cid)
customer.source = options[:stripe_token]
customer.save
## confirm_transaction
HTTParty.post(
"https://api.taxamo.com/api/v1/transactions/#{options[:taxamo_token]}/confirm",
{ query: { private_token: AppConfig.taxamo.private_token }
)
Subscription - purchase
18/37
# create_transaction
...
## create_subscription
Stripe::Subscription.create(
customer: user.stripe_cid,
plan: plan,
metadata: {
taxamo_transaction_key: options[:taxamo_token]
},
tax_percent: options[:tax_percent]
)
### if we don't have customer ID
customer_id = Stripe::Customer.create(source: options[:stripe_token], email: user.email).id
user.update(stripe_cid: customer_id)
Subscription - purchase
19/37
# create_transaction
# delete_other_subscriptions if previous_subscriptions?
# grant_plan
Subscription - purchase
20/37
# delete_other_subscriptions if previous_subscriptions?
subscriptions = Stripe::Customer.retrieve(user.stripe_cid).subscriptions
subscriptions.to_a.drop(1).present?
other_subscriptions_ids.map do |sub_id|
Stripe::Subscription.retrieve(sub_id).delete
end
# grant_plan
account_plan = { plan: plan, currency: currency }
SubscriptionServices::SubscriptionGrantor.new(user: user, new_plan: account_plan).call
Subscriptions
21/37
● Purchase
● Annulment
● Renewal
Subscription - annulment
22/37
def cancel_subscription
stripe_subscription = Stripe::Subscription.retrieve(subscription_id)
stripe_subscription.delete(at_period_end: true)
user.active_subscription.update(is_cancelled: true)
end
def subscription_id
customer = Stripe::Customer.retrieve(user.stripe_cid)
customer.subscriptions.first.id
end
Subscriptions
23/37
● Purchase
● Annulment
● Renewal
Subscription - renewal
24/37
● Add a new webhook with URL:
https://myapp.com/api/v1/subscriptions/events?access_token=your_token
for customer.subscription.updated event
● Handle it in the endpoint
● Don’t forget about authorization
Subscription - renewal
25/37
def call
user.subscriptions.last.update(end_date: end_date)
end
private
def json_object
@json_object ||= event_json['data']['object']
end
def user
customer_id = json_object['customer']
User.find_by!(stripe_cid: customer_id)
end
def end_date
date = json_object['current_period_end']
Time.at(date)
end
Useful stuff
3.
26/37
stripe_event
27/37
gem 'stripe_event'
# config/routes.rb
mount StripeEvent::Engine, at: '/my-chosen-path' # provide a custom path
# config/initializers/stripe.rb
Stripe.api_key = ENV['STRIPE_SECRET_KEY'] # e.g. sk_live_1234
StripeEvent.configure do |events|
events.subscribe 'charge.failed' do |event|
# Define subscriber behavior based on the event object
event.class #=> Stripe::Event
event.type #=> "charge.failed"
event.data.object #=> #<Stripe::Charge:0x3fcb34c115f8>
end
events.all do |event|
events.all BillingEventLogger.new(Rails.logger)
events.subscribe 'customer.created', CustomerCreated.new
end
end
stripe-ruby-mock
28/37
gem 'stripe-ruby-mock', '~> 2.3.1', require: 'stripe_mock'
require 'stripe_mock'
describe MyApp do
let(:stripe_helper) { StripeMock.create_test_helper }
before { StripeMock.start }
after { StripeMock.stop }
it "creates a stripe customer" do
# This doesn't touch stripe's servers nor the internet!
# Specify :source in place of :card (with same value) to return customer with source data
customer = Stripe::Customer.create({
email: 'johnny@appleseed.com',
card: stripe_helper.generate_card_token
})
expect(customer.email).to eq('johnny@appleseed.com')
end
end
stripe-ruby-mock
29/37
stripe_helper.create_plan(my_plan_params)
stripe_helper.delete_plan(my_plan_params)
stripe_helper.generate_card_token(my_card_params)
let(:customer) do
Stripe::Util.convert_to_stripe_object(
{
object: 'customer',
source: 'source',
subscriptions: subscriptions_array
}, {}
)
end
let(:stripe_subscription) do
Stripe::Util.convert_to_stripe_object({ object: 'subscription', id: '1' }, {})
end
Links
30/37
● Stripe API reference: https://stripe.com/docs/api/ruby
● Taxamo API reference: https://www.taxamo.com/apidocs/
● Stripe-ruby: https://github.com/stripe/stripe-ruby
● Stripe-ruby-mock: https://github.com/rebelidealist/stripe-ruby-mock
● Stripe_event: https://github.com/integrallis/stripe_event
● Taxamo-ruby: https://github.com/taxamo/taxamo-ruby
● Stripe JS reference: https://stripe.com/docs/stripe.js
● Ember-stripe-service: https://github.com/code-corps/ember-stripe-service
Q&A
31/37
Ruby on Rails Development Team
32/37
● ~ 80 developers including
○ ~ 20 seniors
○ ~ 10 team leaders
Ruby on Rails Developer must-haves:
33/37
● Have a hands-on knowledge of Ruby on Rails, HAML/SASS
● Have knowledge of at least one of JavaScript frameworks
(AngularJS/Ember.js, React, jQuery)
● You know how to deal efficiently with databases and various queries
● You have very good command of written and spoken English (minimum
B2)
● You have experience in direct communication with clients
Juniors are more than welcome! You just need to:
34/37
● Have some basic knowledge in Ruby and Ruby on Rails
● Have at least one Rails app on your GitHub account
● Be fluent in English - at least B2 level, spoken and written
● Be ready to work at least 35 hours/week, from Monday till
Friday
How to join our awesome team?
35/37
● Step one - check our career path and see what level you are
netguru.co/career/paths
● Step two - apply for the proper position - netguru.co/career
● Step three - take part in our recruitment process - solve the
task and join us for the remote interview and pair programming
● Step four - welcome onboard!
36/37
Any questions regarding recruitment process?
Drop us a line at jobs@netguru.co
Don’t hesitate and join our team!
Thanks!
37/37

More Related Content

What's hot

How to test payment gateway functionality
How to test payment gateway functionalityHow to test payment gateway functionality
How to test payment gateway functionalityTrupti Jethva
 
Startup Highway Workshop
Startup Highway WorkshopStartup Highway Workshop
Startup Highway WorkshopPayPal
 
Payment gateway
Payment gatewayPayment gateway
Payment gatewayPiyush Dua
 
CCAvenue Features Presentation
CCAvenue Features PresentationCCAvenue Features Presentation
CCAvenue Features PresentationPramod Ganji
 
Integration of payment gateways using Paypal account
Integration of payment gateways using Paypal account Integration of payment gateways using Paypal account
Integration of payment gateways using Paypal account Phenom People
 
eCommerce Payment Gateways: An Introduction
eCommerce Payment Gateways: An IntroductioneCommerce Payment Gateways: An Introduction
eCommerce Payment Gateways: An IntroductionAidanChard
 
Payment gateway
Payment gatewayPayment gateway
Payment gatewayHananBahy
 
Safex pay wl-pg-presentation
Safex pay wl-pg-presentationSafex pay wl-pg-presentation
Safex pay wl-pg-presentationNeha Sahay
 
Introducing safex pay 2018
Introducing safex pay 2018Introducing safex pay 2018
Introducing safex pay 2018Neha Sahay
 
Safex pay avantgarde -presentation
Safex pay avantgarde -presentationSafex pay avantgarde -presentation
Safex pay avantgarde -presentationNeha Sahay
 
Authorized payment gateway
Authorized payment gatewayAuthorized payment gateway
Authorized payment gatewayspencerwebb
 
Payment Gateways in Kuwait - 2014 Update
Payment Gateways in Kuwait - 2014 UpdatePayment Gateways in Kuwait - 2014 Update
Payment Gateways in Kuwait - 2014 UpdateBurhan Khalid
 
Safex pay avantgarde -presentation
Safex pay avantgarde -presentationSafex pay avantgarde -presentation
Safex pay avantgarde -presentationNeha Sahay
 
Payment Services in Kuwait
Payment Services in KuwaitPayment Services in Kuwait
Payment Services in KuwaitBurhan Khalid
 
Payment Gateway History: An interview with the Inventor
Payment Gateway History: An interview with the InventorPayment Gateway History: An interview with the Inventor
Payment Gateway History: An interview with the InventorWayne Akey
 

What's hot (20)

How to test payment gateway functionality
How to test payment gateway functionalityHow to test payment gateway functionality
How to test payment gateway functionality
 
Startup Highway Workshop
Startup Highway WorkshopStartup Highway Workshop
Startup Highway Workshop
 
Payment gateway
Payment gatewayPayment gateway
Payment gateway
 
CCAvenue Features Presentation
CCAvenue Features PresentationCCAvenue Features Presentation
CCAvenue Features Presentation
 
Integration of payment gateways using Paypal account
Integration of payment gateways using Paypal account Integration of payment gateways using Paypal account
Integration of payment gateways using Paypal account
 
Payment gateways
Payment gateways Payment gateways
Payment gateways
 
Pinch Product Dev
Pinch Product DevPinch Product Dev
Pinch Product Dev
 
Stripe SCA
Stripe SCAStripe SCA
Stripe SCA
 
eCommerce Payment Gateways: An Introduction
eCommerce Payment Gateways: An IntroductioneCommerce Payment Gateways: An Introduction
eCommerce Payment Gateways: An Introduction
 
Payment gateway
Payment gatewayPayment gateway
Payment gateway
 
SMA Online
SMA OnlineSMA Online
SMA Online
 
Safex pay wl-pg-presentation
Safex pay wl-pg-presentationSafex pay wl-pg-presentation
Safex pay wl-pg-presentation
 
Introducing safex pay 2018
Introducing safex pay 2018Introducing safex pay 2018
Introducing safex pay 2018
 
Safex pay avantgarde -presentation
Safex pay avantgarde -presentationSafex pay avantgarde -presentation
Safex pay avantgarde -presentation
 
Authorized payment gateway
Authorized payment gatewayAuthorized payment gateway
Authorized payment gateway
 
Payment Gateways in Kuwait - 2014 Update
Payment Gateways in Kuwait - 2014 UpdatePayment Gateways in Kuwait - 2014 Update
Payment Gateways in Kuwait - 2014 Update
 
Payments whatsapp link
Payments whatsapp linkPayments whatsapp link
Payments whatsapp link
 
Safex pay avantgarde -presentation
Safex pay avantgarde -presentationSafex pay avantgarde -presentation
Safex pay avantgarde -presentation
 
Payment Services in Kuwait
Payment Services in KuwaitPayment Services in Kuwait
Payment Services in Kuwait
 
Payment Gateway History: An interview with the Inventor
Payment Gateway History: An interview with the InventorPayment Gateway History: An interview with the Inventor
Payment Gateway History: An interview with the Inventor
 

Viewers also liked

Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, NetguruRozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, NetguruBiznes 2.0
 
Strategia w Social Media w 6 krokach
Strategia w Social Media w 6 krokachStrategia w Social Media w 6 krokach
Strategia w Social Media w 6 krokachFilip Cieslak
 
Why Would A Programmer Fall In Love With SPA?
Why Would A Programmer Fall In Love With SPA?Why Would A Programmer Fall In Love With SPA?
Why Would A Programmer Fall In Love With SPA?Netguru
 
KISS Augmented Reality
KISS Augmented RealityKISS Augmented Reality
KISS Augmented RealityNetguru
 
Czy Project Manger Musi Być Osobą Techniczną?
Czy Project Manger Musi Być Osobą Techniczną?Czy Project Manger Musi Być Osobą Techniczną?
Czy Project Manger Musi Być Osobą Techniczną?Netguru
 
Blogi w firmie
Blogi w firmieBlogi w firmie
Blogi w firmieNetguru
 
Hidden Gems in Swift
Hidden Gems in SwiftHidden Gems in Swift
Hidden Gems in SwiftNetguru
 

Viewers also liked (8)

Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, NetguruRozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
Rozwijanie firmy web developerskiej - Kuba Filipowski, Wiktor Schmidt, Netguru
 
301 Adam Zygadlewicz
301 Adam Zygadlewicz301 Adam Zygadlewicz
301 Adam Zygadlewicz
 
Strategia w Social Media w 6 krokach
Strategia w Social Media w 6 krokachStrategia w Social Media w 6 krokach
Strategia w Social Media w 6 krokach
 
Why Would A Programmer Fall In Love With SPA?
Why Would A Programmer Fall In Love With SPA?Why Would A Programmer Fall In Love With SPA?
Why Would A Programmer Fall In Love With SPA?
 
KISS Augmented Reality
KISS Augmented RealityKISS Augmented Reality
KISS Augmented Reality
 
Czy Project Manger Musi Być Osobą Techniczną?
Czy Project Manger Musi Być Osobą Techniczną?Czy Project Manger Musi Być Osobą Techniczną?
Czy Project Manger Musi Być Osobą Techniczną?
 
Blogi w firmie
Blogi w firmieBlogi w firmie
Blogi w firmie
 
Hidden Gems in Swift
Hidden Gems in SwiftHidden Gems in Swift
Hidden Gems in Swift
 

Similar to Payments integration: Stripe & Taxamo

Moore Advanced Calculations in Calc Manager OW 20151015
Moore Advanced Calculations in Calc Manager  OW 20151015Moore Advanced Calculations in Calc Manager  OW 20151015
Moore Advanced Calculations in Calc Manager OW 20151015Ron Moore
 
Using Graphs for Feature Engineering_ Graph Reduce-2.pdf
Using Graphs for Feature Engineering_ Graph Reduce-2.pdfUsing Graphs for Feature Engineering_ Graph Reduce-2.pdf
Using Graphs for Feature Engineering_ Graph Reduce-2.pdfWes Madrigal
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDDKonstantin Kudryashov
 
Streamlining Feature Engineering Pipelines with Open Source
Streamlining Feature Engineering Pipelines with Open SourceStreamlining Feature Engineering Pipelines with Open Source
Streamlining Feature Engineering Pipelines with Open SourceSoledad Galli
 
DRUPAL AUDITS MADE FASTR
DRUPAL AUDITS MADE FASTRDRUPAL AUDITS MADE FASTR
DRUPAL AUDITS MADE FASTRDrupalCamp Kyiv
 
A Technical Introduction to RTBkit
A Technical Introduction to RTBkitA Technical Introduction to RTBkit
A Technical Introduction to RTBkitDatacratic
 
Behavior-driven Development and Lambdaj
Behavior-driven Development and LambdajBehavior-driven Development and Lambdaj
Behavior-driven Development and LambdajAndreas Enbohm
 
From class to architecture
From class to architectureFrom class to architecture
From class to architectureMarcin Hawraniak
 
Towards cross-platfrom application development
Towards cross-platfrom application developmentTowards cross-platfrom application development
Towards cross-platfrom application developmentESUG
 
BPCS Infor ERP LX Implementation Evaluation Q4 2007
BPCS Infor ERP LX Implementation Evaluation Q4 2007BPCS Infor ERP LX Implementation Evaluation Q4 2007
BPCS Infor ERP LX Implementation Evaluation Q4 2007Dedy Sofyan
 
On component interface
On component interfaceOn component interface
On component interfaceLaurence Chen
 
Biconomy - ETHglobal workshop
Biconomy - ETHglobal workshopBiconomy - ETHglobal workshop
Biconomy - ETHglobal workshopAditya Khanduri
 
Presentation 2315006 done
Presentation 2315006 donePresentation 2315006 done
Presentation 2315006 donedeepaktile
 
Industrail training report on website design and development
Industrail training report on website design and developmentIndustrail training report on website design and development
Industrail training report on website design and developmentMUSICbegins
 
Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Geoffrey De Smet
 
Agados Function & Feature
Agados Function & FeatureAgados Function & Feature
Agados Function & FeatureYongkyoo Park
 
Turbogears2 tutorial to create mvc app
Turbogears2 tutorial to create mvc appTurbogears2 tutorial to create mvc app
Turbogears2 tutorial to create mvc appfRui Apps
 
DrupalCommerce Lisbon presentation
DrupalCommerce Lisbon presentationDrupalCommerce Lisbon presentation
DrupalCommerce Lisbon presentationPedro Cambra
 

Similar to Payments integration: Stripe & Taxamo (20)

Moore Advanced Calculations in Calc Manager OW 20151015
Moore Advanced Calculations in Calc Manager  OW 20151015Moore Advanced Calculations in Calc Manager  OW 20151015
Moore Advanced Calculations in Calc Manager OW 20151015
 
Using Graphs for Feature Engineering_ Graph Reduce-2.pdf
Using Graphs for Feature Engineering_ Graph Reduce-2.pdfUsing Graphs for Feature Engineering_ Graph Reduce-2.pdf
Using Graphs for Feature Engineering_ Graph Reduce-2.pdf
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDD
 
Streamlining Feature Engineering Pipelines with Open Source
Streamlining Feature Engineering Pipelines with Open SourceStreamlining Feature Engineering Pipelines with Open Source
Streamlining Feature Engineering Pipelines with Open Source
 
DRUPAL AUDITS MADE FASTR
DRUPAL AUDITS MADE FASTRDRUPAL AUDITS MADE FASTR
DRUPAL AUDITS MADE FASTR
 
A Technical Introduction to RTBkit
A Technical Introduction to RTBkitA Technical Introduction to RTBkit
A Technical Introduction to RTBkit
 
Behavior-driven Development and Lambdaj
Behavior-driven Development and LambdajBehavior-driven Development and Lambdaj
Behavior-driven Development and Lambdaj
 
From class to architecture
From class to architectureFrom class to architecture
From class to architecture
 
Towards cross-platfrom application development
Towards cross-platfrom application developmentTowards cross-platfrom application development
Towards cross-platfrom application development
 
BPCS Infor ERP LX Implementation Evaluation Q4 2007
BPCS Infor ERP LX Implementation Evaluation Q4 2007BPCS Infor ERP LX Implementation Evaluation Q4 2007
BPCS Infor ERP LX Implementation Evaluation Q4 2007
 
On component interface
On component interfaceOn component interface
On component interface
 
Biconomy - ETHglobal workshop
Biconomy - ETHglobal workshopBiconomy - ETHglobal workshop
Biconomy - ETHglobal workshop
 
Presentation 2315006 done
Presentation 2315006 donePresentation 2315006 done
Presentation 2315006 done
 
Graphdo overview
Graphdo overviewGraphdo overview
Graphdo overview
 
eBPF/XDP
eBPF/XDP eBPF/XDP
eBPF/XDP
 
Industrail training report on website design and development
Industrail training report on website design and developmentIndustrail training report on website design and development
Industrail training report on website design and development
 
Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)
 
Agados Function & Feature
Agados Function & FeatureAgados Function & Feature
Agados Function & Feature
 
Turbogears2 tutorial to create mvc app
Turbogears2 tutorial to create mvc appTurbogears2 tutorial to create mvc app
Turbogears2 tutorial to create mvc app
 
DrupalCommerce Lisbon presentation
DrupalCommerce Lisbon presentationDrupalCommerce Lisbon presentation
DrupalCommerce Lisbon presentation
 

More from Netguru

Defining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using RubyDefining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using RubyNetguru
 
How To Build Great Relationships With Your Clients
How To Build Great Relationships With Your ClientsHow To Build Great Relationships With Your Clients
How To Build Great Relationships With Your ClientsNetguru
 
Agile Retrospectives
Agile RetrospectivesAgile Retrospectives
Agile RetrospectivesNetguru
 
Ruby Rails Overview
Ruby Rails OverviewRuby Rails Overview
Ruby Rails OverviewNetguru
 
From Birds To Bugs: Testowanie Z Pasją
From Birds To Bugs: Testowanie Z PasjąFrom Birds To Bugs: Testowanie Z Pasją
From Birds To Bugs: Testowanie Z PasjąNetguru
 
Communication With Clients Throughout The Project
Communication With Clients Throughout The ProjectCommunication With Clients Throughout The Project
Communication With Clients Throughout The ProjectNetguru
 
Everyday Rails
Everyday RailsEveryday Rails
Everyday RailsNetguru
 
Estimation myths debunked
Estimation myths debunkedEstimation myths debunked
Estimation myths debunkedNetguru
 
Programming Paradigms Which One Is The Best?
Programming Paradigms Which One Is The Best?Programming Paradigms Which One Is The Best?
Programming Paradigms Which One Is The Best?Netguru
 
Z 50 do 100 w ciągu roku Jak rekrutować w IT?
Z 50 do 100 w ciągu roku Jak rekrutować w IT?Z 50 do 100 w ciągu roku Jak rekrutować w IT?
Z 50 do 100 w ciągu roku Jak rekrutować w IT?Netguru
 
Paradygmaty Programowania: Czy Istnieje Najlepszy?
Paradygmaty Programowania: Czy Istnieje Najlepszy?Paradygmaty Programowania: Czy Istnieje Najlepszy?
Paradygmaty Programowania: Czy Istnieje Najlepszy?Netguru
 
CSS architecture: How To Write Clean & Scalable Code
CSS architecture: How To Write Clean & Scalable CodeCSS architecture: How To Write Clean & Scalable Code
CSS architecture: How To Write Clean & Scalable CodeNetguru
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails IntroNetguru
 
Perfect Project Read Me (in a few steps)
Perfect Project Read Me (in a few steps)Perfect Project Read Me (in a few steps)
Perfect Project Read Me (in a few steps)Netguru
 
The Git Basics
The Git BasicsThe Git Basics
The Git BasicsNetguru
 
From nil to guru: intro to Ruby on Rails
From nil to guru: intro to Ruby on RailsFrom nil to guru: intro to Ruby on Rails
From nil to guru: intro to Ruby on RailsNetguru
 
Working With Teams Across The Borders
Working With Teams Across The BordersWorking With Teams Across The Borders
Working With Teams Across The BordersNetguru
 
Front-End Dev Tools
Front-End Dev ToolsFront-End Dev Tools
Front-End Dev ToolsNetguru
 
OOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsOOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsNetguru
 
Coffeescript presentation DublinJS
Coffeescript presentation DublinJSCoffeescript presentation DublinJS
Coffeescript presentation DublinJSNetguru
 

More from Netguru (20)

Defining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using RubyDefining DSL (Domain Specific Language) using Ruby
Defining DSL (Domain Specific Language) using Ruby
 
How To Build Great Relationships With Your Clients
How To Build Great Relationships With Your ClientsHow To Build Great Relationships With Your Clients
How To Build Great Relationships With Your Clients
 
Agile Retrospectives
Agile RetrospectivesAgile Retrospectives
Agile Retrospectives
 
Ruby Rails Overview
Ruby Rails OverviewRuby Rails Overview
Ruby Rails Overview
 
From Birds To Bugs: Testowanie Z Pasją
From Birds To Bugs: Testowanie Z PasjąFrom Birds To Bugs: Testowanie Z Pasją
From Birds To Bugs: Testowanie Z Pasją
 
Communication With Clients Throughout The Project
Communication With Clients Throughout The ProjectCommunication With Clients Throughout The Project
Communication With Clients Throughout The Project
 
Everyday Rails
Everyday RailsEveryday Rails
Everyday Rails
 
Estimation myths debunked
Estimation myths debunkedEstimation myths debunked
Estimation myths debunked
 
Programming Paradigms Which One Is The Best?
Programming Paradigms Which One Is The Best?Programming Paradigms Which One Is The Best?
Programming Paradigms Which One Is The Best?
 
Z 50 do 100 w ciągu roku Jak rekrutować w IT?
Z 50 do 100 w ciągu roku Jak rekrutować w IT?Z 50 do 100 w ciągu roku Jak rekrutować w IT?
Z 50 do 100 w ciągu roku Jak rekrutować w IT?
 
Paradygmaty Programowania: Czy Istnieje Najlepszy?
Paradygmaty Programowania: Czy Istnieje Najlepszy?Paradygmaty Programowania: Czy Istnieje Najlepszy?
Paradygmaty Programowania: Czy Istnieje Najlepszy?
 
CSS architecture: How To Write Clean & Scalable Code
CSS architecture: How To Write Clean & Scalable CodeCSS architecture: How To Write Clean & Scalable Code
CSS architecture: How To Write Clean & Scalable Code
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails Intro
 
Perfect Project Read Me (in a few steps)
Perfect Project Read Me (in a few steps)Perfect Project Read Me (in a few steps)
Perfect Project Read Me (in a few steps)
 
The Git Basics
The Git BasicsThe Git Basics
The Git Basics
 
From nil to guru: intro to Ruby on Rails
From nil to guru: intro to Ruby on RailsFrom nil to guru: intro to Ruby on Rails
From nil to guru: intro to Ruby on Rails
 
Working With Teams Across The Borders
Working With Teams Across The BordersWorking With Teams Across The Borders
Working With Teams Across The Borders
 
Front-End Dev Tools
Front-End Dev ToolsFront-End Dev Tools
Front-End Dev Tools
 
OOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsOOScss Architecture For Rails Apps
OOScss Architecture For Rails Apps
 
Coffeescript presentation DublinJS
Coffeescript presentation DublinJSCoffeescript presentation DublinJS
Coffeescript presentation DublinJS
 

Recently uploaded

Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Recently uploaded (20)

Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

Payments integration: Stripe & Taxamo

  • 2. About me Grzegorz Unijewski Ruby on Rails Developer grzegorz.unijewski@netguru.co 2/37
  • 3. Agenda 3/37 ● What is Stripe & Taxamo? ● Services integration based on my case ● Useful stuff
  • 4. What is Stripe & Taxamo? 1. 4/37
  • 5. Stripe 5/37 ● Online payments platform ● Developer friendly documentation ● Paid per transaction ● Maintained Ruby client ● 1.4% + 20p for EU cards (2.9% for non-EU)
  • 7. Taxamo 7/37 ● Global, real-time VAT & tax solution ● Paid monthly/annually ● €25/month or €19/month (up to €10k payments/month)
  • 11. Integration - preparing 11/37 # Gemfile gem 'stripe' # config/initializer/stripe.rb Stripe.api_key = AppConfig.stripe.api_key # secret token # Examples: # list charges Stripe::Charge.list() # retrieve single charge Stripe::Charge.retrieve( "ch_123456789", )
  • 12. Integration - preparing # Required data :user # resource owner :plan # subscription plan type :tax_percent # tax rate :stripe_token # stripe transaction key :taxamo_token # taxamo transaction key # Required column in User model create_table "users", force: :cascade do |t| [...] t.string "stripe_cid" end 12/37
  • 14. Integration - preparing 14/37 For the payment form use Stripe.js or ember-stripe-service. Examples of good confirmation data: ● Credit card’s country & IP address ● Billing country & IP address ● Billing country & credit card’s country
  • 16. Subscription - purchase 16/37 # create_transaction # delete_other_subscriptions if previous_subscriptions? # grant_plan
  • 17. Subscription - purchase 17/37 # create_transaction ## update_card if user.stripe_cid.present? customer = Stripe::Customer.retrieve(user.stripe_cid) customer.source = options[:stripe_token] customer.save ## confirm_transaction HTTParty.post( "https://api.taxamo.com/api/v1/transactions/#{options[:taxamo_token]}/confirm", { query: { private_token: AppConfig.taxamo.private_token } )
  • 18. Subscription - purchase 18/37 # create_transaction ... ## create_subscription Stripe::Subscription.create( customer: user.stripe_cid, plan: plan, metadata: { taxamo_transaction_key: options[:taxamo_token] }, tax_percent: options[:tax_percent] ) ### if we don't have customer ID customer_id = Stripe::Customer.create(source: options[:stripe_token], email: user.email).id user.update(stripe_cid: customer_id)
  • 19. Subscription - purchase 19/37 # create_transaction # delete_other_subscriptions if previous_subscriptions? # grant_plan
  • 20. Subscription - purchase 20/37 # delete_other_subscriptions if previous_subscriptions? subscriptions = Stripe::Customer.retrieve(user.stripe_cid).subscriptions subscriptions.to_a.drop(1).present? other_subscriptions_ids.map do |sub_id| Stripe::Subscription.retrieve(sub_id).delete end # grant_plan account_plan = { plan: plan, currency: currency } SubscriptionServices::SubscriptionGrantor.new(user: user, new_plan: account_plan).call
  • 22. Subscription - annulment 22/37 def cancel_subscription stripe_subscription = Stripe::Subscription.retrieve(subscription_id) stripe_subscription.delete(at_period_end: true) user.active_subscription.update(is_cancelled: true) end def subscription_id customer = Stripe::Customer.retrieve(user.stripe_cid) customer.subscriptions.first.id end
  • 24. Subscription - renewal 24/37 ● Add a new webhook with URL: https://myapp.com/api/v1/subscriptions/events?access_token=your_token for customer.subscription.updated event ● Handle it in the endpoint ● Don’t forget about authorization
  • 25. Subscription - renewal 25/37 def call user.subscriptions.last.update(end_date: end_date) end private def json_object @json_object ||= event_json['data']['object'] end def user customer_id = json_object['customer'] User.find_by!(stripe_cid: customer_id) end def end_date date = json_object['current_period_end'] Time.at(date) end
  • 27. stripe_event 27/37 gem 'stripe_event' # config/routes.rb mount StripeEvent::Engine, at: '/my-chosen-path' # provide a custom path # config/initializers/stripe.rb Stripe.api_key = ENV['STRIPE_SECRET_KEY'] # e.g. sk_live_1234 StripeEvent.configure do |events| events.subscribe 'charge.failed' do |event| # Define subscriber behavior based on the event object event.class #=> Stripe::Event event.type #=> "charge.failed" event.data.object #=> #<Stripe::Charge:0x3fcb34c115f8> end events.all do |event| events.all BillingEventLogger.new(Rails.logger) events.subscribe 'customer.created', CustomerCreated.new end end
  • 28. stripe-ruby-mock 28/37 gem 'stripe-ruby-mock', '~> 2.3.1', require: 'stripe_mock' require 'stripe_mock' describe MyApp do let(:stripe_helper) { StripeMock.create_test_helper } before { StripeMock.start } after { StripeMock.stop } it "creates a stripe customer" do # This doesn't touch stripe's servers nor the internet! # Specify :source in place of :card (with same value) to return customer with source data customer = Stripe::Customer.create({ email: 'johnny@appleseed.com', card: stripe_helper.generate_card_token }) expect(customer.email).to eq('johnny@appleseed.com') end end
  • 29. stripe-ruby-mock 29/37 stripe_helper.create_plan(my_plan_params) stripe_helper.delete_plan(my_plan_params) stripe_helper.generate_card_token(my_card_params) let(:customer) do Stripe::Util.convert_to_stripe_object( { object: 'customer', source: 'source', subscriptions: subscriptions_array }, {} ) end let(:stripe_subscription) do Stripe::Util.convert_to_stripe_object({ object: 'subscription', id: '1' }, {}) end
  • 30. Links 30/37 ● Stripe API reference: https://stripe.com/docs/api/ruby ● Taxamo API reference: https://www.taxamo.com/apidocs/ ● Stripe-ruby: https://github.com/stripe/stripe-ruby ● Stripe-ruby-mock: https://github.com/rebelidealist/stripe-ruby-mock ● Stripe_event: https://github.com/integrallis/stripe_event ● Taxamo-ruby: https://github.com/taxamo/taxamo-ruby ● Stripe JS reference: https://stripe.com/docs/stripe.js ● Ember-stripe-service: https://github.com/code-corps/ember-stripe-service
  • 32. Ruby on Rails Development Team 32/37 ● ~ 80 developers including ○ ~ 20 seniors ○ ~ 10 team leaders
  • 33. Ruby on Rails Developer must-haves: 33/37 ● Have a hands-on knowledge of Ruby on Rails, HAML/SASS ● Have knowledge of at least one of JavaScript frameworks (AngularJS/Ember.js, React, jQuery) ● You know how to deal efficiently with databases and various queries ● You have very good command of written and spoken English (minimum B2) ● You have experience in direct communication with clients
  • 34. Juniors are more than welcome! You just need to: 34/37 ● Have some basic knowledge in Ruby and Ruby on Rails ● Have at least one Rails app on your GitHub account ● Be fluent in English - at least B2 level, spoken and written ● Be ready to work at least 35 hours/week, from Monday till Friday
  • 35. How to join our awesome team? 35/37 ● Step one - check our career path and see what level you are netguru.co/career/paths ● Step two - apply for the proper position - netguru.co/career ● Step three - take part in our recruitment process - solve the task and join us for the remote interview and pair programming ● Step four - welcome onboard!
  • 36. 36/37 Any questions regarding recruitment process? Drop us a line at jobs@netguru.co Don’t hesitate and join our team!