Cashfree.Forms.Payment.SDK
0.9.3
See the version list below for details.
dotnet add package Cashfree.Forms.Payment.SDK --version 0.9.3
NuGet\Install-Package Cashfree.Forms.Payment.SDK -Version 0.9.3
<PackageReference Include="Cashfree.Forms.Payment.SDK" Version="0.9.3" />
paket add Cashfree.Forms.Payment.SDK --version 0.9.3
#r "nuget: Cashfree.Forms.Payment.SDK, 0.9.3"
// Install Cashfree.Forms.Payment.SDK as a Cake Addin #addin nuget:?package=Cashfree.Forms.Payment.SDK&version=0.9.3 // Install Cashfree.Forms.Payment.SDK as a Cake Tool #tool nuget:?package=Cashfree.Forms.Payment.SDK&version=0.9.3
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,
- Create an account with Cashfree and get the API keys.
- Integrate the Cashfree SDK into your application.
- Generate Token (From Backend)
- 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.
- Receive and handle response - Cashfree SDK returns the payment result for the order which should be handled in your application.
- 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
- Go to the Xamarin Forms project and Right Click on Packages and click on Manage NuGet Packages.
- Search for "Cashfree.Forms.Payment.SDK" in browse and select the latest version of the package and click on Add Package.
- 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 inUnable 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 anInvalid 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:-
- 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
- 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:
- InputParams: A map of all the relevant parameters described here
- Token: The token generated here
- Environment: Value should be either "TEST" for testing server, or "PROD" for production server respectively.
- 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[PARAM_PAYMENT_OPTION] = "card";
params[PARAM_CARD_NUMBER] = "4434260000000008";//Replace Card number
params[PARAM_CARD_MM] = "05"; // Card Expiry Month in MM
params[PARAM_CARD_YYYY] = "2021"; // Card Expiry Year in YYYY
params[PARAM_CARD_HOLDER] = "John Doe"; // Card Holder name
params[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[PARAM_PAYMENT_OPTION] = "nb";
params[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[PARAM_PAYMENT_OPTION] = "wallet";
params[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[PARAM_PAYMENT_OPTION = "upi";
params[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[PARAM_PAYMENT_OPTION] = "paypal";
Request and Response Parameters
For request and response parameters check here.
Learn more about Target Frameworks and .NET Standard.
-
Portable Class Library (.NETFramework 4.5, Windows 8.0, WindowsPhoneApp 8.1)
- Xamarin.Forms (>= 4.8.0.1451)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.