0.0.2 • Published 10 months ago

adyen-rn v0.0.2

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
10 months ago

react-native-adyen

React Native Adyen Module for iOS and Android. Adyen allows developers to collect payment details utilizing native components or via asymetric encryption. Native components can be broken down into Card Components, Redirect Component and 3DS2 Component. Native asymetric encryption encrypts card number, expiry date and cvc/cvv number.

Currently CCI, 3DS, 3DS2, Scheme Card Component, BCMC Card Component, iDEAL Card Component and EPS Card Component are supported. Currently Drop-in integration is not supported.

Since react-native 0.60 and higher, autolinking makes the installation process simpler.

Configuration

iOS

Edit the Podfile to update the iOS platform to 11.0 - platform :ios, '11.0'. Save the Podfile and install the pods.

pod install

Redirect / 3D Secure

To complete the Adyen redirect and properly receive the redirect result on iOS the deeplink URL will need to be listened to on the native delegate application:openUrl:options. Add a native file that contains the following:

import Foundation
import Adyen

@objc(RCTAdyenExample)
class RCTAdyenExample: NSObject {

  @objc(applicationDidOpen:)
  static func applicationDidOpen(_ url: URL) -> Bool {
     let adyenHandled = RedirectComponent.applicationDidOpen(from : url)

     return adyenHandled
  }
}

When the Adyen URL is received, execute the function RCTAdyenExample.applicationDidOpen(url) - the Adyen delegate function will be executed and the redirect result will be recieved through the pending promise.

Android

Redirect / 3D Secure

To complete the Adyen redirect and properly receive the redirect result on Android the expected Adyen scheme and host must be registered in the Android Manifest.

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data
        android:host="${applicationId}"
        android:scheme="adyencheckout" />
</intent-filter>

When the Adyen URL is received, the awaited promise will receive the Redirect result.

Usage

Example

import React from 'react';
import {
  encrypt,
  handleAction,
  handleComponent,
} from 'react-native-adyen';

const adyen = () => {
  const cciRes = await encrypt('10001|...', {
    number: '4111111111111111',
    expiryMonth: '03',
    expiryYear: '30',
    securityCode: '737',
  });

  const actionRes = await handleAction(
    'test_',
    'test',
    PaymentMethods.redirect
  );

  const componentRes = await handleComponent(
    'test_',
    'test',
    paymentMethod,
    {
      currencyCode: 'EUR',
      value: 1000,
      countryCode: 'NL',
    }
  );

  .
  .
  .
};

Methods

Summary


encrypt()

const cciRes = await encrypt(publicKey, paymentDetails);

Adyen provides custom card integration via asymmetric encryption through the this function with providing the client public key and payment details.

Parameters:

NameTypeRequiredDescription
publicKeystringYesSee below.
paymentDetailsobjectYesSee below.

Supported options:

  • publicKey (string) - A public key linked to your API credential, used for client-side authentication.
  • paymentDetails (object) - The credit card number, expiry month, expiry year and cvc/cvv numbers.

handleAction()

const actionRes = await handleAction(clientKey, environment, action);

Adyen provides a redirect component for redirect actions / payment methods i.e. 3D Secure, 3D Secure 2, Redirect Payemnts.

Parameters:

NameTypeRequiredDescription
clientKeystringYesSee below.
environmentstringYesSee below.
actionobjectYesSee below.

Supported options:

  • clientKey (string) - A public key linked to your API credential, that the SDK Components use for client-side authentication.
  • environment (string) - Use test. When you're ready to accept live payments, change the value to one of our live environments.
  • action (object) - Payment object for some payment methods require additional action from the shopper such as: to authenticate a payment with 3D Secure, or to switch to another app to complete the payment.

handleComponent()

const componentRes = await handleComponent(clientKey, environment, paymentMethod, amount);

Adyen provides native component integration - Adyen takes care of the ui and controller logic and provides the developer with the resulting details.

Parameters:

NameTypeRequiredDescription
clientKeystringYesSee below.
environmentstringYesSee below.
paymentMethodobjectYesSee below.
amountobjectYesSee below.

Supported options:

  • clientKey (string) - A public key linked to your API credential, that the SDK Components use for client-side authentication.
  • environment (string) - Use test. When you're ready to accept live payments, change the value to one of our live environments.
  • paymentMethod (object) - Decoded from the /paymentMethods response with the PaymentMethods structure. Find the payment method object for the Component that you want to instantiate.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

