SlideShare a Scribd company logo
Payment Request API
with a React high order component
@marcolanaro86marcolanaro
Question 1
How many people actually enjoy the process of buying
something on the web using their mobile device?
Question 2
How many people can remember all the details from their
credit card without having to take it out?
Question 3
How many people like giving their raw credit card numbers
over to random websites?
Web Desktop vs Mobile
Traffic
Conversion
60%
5%
40%
15%
MobileDesktop
Mobile Native vs Web
Step conversion
results -> checkout
Total Conversion
Native Web
10% 5%
Step conversion
checkout -> confirmation 30%
30% 30%
15%
Why?
Autocomplete fields
less friction
30% faster
each app needs data entry
each app need validation process
multiple payment methods
Autofill
Cannot guess 100% reliability card type from number
Card number formatting while typing
Card number validation
Custom Forms
Scan your card details from the camera without need of typing
Credit/Debit card
…billing/shipping address, contact info
Payment Request API
Eliminate checkout forms
It is not
Integrator with payment processor
Supported by Safari (but we have ApplePay)
A new payment method
A finalised standard
It is
Open
Cross browser
Chrome, Chrome for Android, Edge, Opera
Standard
One click payment
Native
Despite WIP, >28% support
Process
Playground
React
Everything is a component
Declarative code
Not obvious how to
encapsulate logic in a
component
Functor
Given categories C and D
a functor F:C→D
is a map that sends
each object x in C to an object F(x) in D
&
each morphism f:x→y in C to a
morphism F(f):F(x)→F(y) in D
such that each commuting diagram in C
maps to a commuting diagram in D
1
2
1
2
const paymentRequest = () => (WrappedComponent) => (
class ExtendedComponent extends React.Component {
render() {
const { config, ...rest } = this.props;
if (!isSupported() || !config) {
return WrappedComponent({ ...rest, isSupported: false });
}
return WrappedComponent({ ...rest, isSupported: true, show:
show(config), abort });
}
}
);
Pseudo code
Why?
Powerful behaviour encapsulated in the high order component
Declarative API
Composable
Very simple to use
Create the component
import * as React from 'react';
import paymentRequest from 'react-payment-request-api';
const Button = ({ show, isSupported, style }) => isSupported
? <button onClick={show} style={style}>Pay now!</button>
: <span>Payment request not supported</span>;
export default paymentRequest()(Button);
Use the component
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import Button from './button';
import getConfig from './config';
import styles from './styles';
const App = () =>
<Button config={getConfig()} style={styles.button} />;
ReactDOM.render(<App />, document.getElementById('app'));
const getConfig = () => ({
methodData: [{
supportedMethods: ['basic-card'],
data: {
supportedNetworks: ['visa', 'mastercard', 'diners'],
},
}],
details: details,
onShowSuccess: (result, resolve, reject): void => {
console.log('Result:', result);
// make the payment
setTimeout(resolve, 2000);
},
onShowFail: (error) => console.log('Error', error),
onShippingAddressChange: (request, resolve, reject): void => {
console.log('ShippingAddress:', request.shippingAddress);
// recalculate details
resolve(details);
},
onShippingOptionChange: (request, resolve, reject): void => {
resolve(details);
},
});
Configuration
const getConfig = () => ({
methodData: [{
supportedMethods: ['basic-card'],
data: {
supportedNetworks: ['visa', 'mastercard', 'diners'],
},
}],
details: details,
onShowSuccess: (result, resolve, reject): void => {
console.log('Result:', result);
// make the payment
setTimeout(resolve, 2000);
},
onShowFail: (error) => console.log('Error', error),
onShippingAddressChange: (request, resolve, reject): void => {
console.log('ShippingAddress:', request.shippingAddress);
// recalculate details
resolve(details);
},
onShippingOptionChange: (request, resolve, reject): void => {
resolve(details);
},
});
Configuration
Demo
https://lanaro.net/react-payment-request-api/
Open source
Repository:
https://github.com/marcolanaro/react-payment-request-api
Standard:
https://www.w3.org/TR/payment-request/

