Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions android/src/main/java/dk/madslee/mobilepay/RNMobilePayModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.content.Intent;

import com.facebook.react.bridge.*;
import dk.danskebank.mobilepay.sdk.CaptureType;
import dk.danskebank.mobilepay.sdk.Country;
Expand Down Expand Up @@ -146,6 +147,16 @@ public void setMerchantId(String merchantId) {
mMerchantId = merchantId;
}

@ReactMethod
public void isMobilePayInstalled(String country, final Callback successCb, final Callback failureCb) {
try {
Country mobilePayCountry = Country.valueOf(country);
successCb.invoke(MobilePay.getInstance().isMobilePayInstalled(getReactApplicationContext(), mobilePayCountry));
} catch (Exception e) {
failureCb.invoke(e.toString());
}
}

@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
Expand All @@ -158,9 +169,6 @@ public Map<String, Object> getConstants() {
constants.put("COUNTRY_NORWAY", Country.NORWAY.name());
constants.put("COUNTRY_FINLAND", Country.FINLAND.name());

constants.put("isMobilePayInstalledDenmark", MobilePay.getInstance().isMobilePayInstalled(getReactApplicationContext(), Country.DENMARK));
constants.put("isMobilePayInstalledNorway", MobilePay.getInstance().isMobilePayInstalled(getReactApplicationContext(), Country.NORWAY));
constants.put("isMobilePayInstalledFinland", MobilePay.getInstance().isMobilePayInstalled(getReactApplicationContext(), Country.FINLAND));
return constants;
}

Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ import { NativeModules } from 'react-native';

const { RNMobilePay } = NativeModules;

export function isMobilePayInstalled (country) {
return new Promise((resolve, reject) => {
RNMobilePay.isMobilePayInstalled(country, resolve, reject);
});
}

export default RNMobilePay;