From a54ec9ec14a305907d0ae801561dbb70feb0137d Mon Sep 17 00:00:00 2001 From: Kishan_maurya Date: Wed, 25 Sep 2024 14:23:05 +0530 Subject: [PATCH] Android SDK version update 2.1.21, Native OTP flwo implemented --- app/build.gradle | 17 ++++++------ .../java/com/cashfree/sdk_sample/Config.kt | 6 ++--- .../compose/DropCheckoutActivity.kt | 5 +--- .../java/ElementCheckoutActivity.java | 3 ++- .../kotlin/ElementCheckoutActivity.kt | 27 +++++++++++++++++-- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e38eddc..36313c7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" @@ -29,7 +29,6 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - namespace 'com.cashfree.sdk_sample' kotlinOptions { jvmTarget = '1.8' } @@ -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') @@ -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' } diff --git a/app/src/main/java/com/cashfree/sdk_sample/Config.kt b/app/src/main/java/com/cashfree/sdk_sample/Config.kt index 62aa548..4c738b2 100644 --- a/app/src/main/java/com/cashfree/sdk_sample/Config.kt +++ b/app/src/main/java/com/cashfree/sdk_sample/Config.kt @@ -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", diff --git a/app/src/main/java/com/cashfree/sdk_sample/compose/DropCheckoutActivity.kt b/app/src/main/java/com/cashfree/sdk_sample/compose/DropCheckoutActivity.kt index 5aeeba2..ae18440 100644 --- a/app/src/main/java/com/cashfree/sdk_sample/compose/DropCheckoutActivity.kt +++ b/app/src/main/java/com/cashfree/sdk_sample/compose/DropCheckoutActivity.kt @@ -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") diff --git a/app/src/main/java/com/cashfree/sdk_sample/java/ElementCheckoutActivity.java b/app/src/main/java/com/cashfree/sdk_sample/java/ElementCheckoutActivity.java index 737b8ad..d08a6fe 100644 --- a/app/src/main/java/com/cashfree/sdk_sample/java/ElementCheckoutActivity.java +++ b/app/src/main/java/com/cashfree/sdk_sample/java/ElementCheckoutActivity.java @@ -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") @@ -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(); diff --git a/app/src/main/java/com/cashfree/sdk_sample/kotlin/ElementCheckoutActivity.kt b/app/src/main/java/com/cashfree/sdk_sample/kotlin/ElementCheckoutActivity.kt index a5829ec..78584cf 100644 --- a/app/src/main/java/com/cashfree/sdk_sample/kotlin/ElementCheckoutActivity.kt +++ b/app/src/main/java/com/cashfree/sdk_sample/kotlin/ElementCheckoutActivity.kt @@ -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 @@ -113,6 +114,7 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback .setCardExpiryMonth(cardMM) .setCardExpiryYear(cardYY) .setCVV(cardCVV) + .setChannel("post") .build() val theme = CFThemeBuilder() .setNavigationBarBackgroundColor("#6A2222") @@ -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() } @@ -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) @@ -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) { @@ -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) {