More Related Content

What's hot

Express checkout recurring payments
Express checkout recurring paymentsExpress checkout recurring payments
Express checkout recurring payments
rpawluszek
 
QuayPay - Summary
QuayPay - SummaryQuayPay - Summary
QuayPay - Summary
Carlos Piteira
 
How to implement payment gateway integration for non-credit card on Magento2
How to implement payment gateway integration for non-credit card on Magento2How to implement payment gateway integration for non-credit card on Magento2
How to implement payment gateway integration for non-credit card on Magento2
Hirokazu Nishi
 
Payment integration patterns в Magento2
Payment integration patterns в Magento2Payment integration patterns в Magento2
Payment integration patterns в Magento2
Elogic Magento Development
 
Cool New Advances in PayPal Express Checkout
Cool New Advances in PayPal Express CheckoutCool New Advances in PayPal Express Checkout
Cool New Advances in PayPal Express Checkout
PayPalX Developer Network
 
Pay Book Guide User En
Pay Book Guide User EnPay Book Guide User En
Pay Book Guide User En
Yann GEFFROTIN
 
Point of Sale Paytm All in One Payment
Point of Sale Paytm All in One PaymentPoint of Sale Paytm All in One Payment
Point of Sale Paytm All in One Payment
Geminate Consultancy Services
 
Give1Get2 User's Guide English
Give1Get2 User's Guide EnglishGive1Get2 User's Guide English
Give1Get2 User's Guide English
Yann GEFFROTIN
 
Idram merchant api- Idram Payment System merchant interface description
Idram merchant api- Idram Payment System merchant interface descriptionIdram merchant api- Idram Payment System merchant interface description
Idram merchant api- Idram Payment System merchant interface description
iDramAPI
 
RaaS API Overview and Best Practices
RaaS API Overview and Best PracticesRaaS API Overview and Best Practices
RaaS API Overview and Best Practices
Tango Card
 
Payments integration: Stripe & Taxamo
Payments integration: Stripe & TaxamoPayments integration: Stripe & Taxamo
Payments integration: Stripe & Taxamo
Netguru
 
Payments using Stripe.com
Payments using Stripe.comPayments using Stripe.com
Payments using Stripe.com
Billy Cravens
 

What's hot (12)

Express checkout recurring payments
Express checkout recurring paymentsExpress checkout recurring payments
Express checkout recurring payments
 
QuayPay - Summary
QuayPay - SummaryQuayPay - Summary
QuayPay - Summary
 
How to implement payment gateway integration for non-credit card on Magento2
How to implement payment gateway integration for non-credit card on Magento2How to implement payment gateway integration for non-credit card on Magento2
How to implement payment gateway integration for non-credit card on Magento2
 
Payment integration patterns в Magento2
Payment integration patterns в Magento2Payment integration patterns в Magento2
Payment integration patterns в Magento2
 
Cool New Advances in PayPal Express Checkout
Cool New Advances in PayPal Express CheckoutCool New Advances in PayPal Express Checkout
Cool New Advances in PayPal Express Checkout
 
Pay Book Guide User En
Pay Book Guide User EnPay Book Guide User En
Pay Book Guide User En
 
Point of Sale Paytm All in One Payment
Point of Sale Paytm All in One PaymentPoint of Sale Paytm All in One Payment
Point of Sale Paytm All in One Payment
 
Give1Get2 User's Guide English
Give1Get2 User's Guide EnglishGive1Get2 User's Guide English
Give1Get2 User's Guide English
 
Idram merchant api- Idram Payment System merchant interface description
Idram merchant api- Idram Payment System merchant interface descriptionIdram merchant api- Idram Payment System merchant interface description
Idram merchant api- Idram Payment System merchant interface description
 