UNLICENSED

JSONStreamabort-controllerabsolute-pathacceptsadd-streamanseransi-colorsansi-cyanansi-escapesansi-fragmentsansi-grayansi-redansi-regexansi-stylesansi-wrapanymatchargparsearr-diffarr-flattenarr-unionarray-buffer-byte-lengtharray-filterarray-ifyarray-includesarray-maparray-reducearray-slicearray-uniquearray.prototype.flatarray.prototype.flatmaparray.prototype.tosortedarrifyasapassign-symbolsastral-regexasyncatobavailable-typed-arraysbabel-eslintbabel-plugin-polyfill-corejs2babel-plugin-polyfill-corejs3babel-plugin-polyfill-regeneratorbabel-plugin-syntax-trailing-function-commasbabel-preset-fbjsbalanced-matchbasebase64-jsbig-integerbindingsbplist-creatorbplist-parserbrace-expansionbracesbrowserslistbserbuffer-crc32buffer-frombytescache-basecall-bindcaller-callsitecaller-pathcallsitescamelcasecamelcase-keyscaniuse-litecapture-exitchalkchardetci-infoclass-utilscli-cursorcli-spinnerscli-widthcliuicloneclone-deepcollection-visitcolor-convertcolor-namecolor-supportcolorettecommand-existscommandercommondircompare-funccomponent-emittercompressiblecompressionconcat-mapconcat-streamconnectconventional-changelogconventional-changelog-angularconventional-changelog-atomconventional-changelog-codemirrorconventional-changelog-conventionalcommitsconventional-changelog-coreconventional-changelog-emberconventional-changelog-eslintconventional-changelog-expressconventional-changelog-jqueryconventional-changelog-jshintconventional-changelog-preset-loaderconventional-changelog-writerconventional-commits-filterconventional-commits-parserconventional-recommended-bumpconvert-source-mapcopy-descriptorcore-jscore-js-compatcore-util-iscosmiconfigcross-spawncsstypedargsdateformatdayjsdebugdecamelizedecamelize-keysdecode-uri-componentdeepmergedefaultsdefine-propertiesdefine-propertydenodeifydepddestroydiff-sequencesdoctrinedot-propee-firstelectron-to-chromiumemoji-regexencodeurlencodingend-of-streamenvinfoerror-exerror-stack-parsererrorhandleres-abstractes-set-tostringtages-shim-unscopableses-to-primitiveescaladeescape-htmlescape-string-regexpeslint-config-prettiereslint-plugin-eslint-commentseslint-plugin-flowtypeeslint-plugin-jesteslint-plugin-prettiereslint-plugin-reacteslint-plugin-react-hookseslint-plugin-react-nativeeslint-plugin-react-native-globalseslint-scopeeslint-utilseslint-visitor-keysesprimaesrecurseestraverseesutilsetagevent-target-shimeventemitter3exec-shexecaexpand-bracketsextend-shallowexternal-editorextglobfancy-logfast-difffb-watchmanfbjsfbjs-css-varsfbjs-scriptsfiguresfile-uri-to-pathfill-rangefinalhandlerfind-cache-dirfind-upfor-eachfor-infragment-cachefreshfs-extrafs.realpathfseventsfunction-bindfunction.prototype.namefunctional-red-black-treefunctions-have-namesgensyncget-caller-fileget-intrinsicget-pkg-repoget-stdinget-streamget-symbol-descriptionget-valuegit-raw-commitsgit-remote-origin-urlgit-semver-tagsgitconfiglocalglobglobalsglobalthisgopdgraceful-fshandlebarshard-rejectionhashas-bigintshas-flaghas-property-descriptorshas-protohas-symbolshas-tostringtaghas-valuehas-valueshermes-enginehermes-profile-transformerhosted-git-infohttp-errorsiconv-liteignoreimage-sizeimport-freshindent-stringinflightinheritsiniinquirerinternal-slotinvariantipis-accessor-descriptoris-array-bufferis-arrayishis-bigintis-boolean-objectis-bufferis-callableis-ciis-core-moduleis-data-descriptoris-date-objectis-descriptoris-directoryis-extendableis-extglobis-fullwidth-code-pointis-globis-negative-zerois-numberis-number-objectis-objis-plain-objis-plain-objectis-regexis-shared-array-bufferis-streamis-stringis-symbolis-text-pathis-typed-arrayis-weakrefis-windowsis-wslisarrayisexeisobjectisomorphic-fetchjest-diffjest-get-typejest-haste-mapjest-message-utiljest-mockjest-serializerjest-utiljest-validatejest-workerjetifierjs-tokensjs-yamljsc-androidjsescjson-parse-better-errorsjson-parse-even-better-errorsjson-stable-stringifyjson-stringify-safejson5jsonfilejsonifyjsonparsejsx-ast-utilskind-ofklawlevenlines-and-columnsload-json-filelocate-pathlodashlodash.debouncelodash.ismatchlodash.throttlelog-symbolslogkittyloose-envifylru-cachemake-dirmakeerrormap-cachemap-objmap-visitmeowmerge-streammetrometro-babel-registermetro-babel-transformermetro-cachemetro-configmetro-coremetro-inspector-proxymetro-minify-uglifymetro-react-native-babel-presetmetro-react-native-babel-transformermetro-resolvermetro-source-mapmetro-symbolicatemicromatchmimemime-dbmime-typesmimic-fnmin-indentminimatchminimistminimist-optionsmixin-deepmkdirpmodify-valuesmsmute-streamnannanomatchnegotiatorneo-asyncnice-trynocachenode-fetchnode-int64node-releasesnode-stream-zipnormalize-package-datanormalize-pathnpm-run-pathnullthrowsob1object-assignobject-copyobject-inspectobject-keysobject-visitobject.assignobject.entriesobject.fromentriesobject.hasownobject.pickobject.valueson-finishedon-headersonceonetimeopenoptionsoraos-tmpdirp-finallyp-limitp-locatep-tryparse-jsonparse-node-versionparseurlpascalcasepath-existspath-is-absolutepath-keypath-parsepath-typepicocolorspifypiratespkg-dirplistplugin-errorposix-character-classesprepend-fileprettierprettier-linter-helperspretty-formatprocess-nextick-argspromiseprop-typespseudomappumpqquick-lrurange-parserreact-devtools-corereact-isreact-refreshread-pkgread-pkg-upreadable-streamredentregenerateregenerate-unicode-propertiesregenerator-runtimeregenerator-transformregex-notregexp.prototype.flagsregexppregexpu-coreregjsparserremove-trailing-separatorrepeat-elementrepeat-stringrequire-directoryrequire-main-filenameresolveresolve-fromresolve-urlrestore-cursorretrimrafrsvprun-asyncrx-literx-lite-aggregatessafe-buffersafe-regexsafe-regex-testsafer-buffersanesaxschedulersemversendserialize-errorserve-staticset-blockingset-valuesetimmediatesetprototypeofshallow-cloneshebang-commandshebang-regexshell-quoteside-channelsignal-exitsimple-plistslashslice-ansisnapdragonsnapdragon-nodesnapdragon-utilsource-mapsource-map-resolvesource-map-supportsource-map-urlspdx-correctspdx-exceptionsspdx-expression-parsespdx-license-idssplitsplit-stringsplit2sprintf-jsstack-utilsstackframestacktrace-parserstatic-extendstatusesstream-buffersstring-widthstring.prototype.matchallstring.prototype.trimstring.prototype.trimendstring.prototype.trimstartstring_decoderstrip-ansistrip-bomstrip-eofstrip-indentsudo-promptsupports-colorsupports-preserve-symlinks-flagtemptemp-dirtemp-writetext-extensionsthroatthroughthrough2time-stamptmptmplto-fast-propertiesto-object-pathto-regexto-regex-rangetoidentifiertr46trim-newlinestslibtsutilstype-festtyped-array-lengthtypedarrayua-parser-jsuglify-esuglify-jsultronunbox-primitiveunicode-canonical-property-names-ecmascriptunicode-match-property-ecmascriptunicode-match-property-value-ecmascriptunicode-property-aliases-ecmascriptunion-valueuniversalifyunpipeunset-valueupdate-browserslist-dburixuseuse-subscriptionuse-sync-external-storeutil-deprecateutils-mergeuuidvalidate-npm-package-licensevaryvlqwalkerwcwidthwebidl-conversionswhatwg-fetchwhatwg-urlwhichwhich-boxed-primitivewhich-modulewhich-typed-arraywordwrapwrap-ansiwrappywsxcodexmlbuilderxmldocxpipextendy18nyallistyargsyargs-parser
0.0.2

10 months ago