All Projects → marcolanaro → react-payment-request-api

marcolanaro / react-payment-request-api

Licence: MIT license
High order component to drive Payment Request widget

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-payment-request-api

ATGValidator
iOS validation framework with form validation support
Stars: ✭ 51 (-12.07%)
Mutual labels:  credit-card
react-credit-cards
Beautiful credit cards for your payment forms
Stars: ✭ 2,386 (+4013.79%)
Mutual labels:  credit-card
python-emv
EMV Smartcard Protocol Tool and Library
Stars: ✭ 72 (+24.14%)
Mutual labels:  credit-card
PCard
Demo project to showcase adding payment card details using JetPack Compose
Stars: ✭ 61 (+5.17%)
Mutual labels:  credit-card
cybersource-sdk-java
Java SDK for CyberSource Simple Order API
Stars: ✭ 44 (-24.14%)
Mutual labels:  payment-request
tbc-credit-card-payment-gateway-php-lib
PHP library for the TBC credit card payment gateway API.
Stars: ✭ 80 (+37.93%)
Mutual labels:  credit-card
payment-fields
React component for Braintree/Stripe/Square payment fields
Stars: ✭ 17 (-70.69%)
Mutual labels:  credit-card
masked-input
Mask input with simple API and rich customization
Stars: ✭ 44 (-24.14%)
Mutual labels:  credit-card
CreditCardScanner
Android Credit Card Scanner using CameraX and ML Kit
Stars: ✭ 24 (-58.62%)
Mutual labels:  credit-card
creditcardnumber
Java library that can provide details of a bank issued credit card number
Stars: ✭ 43 (-25.86%)
Mutual labels:  credit-card
emv-bertlv-tools
Deciphering EMV data encoded in the not so basic "basic encoding rules".
Stars: ✭ 41 (-29.31%)
Mutual labels:  credit-card
Woocommerce-Fawry-Payment-Gateway
Fawry payment gateway is a powerful payment processor that helps you pay through credit cart & Fawry Machines.
Stars: ✭ 21 (-63.79%)
Mutual labels:  credit-card
billing-form
Demo page for user-friendly billing form features
Stars: ✭ 23 (-60.34%)
Mutual labels:  credit-card
card-scanner-flutter
A flutter package for Fast, Accurate and Secure Credit card & Debit card scanning
Stars: ✭ 82 (+41.38%)
Mutual labels:  credit-card
Live-cc-checker
This script will check live cc and Grab proxy and check proxy if its working or not
Stars: ✭ 37 (-36.21%)
Mutual labels:  credit-card
web-payments-example
Demo for Payment Request API and Apple Pay for the Web API
Stars: ✭ 31 (-46.55%)
Mutual labels:  payment-request
PaymentCardView
Custom Credit/Debit card view
Stars: ✭ 62 (+6.9%)
Mutual labels:  credit-card
credit-card-view
A fully customizable Android view that can display credit card's informations
Stars: ✭ 25 (-56.9%)
Mutual labels:  credit-card
svelte-stripe-js
Everything you need to add Stripe Elements to your Svelte project
Stars: ✭ 139 (+139.66%)
Mutual labels:  credit-card
checkdigit
🔒 An easy-to-use check digit library for data validation
Stars: ✭ 19 (-67.24%)
Mutual labels:  credit-card

React high order component to drive payment request widget on react applications 💳.

Browser support

Payment request api is supported on Chrome for desktop v. ^61.0, Chrome for Android and Android Webview v. ^56.0, Microsoft Edge v. ^15.0.

Demo

You can find a working demo here. Be sure to use a supported browser.

NPM Install

npm install react-payment-request-api --save

Usage

Consume the UI component in the hight order component button.js:

import React from "react";
import paymentRequest from 'react-payment-request-api';

const Button = ({ show, isSupported }) => isSupported
    ? <button onClick={show}>Pay now!</button>
    : <span>Payment request not supported</span>;

export default paymentRequest<OwnProps>()(Button);

Pass the configuration to the high order component smartComponent.js:

import React from "react";

import Button from "./button";

const SmartComponent = (config) =>
  <Button config={config} foo="bar" />;

export default SmartComponent;

FAQ

How does it work?

It takes a configuration prop that define how the native widget should behave and any other property you want to pass to the UI component. It spread all the properties a part from the configuration to the enhanced UI component. The UI component will also receive other props that will help improving the experience allowing complete control on the renderer and on the action handler.

Does it support Redux or any other flux implementation?

Yes, with version 1.0 we have changed the interface allowing the user to inject the configuration from the parent component. In this way it does not matter which flux implementation you are using. At the same time, we are preserving the high order component pattern so you have complete control on the renderer and on the action handler.

Does it support Typescript?

Yes, you don't need to install any typescript dependecies because types come with the library. It export PaymentRequestParams (injected configuration) and PaymentRequestInterface (UI component extended props) typescript interfaces. All the examples are written in typescript.

API

Your wrapped component will be decorated with this injected props:

Parameter Type Description
isSupported boolean True if the payment request api is supported by the browser.
show function: () => PaymentRequest It will begin the process when the merchant site want to create a new PaymentRequest.
abort function: () => void You can intentionally abort a PaymentRequest by calling the abort method after show has been called.

Configuration of the high order component:

Parameter Type Description
methodData object Required payment method data.
details object Required information about transaction.
options object Optional parameter for things like shipping, etc.
onShowSuccess Promise based callback: (result, resolve, reject) The handler will be executed after the filling of the form is successfull. You should post your payment request and then resolve or reject the promise.
onShowFail Promise based callback: (error) The handler will be executed if the filling of the form is not successfull (like when the user dismiss the form).
onShippingAddressChange Promise based callback: (request, resolve, reject) The handler will be executed if the shipping address has change. You can change the request and then resolve the promise.
onShippingOptionChange Promise based callback: (request, resolve, reject) The handler will be executed if the shipping option has change. You can change the request and then resolve the promise.
onMerchantValidation Promise based callback: (event) Thde handler is used by Apple pay to validate the merchant.

License

See the LICENSE file for license rights and limitations (MIT).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].