Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsSudby committed Nov 3, 2022
0 parents commit a1c232c
Show file tree
Hide file tree
Showing 78 changed files with 2,039 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
.idea/
gradle/wrapper/gradle-wrapper.properties
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
55 changes: 55 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-parcelize'
id 'kotlin-kapt'
}

android {
compileSdk 33

defaultConfig {
applicationId "payselection.payments.demo"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0." + versionCode
}

buildTypes {
release {
minifyEnabled 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 "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation "com.google.android.material:material:1.6.1"

//retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$retrofitCoroutinesVersion"
implementation "com.squareup.okhttp3:okhttp:$okHttp3Version"
implementation "com.squareup.okhttp3:logging-interceptor:$okHttp3Version"

// dagger2
implementation "com.google.dagger:dagger:$dagger2Version"
implementation "com.google.dagger:dagger-android:$dagger2Version"
implementation "com.google.dagger:dagger-android-support:$dagger2Version"
kapt "com.google.dagger:dagger-compiler:$dagger2Version"
kapt "com.google.dagger:dagger-android-processor:$dagger2Version"

implementation project(path: ':sdk')
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
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
27 changes: 27 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="payselection.demo">

<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.PaymentsSdk"
tools:targetApi="31">
<activity
android:name="payselection.demo.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>
132 changes: 132 additions & 0 deletions app/src/main/java/payselection/demo/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package payselection.demo

import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import payselection.payments.sdk.PaySelectionPaymentsSdk
import payselection.payments.sdk.configuration.SdkConfiguration
import payselection.payments.sdk.models.requests.confirm.ConfirmData
import payselection.payments.sdk.models.requests.pay.CardDetails
import payselection.payments.sdk.models.requests.pay.PaymentData
import payselection.payments.sdk.models.requests.pay.TransactionDetails
import payselection.payments.sdk.models.requests.refund.RefundData

class MainActivity : AppCompatActivity() {

lateinit var sdk: PaySelectionPaymentsSdk

private val handler = CoroutineExceptionHandler { context, exception ->
Toast.makeText(application, "Caught $exception", Toast.LENGTH_LONG).show()
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

sdk = PaySelectionPaymentsSdk.getInstance(
SdkConfiguration(
"046fdb81fc698b90dd12f005bc399208fd01bb3225e962d58e115c86d905c5f2144cb5dfe2a30868fdf165a5010de46235a248c645b657c046038466537b01f1d6",
"20160",
"5ve4wkzTycthTKut",
true
)
)

GlobalScope.launch(handler) {
val orderId = "234574"
val transactionId = "PS00000300026126"
testPay(orderId)
// testGetOrderStatus(orderId)
// testGetTransaction(transactionId)
// testRefund(transactionId)
// testRefund(orderId, transactionId)
}
}

suspend fun testPay(orderId: String) {
sdk.pay(
orderId = orderId,
description = "test payment",
paymentData = PaymentData.create(
transactionDetails = TransactionDetails(
amount = "100",
currency = "RUB"
),
cardDetails = CardDetails(
cardholderName = "TEST CARD",
cardNumber = "4111111111111111",
cvc = "123",
expMonth = "12",
expYear = "24"
)
)
).proceedResult(
success = {
println("Result $it")
},
error = {
it.printStackTrace()
}
)
}

suspend fun testGetOrderStatus(orderId: String) {
sdk.getOrderStatus(orderId).proceedResult(
success = {
println("Result $it")
},
error = {
it.printStackTrace()
}
)
}

suspend fun testGetTransaction(transactionId: String) {
sdk.getTransaction(transactionId).proceedResult(
success = {
println("Result $it")
},
error = {
it.printStackTrace()
}
)
}

suspend fun testRefund(transactionId: String) {
sdk.refund(
refundData = RefundData(
transactionId = transactionId,
amount = "100",
currency = "RUB"
)
).proceedResult(
success = {
println("Result $it")
},
error = {
it.printStackTrace()
}
)
}

suspend fun testConfirm(orderId: String, transactionId: String) {
sdk.confirm(
confirmData = ConfirmData(
transactionId = transactionId,
orderId = orderId,
paRes = "string",
MD = "string"
)
).proceedResult(
success = {
println("Result $it")
},
error = {
it.printStackTrace()
}
)
}
}
30 changes: 30 additions & 0 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
Loading

0 comments on commit a1c232c

Please sign in to comment.