-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(SUB-1060): setup Kotlin Checkout SDK (#1)
* (SUB-1060) Initial setup * (SUB-1060) Update settings.gradle.kts * (SUB-1060) Update readme docs
- Loading branch information
1 parent
8f6351d
commit ca9856e
Showing
35 changed files
with
852 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Log/OS Files | ||
*.log | ||
|
||
# Android Studio generated files and folders | ||
captures/ | ||
.externalNativeBuild/ | ||
.cxx/ | ||
*.apk | ||
output.json | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/ | ||
|
||
# Keystore files | ||
*.jks | ||
*.keystore | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
google-services.json | ||
|
||
# Android Profiling | ||
*.hprof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,36 @@ | ||
# reepay-checkout-demo-app-android-kotlin | ||
# billwerk-checkout-sdk-test | ||
|
||
This demo app demonstrates how to build a checkout flow using CheckoutSheet, an embeddable component that currently supports card payments with a single integration | ||
|
||
## Getting Started | ||
|
||
### Option 1: Load CheckoutSheet dependency through Jitpack | ||
|
||
Request a personal access token (`JITPACK_SECRET`) to Billwerk's Jitpack and store it as an environment variable | ||
|
||
Make sure the `dependencyResolutionManagement` code block is uncommented in `settings.gradle.kts` | ||
|
||
Uncomment the dependency in `build.gradle.kts`: | ||
|
||
``` | ||
implementation("com.github.reepay:reepay-checkout-demo-app-android-kotlin:TAG") | ||
``` | ||
|
||
Run the project | ||
|
||
### Option 2: Load CheckoutSheet manually | ||
|
||
Clone https://github.com/reepay/reepay-android-checkout-sheet to your computer | ||
|
||
Copy the absolute path to the repository | ||
|
||
In `settings.gradle.kts`, uncomment the lines and insert the correct path to the repository: | ||
``` | ||
include(":checkout") | ||
project(":checkout").projectDir = file("/PATH/TO/reepay-android-checkout-sheet/checkout") | ||
``` | ||
|
||
Uncomment the dependency in `build.gradle.kts` | ||
``` | ||
implementation(project(":checkout")) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
namespace = "com.billwerk.checkoutsheetdemo" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.billwerk.checkoutsheetdemo" | ||
minSdk = 26 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("androidx.core:core-ktx:1.12.0") | ||
implementation("androidx.appcompat:appcompat:1.6.1") | ||
|
||
// Option 1. implement external dependency | ||
//implementation("com.github.reepay:reepay-checkout-demo-app-android-kotlin:TAG") | ||
|
||
// Option 2. Implement local depenency | ||
//implementation(project(":checkout")) | ||
|
||
implementation("com.google.android.material:material:1.11.0") | ||
implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.ReepayCheckoutKotlinDemoApp" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
55 changes: 55 additions & 0 deletions
55
ReepayCheckoutSheetDemo/src/main/java/com/billwerk/checkoutsheetdemo/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.billwerk.checkoutsheetdemo | ||
|
||
import android.os.Bundle | ||
import android.util.Log | ||
import android.widget.Button | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.lifecycle.repeatOnLifecycle | ||
import com.billwerk.checkout.CheckoutEvent | ||
import com.billwerk.checkout.CheckoutSheet | ||
import com.billwerk.checkout.CheckoutSheetConfig | ||
import com.billwerk.checkout.SheetStyle | ||
import kotlinx.coroutines.launch | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
val payButton: Button = findViewById(R.id.pay_button) | ||
|
||
// Initialize Checkout Sheet | ||
val checkoutSheet = CheckoutSheet(this) | ||
|
||
// Example configuration | ||
val config = CheckoutSheetConfig( | ||
sessionId = "", | ||
acceptURL = "", // Has to be identical to the one defined in the checkout session | ||
cancelURL = "", | ||
sheetStyle = SheetStyle.FULL_SCREEN, | ||
dismissible = true | ||
) | ||
|
||
// Open checkout sheet | ||
payButton.setOnClickListener { | ||
checkoutSheet.open(config) | ||
} | ||
|
||
// Subscribe to events | ||
listenForEvents() | ||
|
||
} | ||
|
||
private fun listenForEvents() { | ||
lifecycleScope.launch { | ||
repeatOnLifecycle(Lifecycle.State.STARTED) { | ||
CheckoutEvent.events.collect { eventType -> | ||
Log.d("MyApp", "Collected event ${eventType}") | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.