Skip to content

Commit e6bba88

Browse files
Merge pull request #27 from qburst/abhishek/common/KDoc_release
Abhishek/common/k doc release
2 parents 4a9486a + 5179969 commit e6bba88

File tree

20 files changed

+2265
-1136
lines changed

20 files changed

+2265
-1136
lines changed

composeApp/build.gradle.kts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
23
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
34
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
@@ -14,23 +15,23 @@ plugins {
1415

1516
kotlin {
1617
@OptIn(ExperimentalWasmDsl::class)
17-
wasmJs {
18-
moduleName = "composeApp"
19-
browser {
20-
val projectDirPath = project.projectDir.path
21-
commonWebpackConfig {
22-
outputFileName = "composeApp.js"
23-
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
24-
static = (static ?: mutableListOf()).apply {
25-
// Serve sources to debug inside browser
26-
add(projectDirPath)
27-
}
28-
}
29-
}
30-
}
31-
binaries.executable()
32-
}
33-
18+
wasmJs {
19+
moduleName = "composeApp"
20+
browser {
21+
val projectDirPath = project.projectDir.path
22+
commonWebpackConfig {
23+
outputFileName = "composeApp.js"
24+
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
25+
static = (static ?: mutableListOf()).apply {
26+
// Serve sources to debug inside browser
27+
add(projectDirPath)
28+
}
29+
}
30+
}
31+
}
32+
binaries.executable()
33+
}
34+
3435
androidTarget {
3536
@OptIn(ExperimentalKotlinGradlePluginApi::class)
3637
compilerOptions {

composeApp/src/commonMain/kotlin/Cart.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fun Cart(
115115
var paymentIntentParams = SetupParams(
116116
merchantDisplayName = "Qburst",
117117
amount=amount,
118-
paymentIntentClientSecret = "pi_1QXLRzKJ38Q1wp9dF6c5MrT1_secret_9EDiqf0eNa3rfEyE1U2RDMcQj"
118+
paymentIntentClientSecret = "pi_1Qh7GBKJ38Q1wp9dzgi4FRes_secret_xVx43XhW0VG6qbKpVeH46gsfY"
119119
)
120120
CoroutineScope(Dispatchers.Default).launch {
121121
stripe.initPaymentSheet(

gradle/libs.versions.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ stripeAndroid = "20.48.1"
2222
swiftklib = "0.6.3"
2323
cocoapods = "2.0.0"
2424

25-
2625
[libraries]
2726
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
2827
jetbrains-kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesCoreVersion" }
@@ -61,4 +60,4 @@ kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
6160
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
6261
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
6362
swiftklib = { id = "io.github.ttypic.swiftklib", version.ref = "swiftklib" }
64-
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
63+
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }

shared/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,4 @@ ksp {
136136
arg("io.mockative:mockative:opt-in:io.github.OptInType", "kotlinx.cinterop.ExperimentalForeignApi")
137137
arg("io.mockative:mockative:opt-in:io.github.*", "kotlin.ExperimentalStdlibApi")
138138
arg("io.mockative:mockative:opt-in", "kotlin.ExperimentalUnsignedTypes")
139-
}
139+
}

shared/src/androidMain/kotlin/InitializeStripe.kt

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,55 @@ import com.stripe.android.paymentsheet.PaymentSheet
88
import com.stripe.android.paymentsheet.PaymentSheetResult
99
import model.InitialiseParams
1010

11+
/**
12+
* Class responsible for initializing Stripe SDK and handling payment-related operations.
13+
*/
1114
class InitializeStripe {
1215

16+
// Private variables for storing activity, context, and publishable key.
1317
private var _activity: ComponentActivity? = null
1418
private var _context: Context? = null
1519
private var _publishableKey: String? = null
20+
21+
/**
22+
* Instance of [Stripe] used for interacting with Stripe SDK.
23+
*/
1624
lateinit var stripe: Stripe
25+
26+
/**
27+
* Instance of [PaymentSheet] used for managing Stripe payment sheets.
28+
*/
1729
lateinit var paymentSheet: PaymentSheet
18-
var clientSecret = ""
1930

20-
private var paymentResultCallback:PaymentResult ? =null
31+
var clientSecret = ""
2132

33+
/**
34+
* Callback interface for payment result handling.
35+
*/
36+
private var paymentResultCallback: PaymentResult? = null
2237

38+
/**
39+
* Interface definition for payment result callbacks.
40+
*/
2341
interface PaymentResult {
42+
/**
43+
* Called when payment succeeds.
44+
* @param status A map containing payment status details.
45+
*/
2446
fun onSuccess(status: Map<String, Any?>)
47+
48+
/**
49+
* Called when payment fails.
50+
* @param throwable An exception containing the error details.
51+
*/
2552
fun onFailure(throwable: Throwable)
2653
}
2754

28-
29-
// Initialize Stripe only once
55+
/**
56+
* Initializes the Stripe SDK with the provided parameters. Ensures initialization happens only once.
57+
*
58+
* @param initialObject An instance of [InitialiseParams] containing initialization details.
59+
*/
3060
fun initializeStripe(initialObject: InitialiseParams) {
3161
if (_activity == null && _context == null && _publishableKey == null) {
3262
_activity = initialObject.androidActivity as ComponentActivity
@@ -40,20 +70,30 @@ class InitializeStripe {
4070
}
4171
}
4272

43-
73+
/**
74+
* Initializes the Stripe Payment Sheet with the provided parameters.
75+
*
76+
* @param initialiseParams An instance of [InitialiseParams] containing initialization details.
77+
*/
4478
fun initialisePaymentSheet(initialiseParams: InitialiseParams) {
45-
if((initialiseParams.androidContext != null ) && (initialiseParams.androidActivity != null)) {
79+
if ((initialiseParams.androidContext != null) && (initialiseParams.androidActivity != null)) {
4680
PaymentConfiguration.init(
4781
context = initialiseParams.androidContext as Context,
4882
publishableKey = initialiseParams.publishableKey
4983
)
5084

5185
paymentSheet =
5286
PaymentSheet(initialiseParams.androidActivity as ComponentActivity) { paymentSheet ->
53-
onPaymentSheetResult(paymentSheet)
87+
onPaymentSheetResult(paymentSheet)
5488
}
5589
}
5690
}
91+
92+
/**
93+
* Handles the result of a payment sheet operation.
94+
*
95+
* @param paymentSheetResult The result of the payment sheet operation.
96+
*/
5797
private fun onPaymentSheetResult(paymentSheetResult: PaymentSheetResult) {
5898
when (paymentSheetResult) {
5999
is PaymentSheetResult.Canceled -> {
@@ -67,19 +107,29 @@ class InitializeStripe {
67107
}
68108

69109
is PaymentSheetResult.Completed -> {
70-
//TODO: Handle paymentSheetResult
110+
// TODO: Handle paymentSheetResult
71111
paymentResultCallback?.onSuccess(emptyMap())
72112
paymentResultCallback = null
73113
}
74114
}
75115
}
76116

117+
/**
118+
* Sets the callback for handling payment results.
119+
*
120+
* @param callback An implementation of [PaymentResult] interface.
121+
*/
77122
fun setPaymentResultCallback(callback: InitializeStripe.PaymentResult) {
78123
paymentResultCallback = callback
79124
}
80-
81125
}
82126

127+
/**
128+
* Singleton object for managing a single instance of [InitializeStripe].
129+
*/
83130
object SingletonStripeInitialization {
131+
/**
132+
* Single instance of [InitializeStripe].
133+
*/
84134
val StripeInstanse = InitializeStripe()
85-
}
135+
}

0 commit comments

Comments
 (0)