Skip to content

Commit

Permalink
Merge pull request #23 from cashfree/task/android_sdk_verison_2.1.21
Browse files Browse the repository at this point in the history
Android SDK version update 2.1.21, Native OTP FLOW implemented
  • Loading branch information
kishan-cashfree authored Sep 25, 2024
2 parents f820551 + a54ec9e commit 575612a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
17 changes: 8 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

android {
compileSdk 33
compileSdk 34

defaultConfig {
applicationId "com.cashfree.pg.demoapp"
namespace 'com.cashfree.sdk_sample'
minSdk 21
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"

Expand All @@ -29,7 +29,6 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.cashfree.sdk_sample'
kotlinOptions {
jvmTarget = '1.8'
}
Expand All @@ -48,11 +47,11 @@ android {

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.2'
implementation platform('androidx.compose:compose-bom:2023.03.00')
Expand All @@ -62,5 +61,5 @@ dependencies {
implementation 'androidx.compose.material3:material3'
testImplementation 'junit:junit:4.13.2'

implementation 'com.cashfree.pg:api:2.1.20'
implementation 'com.cashfree.pg:api:2.1.21'
}
6 changes: 3 additions & 3 deletions app/src/main/java/com/cashfree/sdk_sample/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import com.cashfree.pg.core.api.upi.CFUPI

data class Config(
// CFSession Inputs
val orderID: String = "devstudio_272366234679",
val paymentSessionID: String = "session_XMb4ZaTSh28_jDZUUYCnPunUc7qEG-du57oawTj1kgnqy5lrukxCtk23z5o2WQ12SzExpuSbKJH_U2-R4YRN5l1oL-2jzzuLiHYmu0lY800D",
val orderID: String = "order_101024392mYVEm8ceFaoMLeqKkvMDKFa5pj",
val paymentSessionID: String = "session_-b_45ThEbGKTYYcW9RbhHFlGrq4gbV2_tmZ9Fz-UsSZnbHO2VBWRnCAAPytxr3AxDj1jB2_KxHZ8ubdmHOkbQOco2TNRwX95YhwQLL-FDMKb",
val environment: CFSession.Environment = CFSession.Environment.SANDBOX,

//Card Payment Inputs
val cardNumber: String = "4585340002077590",
val cardNumber: String = "4706130002077527",
val cardMM: String = "09",
val cardYY: String = "26",
val cardHolderName: String = "John Doe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ class DropCheckoutActivity : ComponentActivity(), CFCheckoutResponseCallback {
.setPaymentSessionID(paymentSessionID)
.setOrderId(orderID)
.build()
// val cfPaymentComponent = CFPaymentComponentBuilder()
// .add(CFPaymentComponent.CFPaymentModes.CARD)
// .add(CFPaymentComponent.CFPaymentModes.UPI)
// .build()

val cfTheme = CFThemeBuilder()
.setNavigationBarBackgroundColor("#006EE1")
.setNavigationBarTextColor("#ffffff")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public void onElementPayClick(View view) {
.setCardExpiryYear(cardYY)
.setCVV(cardCVV)
.setCfCard(true)
.setChannel("post")
.build();
CFTheme theme = new CFTheme.CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
Expand All @@ -193,7 +194,7 @@ public void onElementPayClick(View view) {
* To set Loader UI before order pay network call.
* This is optional for merchants. If they specially want to show UI loader then only enable it.
*/
cfCardPayment.setLoaderEnable(true);
cfCardPayment.setCfSDKFlow(CFPayment.CFSDKFlow.WITH_CASHFREE_FULLSCREEN_LOADER);
cfElementCard.doPayment(ElementCheckoutActivity.this, cfCardPayment);
} catch (CFException exception) {
exception.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.cashfree.pg.core.api.CFCorePaymentGatewayService
import com.cashfree.pg.core.api.CFSession
import com.cashfree.pg.core.api.CFSession.CFSessionBuilder
import com.cashfree.pg.core.api.CFTheme.CFThemeBuilder
import com.cashfree.pg.core.api.base.CFPayment
import com.cashfree.pg.core.api.callback.CFCheckoutResponseCallback
import com.cashfree.pg.core.api.card.CFCard.CFCardBuilder
import com.cashfree.pg.core.api.card.CFCardPayment.CFCardPaymentBuilder
Expand Down Expand Up @@ -113,6 +114,7 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setCardExpiryMonth(cardMM)
.setCardExpiryYear(cardYY)
.setCVV(cardCVV)
.setChannel("post")
.build()
val theme = CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
Expand All @@ -127,8 +129,14 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setCard(cfCard)
.build()
cfCardPayment.theme = theme
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfCardPayment)
/**
* To set Full Screen Loader UI before order pay network call.
* This is optional for merchants. If they specially want to show UI loader then only enable it.
* Note : If Merchant wants to use Native OTP flow in card payment then this is required.
*/

cfCardPayment.cfSDKFlow = CFPayment.CFSDKFlow.WITH_CASHFREE_FULLSCREEN_LOADER
CFCorePaymentGatewayService.getInstance().doPayment(this@ElementCheckoutActivity, cfCardPayment)
} catch (exception: CFException) {
exception.printStackTrace()
}
Expand Down Expand Up @@ -216,6 +224,11 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build()
/**
* To set Loader UI before order pay network call.
* This is optional for merchants. If they specially want to show UI loader then only enable it.
*/
cfNetBankingPayment.cfSDKFlow = CFPayment.CFSDKFlow.WITH_CASHFREE_FULLSCREEN_LOADER
cfNetBankingPayment.theme = theme
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfNetBankingPayment)
Expand Down Expand Up @@ -257,6 +270,11 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setSecondaryTextColor("#808080")
.build()
cfWalletPayment.theme = theme
/**
* To set Loader UI before order pay network call.
* This is optional for merchants. If they specially want to show UI loader then only enable it.
*/
cfWalletPayment.cfSDKFlow = CFPayment.CFSDKFlow.WITH_CASHFREE_FULLSCREEN_LOADER
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfWalletPayment)
} catch (exception: CFException) {
Expand Down Expand Up @@ -288,6 +306,11 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setSecondaryTextColor("#808080")
.build()
cfPayLaterPayment.theme = theme
/**
* To set Loader UI before order pay network call.
* This is optional for merchants. If they specially want to show UI loader then only enable it.
*/
cfPayLaterPayment.cfSDKFlow = CFPayment.CFSDKFlow.WITH_CASHFREE_FULLSCREEN_LOADER
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfPayLaterPayment)
} catch (exception: CFException) {
Expand Down

0 comments on commit 575612a

Please sign in to comment.