Cashfree.AndroidX.Payment.Sdk 1.1.0

There is a newer version of this package available.
See the version list below for details.
Install-Package Cashfree.AndroidX.Payment.Sdk -Version 1.1.0
dotnet add package Cashfree.AndroidX.Payment.Sdk --version 1.1.0
<PackageReference Include="Cashfree.AndroidX.Payment.Sdk" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cashfree.AndroidX.Payment.Sdk --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Cashfree.AndroidX.Payment.Sdk, 1.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Cashfree.AndroidX.Payment.Sdk as a Cake Addin
#addin nuget:?package=Cashfree.AndroidX.Payment.Sdk&version=1.1.0

// Install Cashfree.AndroidX.Payment.Sdk as a Cake Tool
#tool nuget:?package=Cashfree.AndroidX.Payment.Sdk&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Xamarin Android SDK

The Cashfree Xamarin Android SDK allows you to integrate Cashfree Payment Gateway into your application and start collecting payments from your customers.


The Cashfree SDK has been designed to minimise the complexity of handling and integrating payments in your application. The Cashfree Xamarin Android SDK is available at the Nuget Gallery as a nuget package.


Integration Steps

To integrate Cashfree Xamarin Android SDK with your Android application,

  1. Create an account with Cashfree and get the API keys.
  2. Integrate the Cashfree SDK into your application.
  3. Generate Token (From Backend)
  4. Initiate payment - Invoke a payment API from the Cashfree SDK with the token generated when the customer initiates payment for an order from your application. Cashfree SDK displays appropriate screens to the customer for the payment.
  5. Receive and handle response - Cashfree SDK returns the payment result for the order which should be handled in your application.
  6. Verify response - We recommend you to verify the payment response using webhooks and by checking the signature value returned in the payment response.

Initiate Payment

After generating the order token, the payment gets initiated when the payment API is called DoPayment.

For payment, your application passes the order info and the cftoken to the SDK. The relevant payment screen is displayed to the customer where they enter the required information and make the payment. After the payment is complete the customers are redirected to the Android application and response is received on OnActivityResult()

NOTE: The order details passed during the token generation and the payment initiation should match. Else, you will get an Invalid order details error. Wrong appId and token will result in Unable to authenticate merchant error. The token generated for payment is valid for 5 minutes within which the payment has to be initiated. Else, you will get an Invalid token error.

Receive and Handle Response

After the payment is complete you will receive the response on the onActivityResult() function of the invoking activity. In the intent extras, you will receive a set of response parameters which is used to determine if the transaction was successful or not. Request code will always be equal to CFPaymentService.REQ_CODE.

protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) 
{ 
    base.OnActivityResult(requestCode, resultCode, data);
    if (data != null) 
    {  
        String dataString = data.DataString;
        if (dataString != null) 
        { 
            // do your payment verification here using dataString
        } 
    } 
}

Web Checkout

Web Checkout is the standard flow for Cashfree Cordova SDK. In this flow, the SDK loads a webview which will render the payment page. The customer can fill the required payment details here and complete the payment. The Web Checkout can be used in two ways:-

  1. Web Checkout with Cashfree UI: Customer selects the payment mode and enters the payment details within the Cashfree's web payment page to complete the payment
  2. Seamless Web Checkout: Customer selects the payment mode and enters payment details in your application. These details are then passed on to the Cashfree SDK. Webview is launched only for scenarios like the two-factor authentication.

NOTE: Web checkout supports payment through Google pay, Amazon pay, PhonePe and UPI payment modes.

Web Checkout Using Cashfree UI

Web checkout uses webview to process payment hence the name. For both Web Checkout and Seamless Web Checkout you need to invoke the DoPayment(). method. However, there are a few extra parameters you need to pass for seamless integration method.

DoPayment: Add this package in your class. using Com.Cashfree.PG;

CFPaymentService.CFPaymentServiceInstance.DoPayment(Context context, Dictionary<String, String> params, String token, String stage);

Initiates the payment in a webview. The customer will be taken to the payment page on the Cashfree server where they have the option to pay through any payment option that is activated on their account. Once the payment is done the webview will close and the response will be delivered in the OnActivityResult().

Parameters:

  1. Context: Context of the calling activity.
  2. Params: A map of all the relevant parameters described here
  3. Token: The token generated here
  4. Environment: Value should be either "TEST" for testing server, or "PROD" for production server respectively.
CFPaymentService.CFPaymentServiceInstance.DoPayment(Context context, Dictionary<String, String> params, String token, String stage, String color1, String color2)

Additional Parameters:

  1. color1: Toolbar background color.
  2. color2: Toolbar text and back arrow color.

If you want to hide the order ID, add another parameter hideOrderID as shown below:

CFPaymentService.CFPaymentServiceInstance.DoPayment(Context context, Dictionary<String, String> params, 
String token, String stage, bool hideOrderId)

If you want to customise the toolbar colour and also hide the order ID in the toolbar, add the parameters as shown below:

CFPaymentService.CFPaymentServiceInstance.DoPayment(Context context, Dictionary<String, String> params, 
String token, String stage, String color1, String color2, 
bool hideOrderId)

Seamless Integration

When you have a requirement for a customised payment flow, you can use the seamless integration. You can implement the payment page as per your requirement and then use our SDK to authorise the payment. Once the payment details are collected the OTP or the two-factor authentication page will open in a webview. After the payment is confirmed the webview closes and you will receive a response.

Click here for more details.

Other Common SDK Functions

SetOrientation

Choose the orientation (portrait or landscape) of the payment page. By default the payment page is shown in portrait orientation.

public void setOrientation(Context context, int val)

Parameters

  1. val: If the integer value is zero the orientation will be in portrait mode. Else, it will be landscape mode.
  2. context: Context of the calling activity.
SetConfirmOnExit

By default, a confirmation dialog is displayed when the users press back in the payment screen. You have the option to disable the confirmation dialog.

public void setConfirmOnExit(Context context, bool confirmOnExit)

Parameters

  1. context: Context of the calling activity.
  2. confirmOnExit: Value should be true if you want to show a confirmation popup on pressing back in the payment screen.

Request and Response Parameters

Click here for request and response parameters.

  • MonoAndroid 9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 121 6/6/2021
1.2.0 76 4/21/2021
1.1.0 169 11/25/2020
1.0.0 134 10/25/2020