RaaS API Overview and Best Practices
RaaS API Overview and Best PracticesRaaS API Overview and Best Practices
RaaS API Overview and Best Practices
 
Payments integration: Stripe & Taxamo
Payments integration: Stripe & TaxamoPayments integration: Stripe & Taxamo
Payments integration: Stripe & Taxamo
 
Payments using Stripe.com
Payments using Stripe.comPayments using Stripe.com
Payments using Stripe.com
 

Similar to Payment Request API with a React high order component

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
 
How to Integrate Stripe Payment with Liferay A Step-by-Step Guide
How to Integrate Stripe Payment with Liferay A Step-by-Step GuideHow to Integrate Stripe Payment with Liferay A Step-by-Step Guide
How to Integrate Stripe Payment with Liferay A Step-by-Step Guide
Inexture Solutions
 
Monetizing your Applications with PayPal X Payments Platform
Monetizing your Applications withPayPal X Payments PlatformMonetizing your Applications withPayPal X Payments Platform
Monetizing your Applications with PayPal X Payments Platform
guest72b121
 
Monetizing your Applications with PayPal X Payments Platform
Monetizing your Applications withPayPal X Payments PlatformMonetizing your Applications withPayPal X Payments Platform
Monetizing your Applications with PayPal X Payments Platform
PayPalX Developer Network
 
Mắt kính chính hãng trả góp 0%
Mắt kính chính hãng trả góp 0%Mắt kính chính hãng trả góp 0%
Mắt kính chính hãng trả góp 0%
Phcng991605
 
Safex pay wl-pg-presentation
Safex pay wl-pg-presentationSafex pay wl-pg-presentation
Safex pay wl-pg-presentation
Neha Sahay
 
CS-Cart Stripe Payment Gateway V3.1
CS-Cart Stripe Payment Gateway V3.1CS-Cart Stripe Payment Gateway V3.1
CS-Cart Stripe Payment Gateway V3.1
Webkul Software Pvt. Ltd.
 
How to integrate paytm payment gateway using react js in seven easy steps
How to integrate paytm payment gateway using react js in seven easy stepsHow to integrate paytm payment gateway using react js in seven easy steps
How to integrate paytm payment gateway using react js in seven easy steps
Katy Slemon
 
Safex pay avantgarde -presentation
Safex pay avantgarde -presentationSafex pay avantgarde -presentation
Safex pay avantgarde -presentation
Neha Sahay
 
A Journey with React
A Journey with ReactA Journey with React
A Journey with React
FITC
 
Accept PayPal in 5 Minutes or Less Using Button Manager and Button Manager API
Accept PayPal in 5 Minutes or Less Using Button Manager and Button Manager APIAccept PayPal in 5 Minutes or Less Using Button Manager and Button Manager API
Accept PayPal in 5 Minutes or Less Using Button Manager and Button Manager API
PayPalX Developer Network
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applications
Evangelia Mitsopoulou
 
Safex pay corporate presentation
Safex pay corporate presentationSafex pay corporate presentation
Safex pay corporate presentation
Neha Sahay
 
Introducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solutionIntroducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solution
Neha Sahay
 
The Future of the Web - Cold Front conference 2016
The Future of the Web - Cold Front conference 2016The Future of the Web - Cold Front conference 2016
The Future of the Web - Cold Front conference 2016
Robert Nyman
 
Lo39
Lo39Lo39
Lo39
lksoo
 
08
0808
Payments Integration at Uber: a (Short) Case Study
Payments Integration at Uber: a (Short) Case StudyPayments Integration at Uber: a (Short) Case Study
Payments Integration at Uber: a (Short) Case Study
Gergely Orosz
 
Creating an Uber Clone - Part XXXI - Transcript.pdf
Creating an Uber Clone - Part XXXI - Transcript.pdfCreating an Uber Clone - Part XXXI - Transcript.pdf
Creating an Uber Clone - Part XXXI - Transcript.pdf
ShaiAlmog1
 
