You are provided HTML/Javascript snippets that can be embedded in any frontend framework. Below you will find examples of this platform embedded in some popular frontend frameworks.
React
Step 1. Install the npm package
npm install payengine
Step 2. Load the platform using react useEffect hook
This is just our recommended way of loading the library. There are other ways library can be loaded for example by leveraging React's provider pattern.
Mac M1 architecture is not directly compatible with Cocoapods. If you encounter issues when installing pods, you can solve it by running:
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
These commands install the ffi package, to load dynamically-linked libraries and let you run the pod install properly, and runs pod install with the proper architecture.
This is our recommended way of loading the library. Other methods can be used according to your own requirements.
Angular
Step 1. Install the npm package
npm install payengine
Step 2. Enable `CUSTOM_ELEMENTS_SCHEMA` mode
By default, Angular assumes that all custom HTML elements are Angular components and throws errors when encountering non-angular components. You need to enable custom elements by adding the CUSTOM_ELEMENTS_SCHEMA to the application module.
Following is an example of what a module file should look like with CUSTOM_ELEMENTS_SCHEMA added.
In HTML you can enable web components by adding a script tag pointing to javascript library. Once loaded, pay-engine web component are available to use anywhere in your HTML.
Please ask your technical contact to get access to iOS SDK.
Displaying secure form
overridefuncviewDidLoad() { super.viewDidLoad()let config =PEConfig(publicKey:"pk_test_xxx", baseURL:"https://console.payengine.co")let payengine =PayEngine(config: config) payengine.createSecureView { [unowned self] result inswitch result {case .success(let view): DispatchQueue.main.async { self.secureField = view self.stackView.addArrangedSubview(self.secureField)//... other UI elements// register tap action will send the createCard request button.addTarget(self, action: #selector(self.onButtonTap), for: .touchUpInside) self.stackView.addArrangedSubview(button) }case .failure(let error):// Error Handling } }}
Capturing card token
@objcfunconButtonTap() { secureField.createCard(merchantId:"MERCHANT_ID") { [unowned self] result inswitch result {case .success(let data)://Use data.token to make the sale API callcase .failure(let error):// Error Handling } }}
Displaying ACH form and capturing token
overridefuncviewDidLoad() { super.viewDidLoad()let config =PEConfig(publicKey:"pk_test_xxx", baseURL:"https://console.payengine.co")let payengine =PayEngine(config: config) payengine.createBankAccountView { [unowned self] result inswitch result {case .success(let view): DispatchQueue.main.async { self.secureField = view self.stackView.addArrangedSubview(self.secureField)//... other UI elements// register tap action will send the createCard request button.addTarget(self, action: #selector(self.onButtonTap), for: .touchUpInside) self.stackView.addArrangedSubview(button) }case .failure(let error):// Error Handling } } }@objcfunconButtonTap() { secureField.createBankAccount(merchantId:"a0c1f72e-b44b-48e0-a8b6-bc72ce38b4ca") { [unowned self] result inswitch result {case .success(let data)://Use data.token to make the ach sale API call case .failure(let error):// Error Handling } } }
Lightweight Version (Optimized for Secure Fields)
For applications that don't require all web components, an optimized library version enables faster load times with access to only a limited set of components. This is advisable for those needing only secure fields or Plaid in their web application.
Please note that the optimized library only provides the following functionalities. For UI web widgets, please use the full library as specified in the previous section.