Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes of the library and example #3

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/AssembleOnMain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Get secret and add to freshly created local.properties
run: echo ${{ secrets.PAYLIKEMERCHANTAPIKEY }} > local.properties
- name: Build APK
run: ./gradlew assemble
run: ./gradlew build
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<a href="https://jitpack.io/#paylike/kotlin_sdk" target="_blank">
<img src="https://jitpack.io/v/paylike/kotlin_sdk.svg" />
</a>
<a href="https://github.com/paylike/kotlin_sdk/actions/workflows/AssembleOnMain.yml" target="_blank">
<img src="https://github.com/paylike/kotlin_sdk/actions/workflows/AssembleOnMain.yml/badge.svg?branch=main" />
<a href="/../../actions/workflows/AssembleOnMain.yml" target="_blank">
<img src="/../../actions/workflows/AssembleOnMain.yml/badge.svg?branch=main" />
</a>

This library includes the high level components providing complete payment forms to use the Paylike ecosystem.
Expand Down Expand Up @@ -191,7 +191,7 @@ This form provides the simplest implementation of a payment flow.
* webView to help TDS and
* can receive custom theme definition.

Every field has a realtime sanitation and check if its acceptable. Pushing the pay button has a check if every field meets the requirements, if not refuses to trigger the payment flow. If every field exaushted the expected conditions then the payment flow starts, the fields become disabled and the button disappears. The webView appears when necessary, accepts user input to solve TDS, then disappears. This form does not show any sign of feedback about the flow. The navigation to and from the form is up to the developer. In case of any error at any time, the form jumps to the error state, but like success state, does not show any feedback.
Every field has a realtime sanitation and check if its acceptable. Pushing the pay button has a check if every field meets the requirements, if not refuses to trigger the payment flow. If every field exhausted the expected conditions then the payment flow starts, the fields become disabled and the button disappears. The webView appears when necessary, accepts user input to solve TDS, then disappears. This form does not show any sign of feedback about the flow. The navigation to and from the form is up to the developer. In case of any error at any time, the form jumps to the error state, but like success state, does not show any feedback.
Theme has to be defined like built-in MaterialTheme.

The white label view model has UI states what are used only by the Paylike style form.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ spotless {
endWithNewline()
}
}
assemble.dependsOn 'spotlessApply'
build.dependsOn 'spotlessCheck'
2 changes: 1 addition & 1 deletion kotlin_sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ spotless {
endWithNewline()
}
}
assemble.dependsOn 'spotlessApply'
build.dependsOn 'spotlessCheck'

afterEvaluate {
publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ fun ExtendableWhiteLabelComposable(
) {
/** WebView to help TDS flow */
val displayMetrics = DisplayMetrics()
val windowManager = LocalContext.current.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val windowManager =
LocalContext.current.getSystemService(Context.WINDOW_SERVICE) as WindowManager
windowManager.defaultDisplay.getMetrics(displayMetrics)

webView.value.WebViewComposable(modifier = Modifier.fillMaxWidth(1f).height(
displayMetrics.heightPixels.dp / displayMetrics.density * 0.8f
).focusable())
webView.value.WebViewComposable(
modifier =
Modifier.fillMaxWidth(1f)
.height(displayMetrics.heightPixels.dp / displayMetrics.density * 0.8f)
.focusable()
)

/** Extender fields */
if (viewModel.extenderPaymentFormStateList.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.github.paylike.kotlin_sdk.whitelabel.simple.view

import android.app.Activity
import android.content.Context.WINDOW_SERVICE
import android.util.DisplayMetrics
import android.util.Log
import android.view.WindowManager
import androidx.compose.foundation.background
import androidx.compose.foundation.focusable
Expand All @@ -15,7 +13,6 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -58,13 +55,16 @@ fun WhiteLabelComposable(

/** WebView to help TDS flow */
val displayMetrics = DisplayMetrics()
val windowManager = LocalContext.current.getSystemService(WINDOW_SERVICE) as WindowManager
val windowManager =
LocalContext.current.getSystemService(WINDOW_SERVICE) as WindowManager
windowManager.defaultDisplay.getMetrics(displayMetrics)

webView.value.WebViewComposable(modifier = Modifier.fillMaxWidth(1f).height(
displayMetrics.heightPixels.dp / displayMetrics.density * 0.8f
).focusable())

webView.value.WebViewComposable(
modifier =
Modifier.fillMaxWidth(1f)
.height(displayMetrics.heightPixels.dp / displayMetrics.density * 0.8f)
.focusable()
)

/** Form that contains the fields */
SimpleWhiteLabelFormComposable(
Expand Down
20 changes: 20 additions & 0 deletions sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Example Application

The purpose of the example application is to showcase the common use-cases of the SDK.

## Setup

To run the test application you need to add your sandbox public Merchant API Key to the `local.properties` file in the project root:

> Important: Make sure to use a sandbox API Key!

```properties
PaylikeMerchantApiKey="your-key-here"
```

## Usage

After starting the application select a use-case from the list, and fill out the form.

You can use test card information to complete the payment forms:
`4012 1111 1111 1111` with any valid expiry (eg.: `11/25`) and CVC.
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ spotless {
endWithNewline()
}
}
assemble.dependsOn 'spotlessApply'
build.dependsOn 'spotlessCheck'
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.ArrowDropDown
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.rotate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.paylike.sample.viewmodel

import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
Expand Down Expand Up @@ -58,7 +57,6 @@ class SampleViewModel : ViewModel() {
mutableStateOf(Pair("Unsupported card scheme", errorCases["Unsupported card scheme"]!!))

private fun onPaymentTestDtoEntryChanged(newValue: Pair<String, PaymentTestDto>) {
Log.d("hello", "onchanged")
paymentTestDtoEntry = newValue
}

Expand Down