Rakuten Pay Mobile Payment Service of Choice
Rakuten Pay  Mobile Payment Service of ChoiceRakuten Pay  Mobile Payment Service of Choice
Rakuten Pay Mobile Payment Service of Choice
Rakuten Group, Inc.
 

Similar to Payment Request API with a React high order component (20)

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
 
How to Integrate Stripe Payment with Liferay A Step-by-Step Guide
How to Integrate Stripe Payment with Liferay A Step-by-Step GuideHow to Integrate Stripe Payment with Liferay A Step-by-Step Guide
How to Integrate Stripe Payment with Liferay A Step-by-Step Guide
 
Monetizing your Applications with PayPal X Payments Platform
Monetizing your Applications withPayPal X Payments PlatformMonetizing your Applications withPayPal X Payments Platform
Monetizing your Applications with PayPal X Payments Platform
 
Monetizing your Applications with PayPal X Payments Platform
Monetizing your Applications withPayPal X Payments PlatformMonetizing your Applications withPayPal X Payments Platform
Monetizing your Applications with PayPal X Payments Platform
 
Mắt kính chính hãng trả góp 0%
Mắt kính chính hãng trả góp 0%Mắt kính chính hãng trả góp 0%
Mắt kính chính hãng trả góp 0%
 
Safex pay wl-pg-presentation
Safex pay wl-pg-presentationSafex pay wl-pg-presentation
Safex pay wl-pg-presentation
 
CS-Cart Stripe Payment Gateway V3.1
CS-Cart Stripe Payment Gateway V3.1CS-Cart Stripe Payment Gateway V3.1
CS-Cart Stripe Payment Gateway V3.1
 
How to integrate paytm payment gateway using react js in seven easy steps
How to integrate paytm payment gateway using react js in seven easy stepsHow to integrate paytm payment gateway using react js in seven easy steps
How to integrate paytm payment gateway using react js in seven easy steps
 
Safex pay avantgarde -presentation
Safex pay avantgarde -presentationSafex pay avantgarde -presentation
Safex pay avantgarde -presentation
 
A Journey with React
A Journey with ReactA Journey with React
A Journey with React
 
Accept PayPal in 5 Minutes or Less Using Button Manager and Button Manager API
Accept PayPal in 5 Minutes or Less Using Button Manager and Button Manager APIAccept PayPal in 5 Minutes or Less Using Button Manager and Button Manager API
Accept PayPal in 5 Minutes or Less Using Button Manager and Button Manager API
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applications
 
Safex pay corporate presentation
Safex pay corporate presentationSafex pay corporate presentation
Safex pay corporate presentation
 
Introducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solutionIntroducing safexpay smart NBFC solution
Introducing safexpay smart NBFC solution
 
The Future of the Web - Cold Front conference 2016
The Future of the Web - Cold Front conference 2016The Future of the Web - Cold Front conference 2016
The Future of the Web - Cold Front conference 2016
 
Lo39
Lo39Lo39
Lo39
 
08
0808
08
 
Payments Integration at Uber: a (Short) Case Study
Payments Integration at Uber: a (Short) Case StudyPayments Integration at Uber: a (Short) Case Study
Payments Integration at Uber: a (Short) Case Study
 
Creating an Uber Clone - Part XXXI - Transcript.pdf
Creating an Uber Clone - Part XXXI - Transcript.pdfCreating an Uber Clone - Part XXXI - Transcript.pdf
Creating an Uber Clone - Part XXXI - Transcript.pdf
 
Rakuten Pay Mobile Payment Service of Choice
Rakuten Pay  Mobile Payment Service of ChoiceRakuten Pay  Mobile Payment Service of Choice
Rakuten Pay Mobile Payment Service of Choice
 

Recently uploaded

Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
Tobias Schneck
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
UiPathCommunity
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Ukraine
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
Sunil Jagani
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 

