This is an example of Reepay Checkout using Ionic v8.4.1 & Cordova v12.0.0 & Angular v18.2.13.
This Ionic Cordova app requires Ionic CLI npm install -g @ionic/cli
and Cordova npm install -g cordova
. Install node modules with npm install
.
npm install -g @ionic/cli
npm install -g cordova
npm install
Runs your app in the browser.
$ ionic serve
Builds the Android platform and runs on an Android device/emulator.
$ ionic cordova build android
For removing the platform, you can use ionic cordova platform remove android
.
Builds the Android platform and runs on an iOS device/emulator.
$ ionic cordova build ios
For removing the platform, you can use ionic cordova platform remove ios
.
The ReepayCheckout Cordova plugin is an example of a native WebView implementation. It is required for iOS devices (works on iOS 15+).
To add ReepayCheckout plugin:
$ ionic cordova plugin add plugins_src/ReepayCheckout
To remove ReepayCheckout plugin:
$ ionic cordova plugin remove cordova-plugin-reepay-checkout
In the app, we will use URL path changes as events that WebView listens to, thus checking whether URL contains accept
or cancel
in the path.
As we are using WebView by passing session URL, we will receive response with as either Accept URL or Cancel URL as defined in the request body docs:
{
...
"accept_url":"https://webshop.com/accept/order-12345",
"cancel_url":"https://webshop.com/decline/order-12345"
}
In the WebView, we will listen to URL changes when the checkout has completed a redirect, either accept or cancel by checking the URL path. For example the above cancel_url, we will check for /decline
meaning the cancel_url has been triggered and WebView has redirected.
For additional parameters to be passed, use query parameters in accept_url
or cancel_url
. For example, https://webshop.com/decline/order-12345?myEvent=someValue&yourEvent=anotherValue
.
- Generate Private API Key from your Reepay account.
- Add the Private API Key to globals.enum.ts located at
./src/app/core/models/globals.enum.ts
. - Build iOS or Android platform and run your app.
- Choose Card Checkout in the menu.
- (Optional) Add an unique identifier for your Order and/or Customer handle.
- Generate a charge session.
- Create Reepay checkout in a webview.
- Complete the purchase with a test card or cancel the checkout.
cordova.MP4
RPReplay_Final1680075067.MP4
When you have generated a Private API Key from Reepay. Add the value to REEPAY_PRIVATE_API_KEY
located at ./src/app/core/models/globals.enum.ts
.
It is recommended to use Android Studio to run your app after the Android platform has been generated with ionic cordova build android
.
It is recommended to use Xcode to run your app after the iOS platform has been generated the first time with ionic cordova build ios
due to Value for SWIFT_VERSION cannot be empty
.