Cashfree.Forms.Payment.SDK 0.9.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Cashfree.Forms.Payment.SDK --version 0.9.0                
NuGet\Install-Package Cashfree.Forms.Payment.SDK -Version 0.9.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cashfree.Forms.Payment.SDK" Version="0.9.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cashfree.Forms.Payment.SDK --version 0.9.0                
#r "nuget: Cashfree.Forms.Payment.SDK, 0.9.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Cashfree.Forms.Payment.SDK as a Cake Addin
#addin nuget:?package=Cashfree.Forms.Payment.SDK&version=0.9.0

// Install Cashfree.Forms.Payment.SDK as a Cake Tool
#tool nuget:?package=Cashfree.Forms.Payment.SDK&version=0.9.0                

Xamarin Forms SDK

The Cashfree Xamarin Forms 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 Forms SDK is available at the Nuget Gallery as a nuget package.


Integration Steps

To integrate Cashfree Xamarin Forms SDK with your Forms 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.

Integrate SDK

  1. Go to the Xamarin Forms project and Right Click on Packages and click on Manage NuGet Packages.
  2. Search for "Cashfree.Forms.Payment.SDK" in browse and select the latest version of the package and click on Add Package.
  3. Also Add the Following Dependencies to the same project. • Xamarin.Forms;

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 Forms application and response is received on IPaymentResult implementation.

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 IPaymentResult.OnComplete() function of the invoking Screen. In the result string, you will receive a set of response parameters which is used to determine if the transaction was successful or not.

public void OnComplete(string result)
{
    // verify the transaction here.
}

Web Checkout

Web Checkout is the standard flow for Cashfree Xamarin Forms 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;

DoPayment(Dictionary<string, string> InputParams, string Token, string Environment, IPaymentResult Result);

Returns a ContentPage which opens 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 IPaymentResult.OnComplete().

Parameters:

  1. InputParams: A map of all the relevant parameters described here
  2. Token: The token generated here
  3. Environment: Value should be either "TEST" for testing server, or "PROD" for production server respectively.
  4. Result: IPaymentResult implementation.

Example:

var page = CFPaymentService.DoPayment(Params, Token, Environment, this);
if (page != null)
{
  await Navigation.PushAsync(page);
}

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.

We recommend that you use Checkout integration method unless you are certain that you require a customised payment flow.

The following sections describe the additional parameters for each of the payment methods:

Credit/Debit Card Add the following parameters to the params map before invoking DoPayment() method to initiate a seamless card transaction.

params.put(PARAM_PAYMENT_OPTION, "card");
params.put(PARAM_CARD_NUMBER, "4434260000000008");//Replace Card number
params.put(PARAM_CARD_MM, "05"); // Card Expiry Month in MM
params.put(PARAM_CARD_YYYY, "2021"); // Card Expiry Year in YYYY
params.put(PARAM_CARD_HOLDER, "John Doe"); // Card Holder name
params.put(PARAM_CARD_CVV, "123"); // Card CVV

Net Banking Add the following parameters to the params map before invoking DoPayment() method to initiate a seamless net banking transaction. All valid bank codes are available here.

params.put(PARAM_PAYMENT_OPTION, "nb");
params.put(PARAM_BANK_CODE, "3333");// Put correct bank code here

Wallet Add the following parameters to the params map before invoking DoPayment() method to initiate a seamless wallet transaction. All valid wallet codes are available here.

params.put(PARAM_PAYMENT_OPTION, "wallet");
params.put(PARAM_BANK_CODE, "4001");// Put correct wallet code here

UPI Add the following parameters to the params map before invoking DoPayment() method to initiate a seamless UPI transaction.

params.put(PARAM_PAYMENT_OPTION, "upi");
params.put(PARAM_UPI_VPA, "testsuccess@gocash");// Put correct upi vpa here

Paypal Add the following parameters to params map before invoking DoPayment() method to initiate a seamless Paypal transaction.

params.put(PARAM_PAYMENT_OPTION, "paypal");

Request and Response Parameters

For request and response parameters check here.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • Portable Class Library (.NETFramework 4.5, Windows 8.0, WindowsPhoneApp 8.1)

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.0.0 775 12/29/2020
0.9.3 454 11/30/2020
0.9.2 430 10/23/2020
0.9.0 477 10/7/2020