Recently uploaded (20)

Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!Containers & AI - Beauty and the Beast!?!
Containers & AI - Beauty and the Beast!?!
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
 
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptxAI in the Workplace Reskilling, Upskilling, and Future Work.pptx
AI in the Workplace Reskilling, Upskilling, and Future Work.pptx
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 

Payment Request API with a React high order component

  • 1. Payment Request API with a React high order component @marcolanaro86marcolanaro
  • 2. Question 1 How many people actually enjoy the process of buying something on the web using their mobile device?
  • 3. Question 2 How many people can remember all the details from their credit card without having to take it out?
  • 4. Question 3 How many people like giving their raw credit card numbers over to random websites?
  • 5. Web Desktop vs Mobile Traffic Conversion 60% 5% 40% 15% MobileDesktop
  • 6. Mobile Native vs Web Step conversion results -> checkout Total Conversion Native Web 10% 5% Step conversion checkout -> confirmation 30% 30% 30% 15%
  • 8. Autocomplete fields less friction 30% faster each app needs data entry each app need validation process multiple payment methods Autofill
  • 9. Cannot guess 100% reliability card type from number Card number formatting while typing Card number validation Custom Forms Scan your card details from the camera without need of typing Credit/Debit card …billing/shipping address, contact info
  • 11. It is not Integrator with payment processor Supported by Safari (but we have ApplePay) A new payment method A finalised standard
  • 12. It is Open Cross browser Chrome, Chrome for Android, Edge, Opera Standard One click payment
  • 14. Despite WIP, >28% support
  • 17. React Everything is a component Declarative code Not obvious how to encapsulate logic in a component
  • 18. Functor Given categories C and D a functor F:C→D is a map that sends each object x in C to an object F(x) in D & each morphism f:x→y in C to a morphism F(f):F(x)→F(y) in D such that each commuting diagram in C maps to a commuting diagram in D
  • 19.
  • 20. 1 2
  • 21. 1 2
  • 22. const paymentRequest = () => (WrappedComponent) => ( class ExtendedComponent extends React.Component { render() { const { config, ...rest } = this.props; if (!isSupported() || !config) { return WrappedComponent({ ...rest, isSupported: false }); } return WrappedComponent({ ...rest, isSupported: true, show: show(config), abort }); } } ); Pseudo code
  • 23. Why? Powerful behaviour encapsulated in the high order component Declarative API Composable Very simple to use
  • 24. Create the component import * as React from 'react'; import paymentRequest from 'react-payment-request-api'; const Button = ({ show, isSupported, style }) => isSupported ? <button onClick={show} style={style}>Pay now!</button> : <span>Payment request not supported</span>; export default paymentRequest()(Button);
  • 25. Use the component import * as React from 'react'; import * as ReactDOM from 'react-dom'; import Button from './button'; import getConfig from './config'; import styles from './styles'; const App = () => <Button config={getConfig()} style={styles.button} />; ReactDOM.render(<App />, document.getElementById('app'));
  • 26. const getConfig = () => ({ methodData: [{ supportedMethods: ['basic-card'], data: { supportedNetworks: ['visa', 'mastercard', 'diners'], }, }], details: details, onShowSuccess: (result, resolve, reject): void => { console.log('Result:', result); // make the payment setTimeout(resolve, 2000); }, onShowFail: (error) => console.log('Error', error), onShippingAddressChange: (request, resolve, reject): void => { console.log('ShippingAddress:', request.shippingAddress); // recalculate details resolve(details); }, onShippingOptionChange: (request, resolve, reject): void => { resolve(details); }, }); Configuration
  • 27. const getConfig = () => ({ methodData: [{ supportedMethods: ['basic-card'], data: { supportedNetworks: ['visa', 'mastercard', 'diners'], }, }], details: details, onShowSuccess: (result, resolve, reject): void => { console.log('Result:', result); // make the payment setTimeout(resolve, 2000); }, onShowFail: (error) => console.log('Error', error), onShippingAddressChange: (request, resolve, reject): void => { console.log('ShippingAddress:', request.shippingAddress); // recalculate details resolve(details); }, onShippingOptionChange: (request, resolve, reject): void => { resolve(details); }, }); Configuration

Editor's Notes

  1. Mehdi rename Hello, I’m Marco, I’m team leader in Tango in the last year I’ve spent almost all the time working on the development of the new mobile web booking flow. I’ve realized soon that it’s very difficult to create a low friction experience with high engagement and easy to use workflow. For that reason I’m really exited about the Payment Request API. reducing the friction and making life easier for users when it’s time to make a purchase the step with probably the highest friction in the entire flow.
  2. But before jumping into the topic, just because it’s almost lunch time, I would like to spend some minutes on doing a little user activity, please raise your hand
  3. I’m talking about all 16 digits number, really? Cvc and expiration? Ok, it’s more then the expected, I have to be honest
  4. … Yeah, exactly. Those are just simple example of reasons why an usual checkout form is a huge barrier for our user. but let’s do a step back and look at some numbers
  5. if we try to compare the desktop web site and the mobile website we find a very interesting situation. despite the mobile traffic is continuously increasing, the conversion on mobile web devices is pretty low. Now, I’m not saying that the work we have done is bad and the mobile web site does not work. I’m also not saying that we should compare the users base. People probably use the 2 products in 2 different ways and they expect something different. For instance, checking train times.
  6. If we now try to compare the native apps (ios and android) with web, we can see something very interesting. Step conversion between results and checkout is the same. Step conversion between checkout and confirmation is half. total conversion Again, probably users use the mobile web site just to check train times But those numbers are pretty similar to result of some study made by Google, Microsoft, Alibaba.
  7. Well, a lot of studies think that the biggest reason is the friction every user find in a mobile web page on filling the payment details. think about it: billing address, name, email, card number, card type, expiration date, cvv everything manual moving across different pages there are a lot of informations to add in multiple pages using multi keyboard typing fat fingering So payment request api It’s all about reducing the friction and making life easier for users. Especially things like repetitive data set, things that user can store inside the browser are exposed API.
  8. chrome has been fighting a good fight against annoying checkout form since 2011. started with autofill not only: every app has it’s own user experience that need to be trusted by the user
  9. Then, just because we are tech guys, there is the development experience. Think about all the problems you have to fight to implement a smart checkout form i’m not talking about expiration validation, but something more trivial
  10. Save the world from annoying checkout form Secure way to exchange sensitive information with third party the browser play this role to help facilitate checkout on the highest friction point common things you request asked
  11. It's not the goal the goal is to allow the user to pay in the way they want to pay and do it quickly and efficently Braintree
  12. standard api Major vendor Seamless easy to use checkout experience
  13. react payment request is NATIVE
  14. Site Browser -> native UI -> collect info (opt in) payment app Info to the browser
  15. biggest mistake in react is mix imperative business logic in a UI component i’m gonna show you how to encapsulate business logic
  16. Now, we should do some step back, breath, and try to remember what we have learn at university. Category map Object x -> F(x) Morphism f:x->y. F(x):F(x)->F(y) each commuting diagram in C map to a commuting diagram in D wha toes the means? it means that Given the same start and endpoint leads to same results by composition pretty simple right?
  17. I know right
  18. factory Pig into sausage pig into warthog
  19. is it simpler now?
  20. Input class output class 2 classes are 2 morphisms in 2 different categories but composable in the same way Enhanced interface Enhanced behaviour
  21. powerfull behaviour encapsulated Declarative (maintanable) Compasable: the output class from a hoc can be input of another hoc very simple to use
  22. last line: we are composing an UI component enhancing: 1-interface 2-behaviour
  23. consumer of enhanced component we are passing down a configuration object
  24. let’s go ahead and see it in action button is based on feature detection checking if payment request exist, native ui, controlled by chrome but populate with data provided by trainline