Skip to content

Commit

Permalink
Element flow theme color sample added
Browse files Browse the repository at this point in the history
  • Loading branch information
kishan-cashfree committed May 10, 2024
1 parent 90541ba commit 5234c18
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/cashfree/sdk_sample/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.cashfree.pg.core.api.upi.CFUPI

data class Config(
// CFSession Inputs
val orderID: String = "ORDER_ID",
val paymentSessionID: String = "PAYMENT_SESSION_ID",
val orderID: String = "order_101024392gHOZuJhvg8FrIRarb7Uy6EAChV",
val paymentSessionID: String = "session_pj4qdmmoYVCpDTTeaaKYZMG5yGWMlRQuQIs3CmwXh4w4DPF9Cqr7r96wvEMkiLl9Bmu_pg8HJSv2cWyW0XvxklmnosIhfvCE_rRzPxnWHjVr",
val environment: CFSession.Environment = CFSession.Environment.SANDBOX,

//Card Payment Inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.cashfree.pg.api.CFPaymentGatewayService;
import com.cashfree.pg.core.api.CFCorePaymentGatewayService;
import com.cashfree.pg.core.api.CFSession;
import com.cashfree.pg.core.api.CFTheme;
import com.cashfree.pg.core.api.callback.CFCheckoutResponseCallback;
import com.cashfree.pg.core.api.card.CFCard;
import com.cashfree.pg.core.api.card.CFCardPayment;
Expand Down Expand Up @@ -108,10 +109,19 @@ public void doCardPayment(View view) {
.setCardExpiryYear(cardYY)
.setCVV(cardCVV)
.build();
CFTheme theme = new CFTheme.CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build();
CFCardPayment cfCardPayment = new CFCardPayment.CFCardPaymentBuilder()
.setSession(cfSession)
.setCard(cfCard)
.build();
cfCardPayment.setTheme(theme);
CFCorePaymentGatewayService.getInstance().doPayment(ElementCheckoutActivity.this, cfCardPayment);
} catch (CFException exception) {
exception.printStackTrace();
Expand Down Expand Up @@ -160,10 +170,19 @@ public void doCardEMIPayment(View view) {
.setBankName(bankName)
.setEMITenure(emiTenure)
.build();
CFTheme theme = new CFTheme.CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build();
CFEMICardPayment cfCardPayment = new CFEMICardPayment.CFEMICardPaymentBuilder()
.setSession(cfSession)
.setCard(cfCard)
.build();
cfCardPayment.setTheme(theme);
CFCorePaymentGatewayService.getInstance().doPayment(ElementCheckoutActivity.this, cfCardPayment);
} catch (CFException exception) {
exception.printStackTrace();
Expand All @@ -182,10 +201,19 @@ public void doNetBankingPayment(View view) {
CFNetBanking cfNetBanking = new CFNetBanking.CFNetBankingBuilder()
.setBankCode(bankCode)
.build();
CFTheme theme = new CFTheme.CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build();
CFNetBankingPayment cfNetBankingPayment = new CFNetBankingPayment.CFNetBankingPaymentBuilder()
.setSession(cfSession)
.setCfNetBanking(cfNetBanking)
.build();
cfNetBankingPayment.setTheme(theme);
CFCorePaymentGatewayService.getInstance().doPayment(ElementCheckoutActivity.this, cfNetBankingPayment);
} catch (CFException exception) {
exception.printStackTrace();
Expand All @@ -212,10 +240,19 @@ public void doWalletPayment(View view) {
.setProvider(channel)
.setPhone(phone)
.build();
CFTheme theme = new CFTheme.CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build();
CFWalletPayment cfWalletPayment = new CFWalletPayment.CFWalletPaymentBuilder()
.setSession(cfSession)
.setCfWallet(cfWallet)
.build();
cfWalletPayment.setTheme(theme);
CFCorePaymentGatewayService.getInstance().doPayment(ElementCheckoutActivity.this, cfWalletPayment);
} catch (CFException exception) {
exception.printStackTrace();
Expand All @@ -234,10 +271,19 @@ public void doPayLaterPayment(View view) {
.setProvider(payLaterChannel)
.setPhone(phone)
.build();
CFTheme theme = new CFTheme.CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build();
CFPayLaterPayment cfPayLaterPayment = new CFPayLaterPayment.CFPayLaterPaymentBuilder()
.setSession(cfSession)
.setCfPayLater(cfPayLater)
.build();
cfPayLaterPayment.setTheme(theme);
CFCorePaymentGatewayService.getInstance().doPayment(ElementCheckoutActivity.this, cfPayLaterPayment);
} catch (CFException exception) {
exception.printStackTrace();
Expand Down Expand Up @@ -277,10 +323,19 @@ private void initiatePayment(CFUPI.Mode mode, String id) {
.setMode(mode)
.setUPIID(id)
.build();
CFTheme theme = new CFTheme.CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build();
CFUPIPayment cfupiPayment = new CFUPIPayment.CFUPIPaymentBuilder()
.setSession(cfSession)
.setCfUPI(cfupi)
.build();
cfupiPayment.setTheme(theme);
CFCorePaymentGatewayService.getInstance().doPayment(ElementCheckoutActivity.this, cfupiPayment);
} catch (CFException exception) {
exception.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package com.cashfree.sdk_sample.kotlin

import androidx.appcompat.app.AppCompatActivity
import com.cashfree.pg.core.api.callback.CFCheckoutResponseCallback
import com.cashfree.pg.core.api.CFSession
import com.cashfree.pg.core.api.upi.CFUPI
import android.os.Bundle
import com.cashfree.sdk_sample.R
import com.cashfree.pg.api.CFPaymentGatewayService
import com.cashfree.pg.core.api.utils.CFErrorResponse
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.cashfree.pg.api.CFPaymentGatewayService
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.callback.CFCheckoutResponseCallback
import com.cashfree.pg.core.api.card.CFCard.CFCardBuilder
import com.cashfree.pg.core.api.card.CFCardPayment.CFCardPaymentBuilder
import com.cashfree.pg.core.api.CFCorePaymentGatewayService
import com.cashfree.pg.core.api.emicard.CFEMICard.CFEMICardBuilder
import com.cashfree.pg.core.api.emicard.CFEMICardPayment.CFEMICardPaymentBuilder
import com.cashfree.pg.core.api.exception.CFException
import com.cashfree.pg.core.api.netbanking.CFNetBanking.CFNetBankingBuilder
import com.cashfree.pg.core.api.netbanking.CFNetBankingPayment.CFNetBankingPaymentBuilder
import kotlin.Throws
import com.cashfree.pg.core.api.wallet.CFWallet.CFWalletBuilder
import com.cashfree.pg.core.api.wallet.CFWalletPayment.CFWalletPaymentBuilder
import com.cashfree.pg.core.api.paylater.CFPayLater.CFPayLaterBuilder
import com.cashfree.pg.core.api.paylater.CFPayLaterPayment.CFPayLaterPaymentBuilder
import com.cashfree.pg.core.api.upi.CFUPI
import com.cashfree.pg.core.api.upi.CFUPI.CFUPIBuilder
import com.cashfree.pg.core.api.upi.CFUPIPayment.CFUPIPaymentBuilder
import com.cashfree.pg.core.api.utils.CFErrorResponse
import com.cashfree.pg.core.api.wallet.CFWallet.CFWalletBuilder
import com.cashfree.pg.core.api.wallet.CFWalletPayment
import com.cashfree.pg.core.api.wallet.CFWalletPayment.CFWalletPaymentBuilder
import com.cashfree.sdk_sample.Config
import java.lang.IllegalArgumentException
import com.cashfree.sdk_sample.R

class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback {
// Go to https://docs.cashfree.com/docs/31-initiate-payment-native-checkout for the documentation
Expand Down Expand Up @@ -114,10 +114,19 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setCardExpiryYear(cardYY)
.setCVV(cardCVV)
.build()
val theme = CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build()
val cfCardPayment = CFCardPaymentBuilder()
.setSession(cfSession)
.setCard(cfCard)
.build()
cfCardPayment.theme = theme
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfCardPayment)
} catch (exception: CFException) {
Expand Down Expand Up @@ -165,10 +174,19 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setBankName(bankName)
.setEMITenure(emiTenure)
.build()
val theme = CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build()
val cfCardPayment = CFEMICardPaymentBuilder()
.setSession(cfSession)
.setCard(cfCard)
.build()
cfCardPayment.theme = theme
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfCardPayment)
} catch (exception: CFException) {
Expand All @@ -190,6 +208,15 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setSession(cfSession)
.setCfNetBanking(cfNetBanking)
.build()
val theme = CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build()
cfNetBankingPayment.theme = theme
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfNetBankingPayment)
} catch (exception: CFException) {
Expand Down Expand Up @@ -221,6 +248,15 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setSession(cfSession)
.setCfWallet(cfWallet)
.build()
val theme = CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build()
cfWalletPayment.theme = theme
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfWalletPayment)
} catch (exception: CFException) {
Expand All @@ -243,6 +279,15 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setSession(cfSession)
.setCfPayLater(cfPayLater)
.build()
val theme = CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build()
cfPayLaterPayment.theme = theme
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfPayLaterPayment)
} catch (exception: CFException) {
Expand Down Expand Up @@ -286,6 +331,15 @@ class ElementCheckoutActivity : AppCompatActivity(), CFCheckoutResponseCallback
.setSession(cfSession)
.setCfUPI(cfupi)
.build()
val theme = CFThemeBuilder()
.setNavigationBarBackgroundColor("#6A2222")
.setNavigationBarTextColor("#FFFFFF")
.setButtonBackgroundColor("#6Aaaaa")
.setButtonTextColor("#FFFFFF")
.setPrimaryTextColor("#11385b")
.setSecondaryTextColor("#808080")
.build()
cfupiPayment.theme = theme
CFCorePaymentGatewayService.getInstance()
.doPayment(this@ElementCheckoutActivity, cfupiPayment)
} catch (exception: CFException) {
Expand Down

0 comments on commit 5234c18

Please sign in to comment.