Skip to content

Commit 085462b

Browse files
fix(android): missing strings.xml on target project (#69)
* fix(android): create and use os_payments_strings.xml file instead of assuming strings.xml exists * fix(android): use correct directory for O11 www folder * chore(release): raise to version 1.2.11 * fix(ios): fix(android): use correct directory for O11 www folder * fix(android): include all directory possibilities for json-config/PaymentsPluginConfiguration.json config file * fix(ios): include all directory possibilities for json-config/PaymentsPluginConfiguration.json config file * chore: update changelog * Update hooks/android/androidCopyPreferences.js Co-authored-by: Pedro Bilro <pedro.gustavo.bilro@outsystems.com> * fix(ios): actually check if directory exists and check for another possible location for json-config/Payments --------- Co-authored-by: Pedro Bilro <pedro.gustavo.bilro@outsystems.com>
1 parent 2e60ce0 commit 085462b

File tree

5 files changed

+55
-22
lines changed

5 files changed

+55
-22
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
The changes documented here do not include those from the original repository.
88

9+
## 1.2.11
10+
11+
### Fixes
12+
- (android) Fixes missing strings.xml on target project (https://outsystemsrd.atlassian.net/browse/RMET-4779)
13+
- (android) include all directory possibilities for json-config/PaymentsPluginConfiguration.json config file (https://outsystemsrd.atlassian.net/browse/RMET-4779)
14+
- (ios) include all directory possibilities for json-config/PaymentsPluginConfiguration.json config file (https://outsystemsrd.atlassian.net/browse/RMET-4779)
15+
916
## 1.2.10
1017

1118
### Fixes

hooks/android/androidCopyPreferences.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ module.exports = function (context) {
2828

2929
let wwwFolder = "www";
3030
let platformPath = path.join(projectRoot, "platforms/android");
31+
32+
// first we look for the platforms/android/json-config directory
3133
let resourcesPath = fs.existsSync(path.join(platformPath, "json-config"))
3234
? platformPath
33-
: path.join(platformPath, wwwFolder);
35+
: path.join(platformPath, wwwFolder);
36+
37+
// it that directory doesn't then we look for platforms/android/www/json-config
38+
if (!fs.existsSync(path.join(resourcesPath, "json-config"))) {
39+
// if that doesn't exist then we try to use root/www directly
40+
resourcesPath = path.join(projectRoot, wwwFolder);
41+
}
3442

3543
let jsonConfig = "";
3644
let jsonParsed;
@@ -115,7 +123,30 @@ module.exports = function (context) {
115123
});
116124

117125
if(hasGooglePay){
118-
let stringsXmlPath = path.join(projectRoot, 'platforms/android/app/src/main/res/values/strings.xml');
126+
127+
// create XML with correct values directly
128+
var stringsXmlPath = path.join(projectRoot, 'platforms/android/app/src/main/res/values/os_payments_strings.xml');
129+
130+
const xmlContent = `<?xml version='1.0' encoding='utf-8'?>
131+
<resources>
132+
<string name="merchant_name">MERCHANT_NAME</string>
133+
<string name="merchant_country_code">MERCHANT_COUNTRY_CODE</string>
134+
<string name="payment_allowed_networks">ALLOWED_NETWORKS</string>
135+
<string name="payment_supported_capabilities">SUPPORTED_CAPABILITIES</string>
136+
<string name="payment_supported_card_countries">SUPPORTED_CARD_COUNTRIES</string>
137+
<string name="shipping_supported_contacts">SHIPPING_SUPPORTED_CONTACTS</string>
138+
<string name="shipping_country_codes">SHIPPING_COUNTRY_CODES</string>
139+
<string name="billing_supported_contacts">BILLING_SUPPORTED_CONTACTS</string>
140+
<string name="gateway">GATEWAY</string>
141+
<string name="backend_url">BACKEND_URL</string>
142+
<string name="gateway_merchant_id">GATEWAY_MERCHANT_ID</string>
143+
<string name="stripe_version">STRIPE_VERSION</string>
144+
<string name="stripe_pub_key">STRIPE_PUB_KEY</string>
145+
</resources>`;
146+
147+
// write XML file directly
148+
fs.writeFileSync(stringsXmlPath, xmlContent);
149+
119150
let stringsXmlContents = fs.readFileSync(stringsXmlPath).toString();
120151
let etreeStrings = et.parse(stringsXmlContents);
121152
const resources = etreeStrings.getroot();

hooks/ios/iOSCopyPreferences.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,21 @@ module.exports = function (context) {
2626
let appName = appNameParser.name();
2727

2828
let platformPath = path.join(projectRoot, "platforms/ios");
29-
let resourcesPath = path.join(platformPath, appName, "Resources");
3029

30+
// first we look for the platforms/ios/<AppName>/Resources directory
31+
let resourcesPath = fs.existsSync(platformPath, appName, "Resources/json-config")
32+
? path.join(platformPath, appName, "Resources")
33+
: path.join(platformPath, "www")
34+
35+
// if that directory doesn't exist then we look for platforms/ios/www/json-config
36+
if (!fs.existsSync(path.join(resourcesPath, "json-config"))) {
37+
// if that doesn't exist then we try to use platforms/ios/<AppName>/Resources/www
38+
resourcesPath = path.join(platformPath, appName, "Resources/www");
39+
}
40+
41+
// if that doesn't exist then we try to use root/www directly
3142
if (!fs.existsSync(path.join(resourcesPath, "json-config"))) {
32-
resourcesPath = path.join(platformPath, appName, "Resources/www");
43+
resourcesPath = path.join(projectRoot, "www");
3344
}
3445

3546
//read json config file

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.outsystems.payments",
3-
"version": "1.2.10",
3+
"version": "1.2.11",
44
"description": "OutSystems-owned plugin for mobile payments",
55
"keywords": [
66
"ecosystem:cordova",

plugin.xml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<plugin id="com.outsystems.payments" version="1.2.10" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2+
<plugin id="com.outsystems.payments" version="1.2.11" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
33
<name>OSPayments</name>
44
<description>OutSystems-owned plugin for mobile payments</description>
55
<author>OutSystems Inc</author>
@@ -24,22 +24,6 @@
2424
<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />
2525
</edit-config>
2626

27-
<config-file parent="/resources" target="res/values/strings.xml">
28-
<string name="merchant_name">MERCHANT_NAME</string>
29-
<string name="merchant_country_code">MERCHANT_COUNTRY_CODE</string>
30-
<string name="payment_allowed_networks">ALLOWED_NETWORKS</string>
31-
<string name="payment_supported_capabilities">SUPPORTED_CAPABILITIES</string>
32-
<string name="payment_supported_card_countries">SUPPORTED_CARD_COUNTRIES</string>
33-
<string name="shipping_supported_contacts">SHIPPING_SUPPORTED_CONTACTS</string>
34-
<string name="shipping_country_codes">SHIPPING_COUNTRY_CODES</string>
35-
<string name="billing_supported_contacts">BILLING_SUPPORTED_CONTACTS</string>
36-
<string name="gateway">GATEWAY</string>
37-
<string name="backend_url">BACKEND_URL</string>
38-
<string name="gateway_merchant_id">GATEWAY_MERCHANT_ID</string>
39-
<string name="stripe_version">STRIPE_VERSION</string>
40-
<string name="stripe_pub_key">STRIPE_PUB_KEY</string>
41-
</config-file>
42-
4327
<source-file src="src/android/com/outsystems/payments/OSPayments.kt" target-dir="app/src/main/kotlin/com/outsystems/payments"/>
4428
<framework src="src/android/com/outsystems/payments/build.gradle" custom="true" type="gradleReference" />
4529

0 commit comments

Comments
 (0)