halo-sdk-react-native 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -27
- package/README.md +735 -735
- package/android/build.gradle +90 -89
- package/android/settings.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +9 -11
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/AnimationActivity.kt +160 -160
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/Const.kt +15 -15
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloCallbacks.kt +126 -126
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloReactActivity.kt +61 -61
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloSdkImplementation.kt +81 -81
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloSdkModule.kt +74 -74
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/HaloSdkPackage.kt +16 -16
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/UIContext.kt +20 -20
- package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/Utils.kt +154 -154
- package/package.json +34 -34
package/android/build.gradle
CHANGED
|
@@ -1,89 +1,90 @@
|
|
|
1
|
-
apply plugin: 'com.android.library'
|
|
2
|
-
apply plugin: 'kotlin-android'
|
|
3
|
-
|
|
4
|
-
group 'za.co.synthesis.halo.sdkreactnativeplugin'
|
|
5
|
-
version '1.0-SNAPSHOT'
|
|
6
|
-
|
|
7
|
-
Properties properties = new Properties()
|
|
8
|
-
if (rootProject.file("local.properties").exists()) {
|
|
9
|
-
properties.load(project.rootProject.file("local.properties").newDataInputStream())
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
rootProject.allprojects {
|
|
13
|
-
repositories {
|
|
14
|
-
google()
|
|
15
|
-
mavenCentral()
|
|
16
|
-
maven { url 'https://jitpack.io' }
|
|
17
|
-
|
|
18
|
-
def repos = [
|
|
19
|
-
'releases',
|
|
20
|
-
'snapshots'
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
flatDir {
|
|
24
|
-
dirs "${project(':halo-sdk-react-native').projectDir}/libs"
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
repos.each { repo ->
|
|
28
|
-
maven {
|
|
29
|
-
name = repo
|
|
30
|
-
url = "s3://synthesis-halo-artifacts/$repo"
|
|
31
|
-
credentials(AwsCredentials) {
|
|
32
|
-
def localAccessKey = properties.getProperty('aws.accesskey')
|
|
33
|
-
def systemEnvAccessKey = System.getenv('AWS_ACCESS_KEY_ID')
|
|
34
|
-
|
|
35
|
-
def localSecretKey = properties.getProperty('aws.secretkey')
|
|
36
|
-
def systemEnvSecretKey = System.getenv('AWS_SECRET_ACCESS_KEY')
|
|
37
|
-
|
|
38
|
-
def localToken = properties.getProperty('aws.token')
|
|
39
|
-
def systemEnvToken = System.getenv('AWS_SESSION_TOKEN')
|
|
40
|
-
|
|
41
|
-
accessKey = localAccessKey != null ? localAccessKey : systemEnvAccessKey
|
|
42
|
-
secretKey = localSecretKey != null ? localSecretKey : systemEnvSecretKey
|
|
43
|
-
|
|
44
|
-
if (systemEnvToken != null) {
|
|
45
|
-
sessionToken = systemEnvToken
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
android {
|
|
54
|
-
compileSdk 35
|
|
55
|
-
namespace 'za.co.synthesis.halo.sdkreactnativeplugin'
|
|
56
|
-
|
|
57
|
-
compileOptions {
|
|
58
|
-
sourceCompatibility JavaVersion.VERSION_17
|
|
59
|
-
targetCompatibility JavaVersion.VERSION_17
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
kotlinOptions {
|
|
63
|
-
jvmTarget = '17'
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
sourceSets {
|
|
67
|
-
main.java.srcDirs += 'src/main/kotlin'
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
defaultConfig {
|
|
71
|
-
minSdkVersion 29
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
def sdkVersion = "4.0.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
implementation 'androidx.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
implementation(name: '
|
|
89
|
-
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
3
|
+
|
|
4
|
+
group 'za.co.synthesis.halo.sdkreactnativeplugin'
|
|
5
|
+
version '1.0-SNAPSHOT'
|
|
6
|
+
|
|
7
|
+
Properties properties = new Properties()
|
|
8
|
+
if (rootProject.file("local.properties").exists()) {
|
|
9
|
+
properties.load(project.rootProject.file("local.properties").newDataInputStream())
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
rootProject.allprojects {
|
|
13
|
+
repositories {
|
|
14
|
+
google()
|
|
15
|
+
mavenCentral()
|
|
16
|
+
maven { url 'https://jitpack.io' }
|
|
17
|
+
|
|
18
|
+
def repos = [
|
|
19
|
+
'releases',
|
|
20
|
+
'snapshots'
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
flatDir {
|
|
24
|
+
dirs "${project(':halo-sdk-react-native').projectDir}/libs"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
repos.each { repo ->
|
|
28
|
+
maven {
|
|
29
|
+
name = repo
|
|
30
|
+
url = "s3://synthesis-halo-artifacts/$repo"
|
|
31
|
+
credentials(AwsCredentials) {
|
|
32
|
+
def localAccessKey = properties.getProperty('aws.accesskey')
|
|
33
|
+
def systemEnvAccessKey = System.getenv('AWS_ACCESS_KEY_ID')
|
|
34
|
+
|
|
35
|
+
def localSecretKey = properties.getProperty('aws.secretkey')
|
|
36
|
+
def systemEnvSecretKey = System.getenv('AWS_SECRET_ACCESS_KEY')
|
|
37
|
+
|
|
38
|
+
def localToken = properties.getProperty('aws.token')
|
|
39
|
+
def systemEnvToken = System.getenv('AWS_SESSION_TOKEN')
|
|
40
|
+
|
|
41
|
+
accessKey = localAccessKey != null ? localAccessKey : systemEnvAccessKey
|
|
42
|
+
secretKey = localSecretKey != null ? localSecretKey : systemEnvSecretKey
|
|
43
|
+
|
|
44
|
+
if (systemEnvToken != null) {
|
|
45
|
+
sessionToken = systemEnvToken
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
android {
|
|
54
|
+
compileSdk 35
|
|
55
|
+
namespace 'za.co.synthesis.halo.sdkreactnativeplugin'
|
|
56
|
+
|
|
57
|
+
compileOptions {
|
|
58
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
59
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
kotlinOptions {
|
|
63
|
+
jvmTarget = '17'
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
sourceSets {
|
|
67
|
+
main.java.srcDirs += 'src/main/kotlin'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
defaultConfig {
|
|
71
|
+
minSdkVersion 29
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
def sdkVersion = "4.0.18"
|
|
76
|
+
def sdkDebugVersion = "4.0.18-debug"
|
|
77
|
+
|
|
78
|
+
dependencies {
|
|
79
|
+
// React Native is provided by the host app
|
|
80
|
+
compileOnly 'com.facebook.react:react-native:+'
|
|
81
|
+
implementation 'androidx.core:core-ktx:1.9.0'
|
|
82
|
+
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
83
|
+
|
|
84
|
+
// Halo SDK
|
|
85
|
+
releaseApi group: "za.co.synthesis.halo", name: "sdk", version: "$sdkVersion", changing: true
|
|
86
|
+
debugApi group: "za.co.synthesis.halo", name: "sdk", version: "$sdkDebugVersion", changing: true
|
|
87
|
+
|
|
88
|
+
implementation(name: 'VisaSensoryBranding', ext: 'aar')
|
|
89
|
+
implementation(name: 'sonic-sdk-release-1.5.0', ext: 'aar')
|
|
90
|
+
}
|
package/android/settings.gradle
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
rootProject.name = 'halo_sdk_react_native_plugin'
|
|
1
|
+
rootProject.name = 'halo_sdk_react_native_plugin'
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
xmlns:tools="http://schemas.android.com/tools"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
android:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</application>
|
|
11
|
-
</manifest>
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
xmlns:tools="http://schemas.android.com/tools">
|
|
3
|
+
<application>
|
|
4
|
+
<activity
|
|
5
|
+
android:name=".AnimationActivity"
|
|
6
|
+
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
|
7
|
+
android:screenOrientation="portrait" />
|
|
8
|
+
</application>
|
|
9
|
+
</manifest>
|
package/android/src/main/kotlin/za/co/synthesis/halo/sdkreactnativeplugin/AnimationActivity.kt
CHANGED
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
-
|
|
3
|
-
import android.graphics.Color
|
|
4
|
-
import android.media.MediaPlayer
|
|
5
|
-
import android.os.Bundle
|
|
6
|
-
import android.os.Handler
|
|
7
|
-
import android.os.Looper
|
|
8
|
-
import android.util.Log
|
|
9
|
-
import android.view.Gravity
|
|
10
|
-
import android.view.HapticFeedbackConstants
|
|
11
|
-
import android.view.ViewGroup
|
|
12
|
-
import android.widget.ImageView
|
|
13
|
-
import android.widget.LinearLayout
|
|
14
|
-
import androidx.appcompat.app.AppCompatActivity
|
|
15
|
-
import com.mastercard.sonic.controller.SonicController
|
|
16
|
-
import com.mastercard.sonic.controller.SonicEnvironment
|
|
17
|
-
import com.mastercard.sonic.controller.SonicType
|
|
18
|
-
import com.mastercard.sonic.listeners.OnCompleteListener
|
|
19
|
-
import com.mastercard.sonic.listeners.OnPrepareListener
|
|
20
|
-
import com.mastercard.sonic.model.SonicMerchant
|
|
21
|
-
import com.mastercard.sonic.widget.SonicBackground
|
|
22
|
-
import com.mastercard.sonic.widget.SonicView
|
|
23
|
-
import com.visa.SensoryBrandingView
|
|
24
|
-
|
|
25
|
-
class AnimationActivity : AppCompatActivity() {
|
|
26
|
-
private val TAG = "AnimationActivity"
|
|
27
|
-
|
|
28
|
-
private lateinit var sonicView: SonicView
|
|
29
|
-
private var sonicController: SonicController? = null
|
|
30
|
-
private lateinit var amexView: ImageView
|
|
31
|
-
private var mediaPlayer: MediaPlayer? = null
|
|
32
|
-
|
|
33
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
|
34
|
-
super.onCreate(savedInstanceState)
|
|
35
|
-
supportRequestWindowFeature(android.view.Window.FEATURE_NO_TITLE)
|
|
36
|
-
window.setFlags(
|
|
37
|
-
android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
38
|
-
android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
val maskedPAN = intent.getStringExtra(Const.MASKED_PAN)
|
|
42
|
-
val cardAssociation: CardAssociations = try {
|
|
43
|
-
intent.getStringExtra(Const.CARD_ASSOCIATION)?.let {
|
|
44
|
-
CardAssociations.valueOf(it.uppercase())
|
|
45
|
-
}
|
|
46
|
-
} catch (e: Exception) {
|
|
47
|
-
getCardTypeFromPan(maskedPAN)
|
|
48
|
-
} ?: CardAssociations.UNKNOWN
|
|
49
|
-
|
|
50
|
-
when (cardAssociation) {
|
|
51
|
-
CardAssociations.VISA -> {
|
|
52
|
-
val animationView = SensoryBrandingView(this, null).apply {
|
|
53
|
-
layoutParams = ViewGroup.LayoutParams(
|
|
54
|
-
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
55
|
-
ViewGroup.LayoutParams.MATCH_PARENT
|
|
56
|
-
)
|
|
57
|
-
gravity = android.view.Gravity.CENTER
|
|
58
|
-
}
|
|
59
|
-
setContentView(animationView)
|
|
60
|
-
animationView.setConstrainedFlags(true)
|
|
61
|
-
animationView.isSoundEnabled = true
|
|
62
|
-
animationView.isHapticFeedbackEnabled = true
|
|
63
|
-
animationView.isCheckMarkShown = true
|
|
64
|
-
animationView.setBackdropColor(Color.parseColor("#FFFFFF"))
|
|
65
|
-
animationView.post {
|
|
66
|
-
animationView.animate { closeAnimation() }
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
CardAssociations.MASTERCARD -> {
|
|
71
|
-
sonicView = SonicView(this).apply {
|
|
72
|
-
layoutParams = ViewGroup.LayoutParams(
|
|
73
|
-
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
74
|
-
ViewGroup.LayoutParams.MATCH_PARENT
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
sonicController = SonicController()
|
|
78
|
-
val sonicMerchant = SonicMerchant.Builder()
|
|
79
|
-
.merchantName("Halo")
|
|
80
|
-
.city("Pretoria")
|
|
81
|
-
.merchantCategoryCodes(arrayOf("MCC 5122"))
|
|
82
|
-
.countryCode("RSA")
|
|
83
|
-
.merchantId("halo-merc-1")
|
|
84
|
-
.build()
|
|
85
|
-
sonicController?.prepare(
|
|
86
|
-
sonicType = SonicType.SOUND_AND_ANIMATION,
|
|
87
|
-
sonicCue = "checkout",
|
|
88
|
-
sonicEnvironment = SonicEnvironment.SANDBOX,
|
|
89
|
-
merchant = sonicMerchant,
|
|
90
|
-
isHapticsEnabled = true,
|
|
91
|
-
context = this,
|
|
92
|
-
onPrepareListener = object : OnPrepareListener {
|
|
93
|
-
override fun onPrepared(statusCode: Int) { playSonic() }
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
sonicView.background = SonicBackground.WHITE
|
|
97
|
-
setContentView(sonicView)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
CardAssociations.AMEX -> {
|
|
101
|
-
val layout = LinearLayout(this).apply {
|
|
102
|
-
orientation = LinearLayout.VERTICAL
|
|
103
|
-
gravity = Gravity.CENTER
|
|
104
|
-
}
|
|
105
|
-
amexView = ImageView(this).apply {
|
|
106
|
-
layoutParams = LinearLayout.LayoutParams(500, 500)
|
|
107
|
-
setImageResource(R.drawable.amex)
|
|
108
|
-
}
|
|
109
|
-
layout.addView(amexView)
|
|
110
|
-
setContentView(layout)
|
|
111
|
-
mediaPlayer = MediaPlayer.create(this, R.raw.amex_confirm)
|
|
112
|
-
mediaPlayer?.isLooping = false
|
|
113
|
-
mediaPlayer?.start()
|
|
114
|
-
mediaPlayer?.setOnCompletionListener {
|
|
115
|
-
mediaPlayer?.release()
|
|
116
|
-
amexView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
|
|
117
|
-
closeAnimation()
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
else -> finish()
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private fun playSonic() {
|
|
126
|
-
sonicController?.play(sonicView, object : OnCompleteListener {
|
|
127
|
-
override fun onComplete(statusCode: Int) { closeAnimation() }
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
private fun closeAnimation() {
|
|
132
|
-
Handler(Looper.getMainLooper()).postDelayed({ finish() }, 3000)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
private fun getCardTypeFromPan(maskedPan: String?): CardAssociations {
|
|
136
|
-
return if (maskedPan != null) {
|
|
137
|
-
when (maskedPan[0]) {
|
|
138
|
-
'2' -> CardAssociations.MASTERCARD
|
|
139
|
-
'5' -> CardAssociations.MASTERCARD
|
|
140
|
-
'4' -> CardAssociations.VISA
|
|
141
|
-
'3' -> CardAssociations.AMEX
|
|
142
|
-
else -> CardAssociations.UNKNOWN
|
|
143
|
-
}
|
|
144
|
-
} else {
|
|
145
|
-
CardAssociations.UNKNOWN
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
@Deprecated("Use onBackPressedDispatcher")
|
|
150
|
-
override fun onBackPressed() {
|
|
151
|
-
// Prevent back press during animation
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
enum class CardAssociations(val association: String) {
|
|
156
|
-
VISA("VISA"),
|
|
157
|
-
MASTERCARD("MASTERCARD"),
|
|
158
|
-
AMEX("AMERICAN EXPRESS"),
|
|
159
|
-
UNKNOWN("UNKNOWN ASSOCIATION")
|
|
160
|
-
}
|
|
1
|
+
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
+
|
|
3
|
+
import android.graphics.Color
|
|
4
|
+
import android.media.MediaPlayer
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
import android.os.Handler
|
|
7
|
+
import android.os.Looper
|
|
8
|
+
import android.util.Log
|
|
9
|
+
import android.view.Gravity
|
|
10
|
+
import android.view.HapticFeedbackConstants
|
|
11
|
+
import android.view.ViewGroup
|
|
12
|
+
import android.widget.ImageView
|
|
13
|
+
import android.widget.LinearLayout
|
|
14
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
15
|
+
import com.mastercard.sonic.controller.SonicController
|
|
16
|
+
import com.mastercard.sonic.controller.SonicEnvironment
|
|
17
|
+
import com.mastercard.sonic.controller.SonicType
|
|
18
|
+
import com.mastercard.sonic.listeners.OnCompleteListener
|
|
19
|
+
import com.mastercard.sonic.listeners.OnPrepareListener
|
|
20
|
+
import com.mastercard.sonic.model.SonicMerchant
|
|
21
|
+
import com.mastercard.sonic.widget.SonicBackground
|
|
22
|
+
import com.mastercard.sonic.widget.SonicView
|
|
23
|
+
import com.visa.SensoryBrandingView
|
|
24
|
+
|
|
25
|
+
class AnimationActivity : AppCompatActivity() {
|
|
26
|
+
private val TAG = "AnimationActivity"
|
|
27
|
+
|
|
28
|
+
private lateinit var sonicView: SonicView
|
|
29
|
+
private var sonicController: SonicController? = null
|
|
30
|
+
private lateinit var amexView: ImageView
|
|
31
|
+
private var mediaPlayer: MediaPlayer? = null
|
|
32
|
+
|
|
33
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
34
|
+
super.onCreate(savedInstanceState)
|
|
35
|
+
supportRequestWindowFeature(android.view.Window.FEATURE_NO_TITLE)
|
|
36
|
+
window.setFlags(
|
|
37
|
+
android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
38
|
+
android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
val maskedPAN = intent.getStringExtra(Const.MASKED_PAN)
|
|
42
|
+
val cardAssociation: CardAssociations = try {
|
|
43
|
+
intent.getStringExtra(Const.CARD_ASSOCIATION)?.let {
|
|
44
|
+
CardAssociations.valueOf(it.uppercase())
|
|
45
|
+
}
|
|
46
|
+
} catch (e: Exception) {
|
|
47
|
+
getCardTypeFromPan(maskedPAN)
|
|
48
|
+
} ?: CardAssociations.UNKNOWN
|
|
49
|
+
|
|
50
|
+
when (cardAssociation) {
|
|
51
|
+
CardAssociations.VISA -> {
|
|
52
|
+
val animationView = SensoryBrandingView(this, null).apply {
|
|
53
|
+
layoutParams = ViewGroup.LayoutParams(
|
|
54
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
55
|
+
ViewGroup.LayoutParams.MATCH_PARENT
|
|
56
|
+
)
|
|
57
|
+
gravity = android.view.Gravity.CENTER
|
|
58
|
+
}
|
|
59
|
+
setContentView(animationView)
|
|
60
|
+
animationView.setConstrainedFlags(true)
|
|
61
|
+
animationView.isSoundEnabled = true
|
|
62
|
+
animationView.isHapticFeedbackEnabled = true
|
|
63
|
+
animationView.isCheckMarkShown = true
|
|
64
|
+
animationView.setBackdropColor(Color.parseColor("#FFFFFF"))
|
|
65
|
+
animationView.post {
|
|
66
|
+
animationView.animate { closeAnimation() }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
CardAssociations.MASTERCARD -> {
|
|
71
|
+
sonicView = SonicView(this).apply {
|
|
72
|
+
layoutParams = ViewGroup.LayoutParams(
|
|
73
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
74
|
+
ViewGroup.LayoutParams.MATCH_PARENT
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
sonicController = SonicController()
|
|
78
|
+
val sonicMerchant = SonicMerchant.Builder()
|
|
79
|
+
.merchantName("Halo")
|
|
80
|
+
.city("Pretoria")
|
|
81
|
+
.merchantCategoryCodes(arrayOf("MCC 5122"))
|
|
82
|
+
.countryCode("RSA")
|
|
83
|
+
.merchantId("halo-merc-1")
|
|
84
|
+
.build()
|
|
85
|
+
sonicController?.prepare(
|
|
86
|
+
sonicType = SonicType.SOUND_AND_ANIMATION,
|
|
87
|
+
sonicCue = "checkout",
|
|
88
|
+
sonicEnvironment = SonicEnvironment.SANDBOX,
|
|
89
|
+
merchant = sonicMerchant,
|
|
90
|
+
isHapticsEnabled = true,
|
|
91
|
+
context = this,
|
|
92
|
+
onPrepareListener = object : OnPrepareListener {
|
|
93
|
+
override fun onPrepared(statusCode: Int) { playSonic() }
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
sonicView.background = SonicBackground.WHITE
|
|
97
|
+
setContentView(sonicView)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
CardAssociations.AMEX -> {
|
|
101
|
+
val layout = LinearLayout(this).apply {
|
|
102
|
+
orientation = LinearLayout.VERTICAL
|
|
103
|
+
gravity = Gravity.CENTER
|
|
104
|
+
}
|
|
105
|
+
amexView = ImageView(this).apply {
|
|
106
|
+
layoutParams = LinearLayout.LayoutParams(500, 500)
|
|
107
|
+
setImageResource(R.drawable.amex)
|
|
108
|
+
}
|
|
109
|
+
layout.addView(amexView)
|
|
110
|
+
setContentView(layout)
|
|
111
|
+
mediaPlayer = MediaPlayer.create(this, R.raw.amex_confirm)
|
|
112
|
+
mediaPlayer?.isLooping = false
|
|
113
|
+
mediaPlayer?.start()
|
|
114
|
+
mediaPlayer?.setOnCompletionListener {
|
|
115
|
+
mediaPlayer?.release()
|
|
116
|
+
amexView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
|
|
117
|
+
closeAnimation()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
else -> finish()
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private fun playSonic() {
|
|
126
|
+
sonicController?.play(sonicView, object : OnCompleteListener {
|
|
127
|
+
override fun onComplete(statusCode: Int) { closeAnimation() }
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private fun closeAnimation() {
|
|
132
|
+
Handler(Looper.getMainLooper()).postDelayed({ finish() }, 3000)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private fun getCardTypeFromPan(maskedPan: String?): CardAssociations {
|
|
136
|
+
return if (maskedPan != null) {
|
|
137
|
+
when (maskedPan[0]) {
|
|
138
|
+
'2' -> CardAssociations.MASTERCARD
|
|
139
|
+
'5' -> CardAssociations.MASTERCARD
|
|
140
|
+
'4' -> CardAssociations.VISA
|
|
141
|
+
'3' -> CardAssociations.AMEX
|
|
142
|
+
else -> CardAssociations.UNKNOWN
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
CardAssociations.UNKNOWN
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@Deprecated("Use onBackPressedDispatcher")
|
|
150
|
+
override fun onBackPressed() {
|
|
151
|
+
// Prevent back press during animation
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
enum class CardAssociations(val association: String) {
|
|
156
|
+
VISA("VISA"),
|
|
157
|
+
MASTERCARD("MASTERCARD"),
|
|
158
|
+
AMEX("AMERICAN EXPRESS"),
|
|
159
|
+
UNKNOWN("UNKNOWN ASSOCIATION")
|
|
160
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
-
|
|
3
|
-
object Const {
|
|
4
|
-
const val APPLICATION_PACKAGE_NAME = "applicationPackageName"
|
|
5
|
-
const val APPLICATION_VERSION = "applicationVersion"
|
|
6
|
-
const val ON_START_TRANSACTION_TIME_OUT = "onStartTransactionTimeOut"
|
|
7
|
-
const val ENABLE_SCHEME_ANIMATIONS = "enableSchemeAnimations"
|
|
8
|
-
|
|
9
|
-
const val TRANSACTION_AMOUNT = "transactionAmount"
|
|
10
|
-
const val MERCHANT_TRANSACTION_REFERENCE = "merchantTransactionReference"
|
|
11
|
-
const val TRANSACTION_CURRENCY = "transactionCurrency"
|
|
12
|
-
|
|
13
|
-
const val CARD_ASSOCIATION = "cardAssociation"
|
|
14
|
-
const val MASKED_PAN = "maskedPAN"
|
|
15
|
-
}
|
|
1
|
+
package za.co.synthesis.halo.sdkreactnativeplugin
|
|
2
|
+
|
|
3
|
+
object Const {
|
|
4
|
+
const val APPLICATION_PACKAGE_NAME = "applicationPackageName"
|
|
5
|
+
const val APPLICATION_VERSION = "applicationVersion"
|
|
6
|
+
const val ON_START_TRANSACTION_TIME_OUT = "onStartTransactionTimeOut"
|
|
7
|
+
const val ENABLE_SCHEME_ANIMATIONS = "enableSchemeAnimations"
|
|
8
|
+
|
|
9
|
+
const val TRANSACTION_AMOUNT = "transactionAmount"
|
|
10
|
+
const val MERCHANT_TRANSACTION_REFERENCE = "merchantTransactionReference"
|
|
11
|
+
const val TRANSACTION_CURRENCY = "transactionCurrency"
|
|
12
|
+
|
|
13
|
+
const val CARD_ASSOCIATION = "cardAssociation"
|
|
14
|
+
const val MASKED_PAN = "maskedPAN"
|
|
15
|
+
}
|