Skip to content

Commit 469bee1

Browse files
chore(android): remove unnecessary dependency to oscore and oscordova (#72)
* chore(android): remove unnecessary dependencies to `oscore` and `oscordova` References: https://outsystemsrd.atlassian.net/browse/RMET-4900 * chore(release): raise to version 1.2.14
1 parent e3c016d commit 469bee1

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ 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.14
10+
11+
### Chores
12+
13+
- (android) remove unecessary dependency to `oscore` and `oscordova` on Android (https://outsystemsrd.atlassian.net/browse/RMET-4900)
14+
915
## 1.2.13
1016

1117
### Chores

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.12",
3+
"version": "1.2.14",
44
"description": "OutSystems-owned plugin for mobile payments",
55
"keywords": [
66
"ecosystem:cordova",

plugin.xml

Lines changed: 1 addition & 1 deletion
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.12" 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.14" 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>

src/android/com/outsystems/payments/OSPayments.kt

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.outsystems.payments
33
import android.app.Activity
44
import android.content.Intent
55
import com.google.gson.Gson
6-
import com.outsystems.plugins.oscordova.CordovaImplementation
76
import com.outsystems.plugins.payments.controller.OSPMTGooglePayManager
87
import com.outsystems.plugins.payments.controller.OSPMTGooglePlayHelper
98
import com.outsystems.plugins.payments.controller.OSPMTController
@@ -13,12 +12,16 @@ import com.outsystems.plugins.payments.model.PaymentDetails
1312
import com.outsystems.plugins.payments.model.Tokenization
1413
import org.apache.cordova.CallbackContext
1514
import org.apache.cordova.CordovaInterface
15+
import org.apache.cordova.CordovaPlugin
1616
import org.apache.cordova.CordovaWebView
17+
import org.apache.cordova.PluginResult
18+
import org.apache.cordova.PluginResult.Status
1719
import org.json.JSONArray
20+
import org.json.JSONObject
1821

19-
class OSPayments : CordovaImplementation() {
22+
class OSPayments : CordovaPlugin() {
2023

21-
override var callbackContext: CallbackContext? = null
24+
var callbackContext: CallbackContext? = null
2225
private lateinit var googlePayManager: OSPMTGooglePayManager
2326
private lateinit var paymentsController: OSPMTController
2427
private lateinit var googlePlayHelper: OSPMTGooglePlayHelper
@@ -47,9 +50,9 @@ class OSPayments : CordovaImplementation() {
4750

4851
override fun initialize(cordova: CordovaInterface, webView: CordovaWebView) {
4952
super.initialize(cordova, webView)
50-
googlePayManager = OSPMTGooglePayManager(getActivity())
53+
googlePayManager = OSPMTGooglePayManager(cordova.activity)
5154
googlePlayHelper = OSPMTGooglePlayHelper()
52-
paymentsController = OSPMTController(googlePayManager, buildPaymentConfigurationInfo(getActivity()), googlePlayHelper)
55+
paymentsController = OSPMTController(googlePayManager, buildPaymentConfigurationInfo(cordova.activity), googlePlayHelper)
5356
}
5457

5558
override fun execute(action: String, args: JSONArray, callbackContext: CallbackContext): Boolean {
@@ -70,7 +73,7 @@ class OSPayments : CordovaImplementation() {
7073
}
7174

7275
private fun setupConfiguration(args: JSONArray) {
73-
paymentsController.setupConfiguration(getActivity(), args.get(0).toString(),
76+
paymentsController.setupConfiguration(cordova.activity, args.get(0).toString(),
7477
{
7578
sendPluginResult(it, null)
7679
},
@@ -81,7 +84,7 @@ class OSPayments : CordovaImplementation() {
8184
}
8285

8386
private fun checkWalletSetup(){
84-
paymentsController.verifyIfWalletIsSetup(getActivity(),
87+
paymentsController.verifyIfWalletIsSetup(cordova.activity,
8588
{
8689
sendPluginResult(it, null)
8790
}, {
@@ -91,12 +94,12 @@ class OSPayments : CordovaImplementation() {
9194
}
9295

9396
private fun setDetailsAndTriggerPayment(args: JSONArray){
94-
setAsActivityResultCallback()
97+
cordova.setActivityResultCallback(this)
9598

9699
paymentDetails = buildPaymentDetails(args)
97100

98101
if(paymentDetails != null){
99-
paymentsController.setDetailsAndTriggerPayment(getActivity(), paymentDetails!!, args.getString(1))
102+
paymentsController.setDetailsAndTriggerPayment(cordova.activity, paymentDetails!!, args.getString(1))
100103
}
101104
else{
102105
sendPluginResult(null, Pair(formatErrorCode(OSPMTError.INVALID_PAYMENT_DETAILS.code), OSPMTError.INVALID_PAYMENT_DETAILS.description))
@@ -126,11 +129,6 @@ class OSPayments : CordovaImplementation() {
126129
// Not used in this project.
127130
}
128131

129-
override fun areGooglePlayServicesAvailable(): Boolean {
130-
// Not used in this project.
131-
return false
132-
}
133-
134132
private fun formatErrorCode(code: Int): String {
135133
return ERROR_FORMAT_PREFIX + code.toString().padStart(4, '0')
136134
}
@@ -163,12 +161,26 @@ class OSPayments : CordovaImplementation() {
163161
private fun buildPaymentDetails(args: JSONArray) : PaymentDetails? {
164162
return try {
165163
gson.fromJson(args.getString(0), PaymentDetails::class.java)
166-
} catch (e: Exception){
164+
} catch (_: Exception){
167165
null
168166
}
169167
}
170168

171169
private fun getStringResourceId(activity: Activity, typeAndName: String): Int {
172170
return activity.resources.getIdentifier(typeAndName, "string", activity.packageName)
173171
}
172+
173+
private fun <T> sendPluginResult(resultVariable: T, error: Pair<String, String>?) {
174+
var pluginResult: PluginResult?
175+
resultVariable?.let {
176+
pluginResult = PluginResult(Status.OK, resultVariable.toString())
177+
this.callbackContext?.sendPluginResult(pluginResult)
178+
return
179+
}
180+
val jsonResult = JSONObject()
181+
jsonResult.put("code", error?.first)
182+
jsonResult.put("message", error?.second ?: "No Results")
183+
pluginResult = PluginResult(Status.ERROR, jsonResult)
184+
this.callbackContext?.sendPluginResult(pluginResult)
185+
}
174186
}

src/android/com/outsystems/payments/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ repositories{
2424
}
2525

2626
dependencies {
27-
implementation("com.github.outsystems:oscore-android:1.2.0@aar")
28-
implementation("com.github.outsystems:oscordova-android:2.0.1@aar")
2927
implementation("com.github.outsystems:ospayments-android:1.1.3@aar")
3028

3129
implementation 'com.stripe:stripe-android:20.5.0'

0 commit comments

Comments
 (0)