### Interactive Setup for PG Skills Source: https://www.cashfree.com/docs/tools-ai/cashfree-agent-skills Run the tool interactively to add Payment Gateway (PG) skills. This is the simplest way to get started. ```bash npx @cashfreepayments/agent-skills add pg ``` -------------------------------- ### Full subscription checkout implementation Source: https://www.cashfree.com/docs/payments/subscription/subscription_checkout_flutter_sdk A complete example demonstrating the integration of session creation, theme setup, and payment execution within a Flutter widget. ```dart import 'package:flutter/material.dart'; import 'package:flutter_cashfree_pg_sdk/api/cferrorresponse/cferrorresponse.dart'; import 'package:flutter_cashfree_pg_sdk/api/cfpayment/cfsubscriptioncheckoutpayment.dart'; import 'package:flutter_cashfree_pg_sdk/api/cfpaymentgateway/cfpaymentgatewayservice.dart'; import 'package:flutter_cashfree_pg_sdk/api/cfsession/cfsubssession.dart'; import 'package:flutter_cashfree_pg_sdk/api/cftheme/cftheme.dart'; import 'package:flutter_cashfree_pg_sdk/utils/cfenums.dart'; import 'package:flutter_cashfree_pg_sdk/utils/cfexceptions.dart'; class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override State createState() => _MyAppState(); } class _MyAppState extends State { var cfPaymentGatewayService = CFPaymentGatewayService(); CFEnvironment environment = CFEnvironment.SANDBOX; @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Plugin example app'), ), body: Center( child: Column( children: [ TextButton( onPressed: () => susbcriptionCheckout(), child: const Text("Subscription Web Checkout Flow")), ], ), ), ), ); } susbcriptionCheckout() async { try { cfPaymentGatewayService.setCallback(onSubscriptionVerify, onSubscriptionFailure); var subsriptionSession = CFSubscriptionSessionBuilder() .setEnvironment(environment) .setSubscriptionId(subscriptionId) .setSubscriptionSessionId(subscriptionSessionId) .build(); var theme = CFThemeBuilder() .setNavigationBarBackgroundColorColor("#ffffff") .setNavigationBarTextColor("#ffffff") .build(); var cfsubscriptionCheckout = CFSubscriptionPaymentBuilder() .setSession(subsriptionSession) .setTheme(theme) .build(); cfPaymentGatewayService.doPayment(cfsubscriptionCheckout); } on CFException catch (e) { print(e.message); } } void onSubscriptionVerify(String subscriptionId) { print("Verify Subscription ===> $subscriptionId"); } void onSubscriptionFailure(CFErrorResponse errorResponse, String data) { print(errorResponse.getMessage()); } } ``` -------------------------------- ### Install Cashfree Agent Toolkit Source: https://www.cashfree.com/docs/tools-ai/cashfree-agent-toolkit Install the toolkit package using your preferred Node.js package manager. ```bash npm install @cashfreepayments/agent-toolkit ``` ```bash yarn add @cashfreepayments/agent-toolkit ``` ```bash pnpm add @cashfreepayments/agent-toolkit ``` -------------------------------- ### Install Cashfree Plugin Source: https://www.cashfree.com/docs/tools-ai/cashfree-here Install the @cashfreepayments/cashfree-here package using your preferred package manager. ```bash npm install @cashfreepayments/cashfree-here ``` ```bash yarn add @cashfreepayments/cashfree-here ``` ```bash pnpm add @cashfreepayments/cashfree-here ``` -------------------------------- ### Initial App Setup Prompt Source: https://www.cashfree.com/docs/tools-ai/replit-integration Use this prompt to generate a full-stack electronics store application with integrated payment functionality. ```text Create a Replit full-stack app for an electronics store with: - Product listing (name, image, price) - Add-to-cart functionality - Checkout page with total amount and a Pay Now button - Payments processed using Cashfree Payments ``` -------------------------------- ### Get Beneficiary V2 Success Response Source: https://www.cashfree.com/docs/api-reference/payouts/v2/beneficiary-v2/create-beneficiary-v2 Example of a successful response when retrieving beneficiary details. ```yaml beneficiary_id: JOHN18011343 beneficiary_name: John Doe beneficiary_instrument_details: bank_account_number: '1223334444' bank_ifsc: HDFC0000001 vpa: test@upi beneficiary_contact_details: beneficiary_email: sample@cashfree.com beneficiary_phone: '9876543210' beneficiary_country_code: '+91' beneficiary_address: 177A Bleecker Street beneficiary_city: New York City beneficiary_state: New York beneficiary_postal_code: '560011' beneficiary_status: VERIFIED added_on: '2023-12-04T15:50:00Z' ``` -------------------------------- ### Get Installed UPI Applications Source: https://www.cashfree.com/docs/payments/online/web/custom-checkout-ios Retrieves a list of installed UPI applications on the device. It checks for the presence of common UPI app package identifiers and includes their display name and icon. This function is useful for pre-selecting payment methods. ```swift func getInstalledUPIApplications() -> [[String: String]] { var installedApps = [[String: String]]() let appName = [ [ "displayName": CFConstants.googlePayName, "id": CFConstants.googlePayPackage, "icon": (UIImage(named: "gpay", in: Bundle(for: CFUPIUtils.self), compatibleWith: nil)!).toBase64() ?? "" ], [ "displayName": CFConstants.paytmName, "id": CFConstants.paytmPackage, "icon": (UIImage(named: "paytm", in: Bundle(for: CFUPIUtils.self), compatibleWith: nil)!).toBase64() ?? "" ], [ "displayName": CFConstants.phonePeName, "id": CFConstants.phonePePackage, "icon": (UIImage(named: "phonepe", in: Bundle(for: CFUPIUtils.self), compatibleWith: nil)!).toBase64() ?? "" ], [ "displayName": CFConstants.bhimName, "id": CFConstants.bhimPackage, "icon": (UIImage(named: "bhim", in: Bundle(for: CFUPIUtils.self), compatibleWith: nil)!).toBase64() ?? "" ], [ "displayName": CFConstants.credName, "id": CFConstants.credPackage, "icon": (UIImage(named: "credpay", in: Bundle(for: CFUPIUtils.self), compatibleWith: nil)!).toBase64() ?? "" ] ] for app in appName { let url = app["id"] ?? "" if UIApplication.shared.canOpenURL(URL(string: url)!) { installedApps.append(app) } } return installedApps } ``` -------------------------------- ### Open 1-Click Onboarding (Android) Source: https://www.cashfree.com/docs/api-reference/vrs/v2/1-click-onboarding/1-click-onboarding-sdk Initiate the 1-Click Onboarding SDK with a session ID and the desired environment (TEST or PROD). ```kotlin verificationService.open1ClickOnboarding(sessionId, Environment.TEST) ``` -------------------------------- ### Integrity Prod Setup Error Response Source: https://www.cashfree.com/docs/payments/online/mobile/misc/cashfree_integrity_prod_testing This JSON response indicates that the app installer is not a trusted source, blocking transactions in the production environment. It's typically encountered when apps are not installed from the Play Store or a whitelisted app store. ```json { "message": "com.google.android.packageinstaller is not a trusted source. App should be installed from play store or another whitelisted app store.", "code": "installer_package_not_approved", "type": "feature_not_enabled" } ``` -------------------------------- ### Full subscription integration sample Source: https://www.cashfree.com/docs/payments/subscription/subscription_checkout_cordova_sdk A complete example demonstrating event listeners, callback registration, and payment initiation in a Cordova environment. ```javascript // Wait for the deviceready event before using any of Cordova's device APIs. // See https://cordova.apache.org/docs/en/latest/cordova/events/events.html#deviceready document.addEventListener('deviceready', onDeviceReady, false); const SESSION_ID = 'sub_session_f-e0jnzQa_qQtkFtPZmWmxj1We1Tu5f76DImA4ySE5CklsjjJVTiGbyTGxGM-ZKLUJV8-ft2SBYRmws180vI-nivXWq56qJhfY75AIjY823dgn1bLGUADSgZ1yqN_6spayment' // payment_session_id const ORDER_ID = 'devstudio_subs_7358099936054719343' // order_id const ENV = "SANDBOX" // "SANDBOX" or "PRODUCTION" function onDeviceReady() { console.log('Running cordova-' + cordova.platformId + '@' + cordova.version); let subscriptionElement = document.getElementById("onSubscription"); subscriptionElement.addEventListener("click", (e) => initiateSubscriptionPayment()); const callbacks = { onVerify: function (result) { console.log("Payment Verify: " + JSON.parse(JSON.stringify(result))); }, onError: function (error){ console.log("Payment Error: " + JSON.parse(JSON.stringify(error))); } } CFPaymentGateway.setCallback(callbacks) } function initiateSubscriptionPayment() { var cfSubscriptionPayment = { "session": { "subscription_session_id": SESSION_ID, "subscription_id": ORDER_ID, "environment": ENV } } CFPaymentGateway.doSubscriptionPayment(cfSubscriptionPayment) } ``` -------------------------------- ### iOS SDK Initialization and Usage Source: https://www.cashfree.com/docs/api-reference/vrs/v2/video-kyc/vkyc-integration Initialize the service, define callback handlers, and start the verification session. ```swift let kycService = CFVerificationService.getInstance() ``` ```swift func onVerificationCompletion(verificationResponse: KycVerificationSdk.CFVerificationResponse) { if verificationResponse.status == "SUCCESS" { print("Success: Verification successful") } else { print("Error: Verification failed, please try again") } } func onErrorResponse(errorReponse: KycVerificationSdk.CFErrorResponse) { print("Error: \(errorReponse.message ?? "")") } func onVerification(_ verificationResponse: KycVerificationSdk.CFSecureShareResponse) { print("Verification ID: \(verificationResponse.verificationId ?? "N/A")") } func onVerificationError(_ errorResponse: KycVerificationSdk.CFSecureShareErrorResponse) { print("Error Status: \(errorResponse.status ?? "N/A")") } func onUserDrop(_ userDropResponse: KycVerificationSdk.CFUserDropResponse) { print("User Dropped: \(userDropResponse.verificationId ?? "N/A")") } func onVkycCloseResponse(verificationResponse: KycVerificationSdk.CFVKycCloseResponse) { print("VKYC Closed") } ``` ```swift do { let kycService = CFVerificationService.getInstance() try kycService.doVerification(kycUrl, self, self, accessToken) } catch let error { print("Error: \(error)") } ``` -------------------------------- ### Verify Webhook Signature in Python Source: https://www.cashfree.com/docs/api-reference/payments/latest/utilities/incidents/incident-webhook Verify webhook signatures in a Python application using the 'cashfree-pg' library. This example assumes a Flask framework setup. ```python from cashfree_pg.api_client import Cashfree @app.route('/webhook', methods = ['POST']) def disp(): # Get the raw body from the request raw_body = request.data # Decode the raw body bytes into a string decoded_body = raw_body.decode('utf-8') #verify_signature timestamp = request.headers['x-webhook-timestamp'] signature = request.headers['x-webhook-signature'] cashfree = Cashfree() cashfree.XClientId = "" cashfree.XClientSecret = "" try: cashfreeWebhookResponse = cashfree.PGVerifyWebhookSignature(signature, decoded_body, timestamp) except: # If Signature mis-match ``` -------------------------------- ### Web SDK HTML Setup Source: https://www.cashfree.com/docs/api-reference/vrs/v2/video-kyc/vkyc-integration Include the SDK script and the required container div in your HTML file. ```html Video KYC
``` -------------------------------- ### Fetch Order Status with PHP SDK Source: https://www.cashfree.com/docs/payments/online/mobile/flutter Use the PHP SDK to get order information. This example includes basic error handling for the API call. ```php $x_api_version = "2023-08-01"; try { $response = $cashfree->PGFetchOrder($x_api_version, ""); print_r($response); } catch (Exception $e) { echo 'Exception when calling PGFetchOrder: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Create an Order using Cashfree SDKs Source: https://www.cashfree.com/docs/payments/online/mobile/flutter Initialize the Cashfree client with your credentials and environment, then use the PGCreateOrder method to generate an order. ```javascript import { Cashfree, CFEnvironment } from "cashfree-pg"; const cashfree = new Cashfree( CFEnvironment.PRODUCTION, "{Client ID}", "{Client Secret Key}" ); function createOrder() { var request = { order_amount: "1", order_currency: "INR", customer_details: { customer_id: "node_sdk_test", customer_name: "", customer_email: "example@gmail.com", customer_phone: "9999999999", }, order_meta: { return_url: "https://test.cashfree.com/pgappsdemos/return.php?order_id=order_123", }, order_note: "", }; cashfree .PGCreateOrder(request) .then((response) => { var a = response.data; console.log(a); }) .catch((error) => { console.error("Error setting up order request:", error.response.data); }); } ``` ```python from cashfree_pg.models.create_order_request import CreateOrderRequest from cashfree_pg.api_client import Cashfree from cashfree_pg.models.customer_details import CustomerDetails Cashfree.XClientId = {Client ID} Cashfree.XClientSecret = {Client Secret Key} Cashfree.XEnvironment = Cashfree.XSandbox x_api_version = "2023-08-01" def create_order(): customerDetails = CustomerDetails(customer_id="123", customer_phone="9999999999") createOrderRequest = CreateOrderRequest(order_amount=1, order_currency="INR", customer_details=customerDetails) try: api_response = Cashfree().PGCreateOrder(x_api_version, createOrderRequest, None, None) print(api_response.data) except Exception as e: print(e) ``` ```java import com.cashfree.*; Cashfree.XClientId = {Client Key}; Cashfree.XClientSecret = {Client Secret Key}; Cashfree.XEnvironment = Cashfree.SANDBOX; static void createOrder() { CustomerDetails customerDetails = new CustomerDetails(); customerDetails.setCustomerId("123"); customerDetails.setCustomerPhone("9999999999"); CreateOrderRequest request = new CreateOrderRequest(); request.setOrderAmount(1.0); request.setOrderCurrency("INR"); request.setCustomerDetails(customerDetails); try { Cashfree cashfree = new Cashfree(); ApiResponse response = cashfree.PGCreateOrder("2023-08-01", request, null, null, null); System.out.println(response.getData().getOrderId()); } catch (ApiException e) { throw new RuntimeException(e); } } ``` ```go import ( cashfree "github.com/cashfree/cashfree-pg/v3" ) func createOrder() { clientId := {Client ID} clientSecret := {Client Secret Key} cashfree.XClientId = &clientId cashfree.XClientSecret = &clientSecret cashfree.XEnvironment = cashfree.SANDBOX request := cashfree.CreateOrderRequest{ OrderAmount: 1, CustomerDetails: cashfree.CustomerDetails{ CustomerId: "1", CustomerPhone: "9999999999", }, OrderCurrency: "INR", OrderSplits: []cashfree.VendorSplit{}, } version := "2023-08-01" response, httpResponse, err := cashfree.PGCreateOrder(&version, &request, nil, nil, nil) if err != nil { fmt.Println(err.Error()) } else { fmt.Println(httpResponse.StatusCode) fmt.Println(response) } } ``` ```csharp using cashfree_pg.Client; using cashfree_pg.Model; Cashfree.XClientId = {Client ID}; Cashfree.XClientSecret = {Client Secret Key}; Cashfree.XEnvironment = Cashfree.PRODUCTION; var cashfree = new Cashfree(); var xApiVersion = "2023-08-01"; void CreateOrder() { var customerDetails = new CustomerDetails("123", null, "9999999999"); var createOrdersRequest = new CreateOrderRequest(null, 1.0, "INR", customerDetails); try { // Create Order var result = cashfree.PGCreateOrder(xApiVersion, createOrdersRequest, null, null, null); Console.WriteLine(result); Console.WriteLine(result.StatusCode); Console.WriteLine((result.Content as OrderEntity)); } catch (ApiException e) { Console.WriteLine("Exception when calling PGCreateOrder: " + e.Message); Console.WriteLine("Status Code: " + e.ErrorCode); Console.WriteLine(e.StackTrace); } } ``` ```php \Cashfree\Cashfree::$XClientId = ""; \Cashfree\Cashfree::$XClientSecret = ""; \Cashfree\Cashfree::$XEnvironment = Cashfree\Cashfree::$SANDBOX; $cashfree = new \Cashfree\Cashfree(); $x_api_version = "2023-08-01"; $create_orders_request = new \Cashfree\Model\CreateOrdersRequest(); ``` -------------------------------- ### Initiate 1-Click Onboarding (iOS) Source: https://www.cashfree.com/docs/api-reference/vrs/v2/1-click-onboarding/1-click-onboarding-sdk Initiate the 1-Click Onboarding SDK, providing the session ID, environment, and delegate objects. This operation can throw a VerificationError. ```swift do { let environment = Environment.PROD try kycService.open1ClickOnboarding(sessionId, environment, self, self) } catch let e { let error = e as! VerificationError print(error) } ``` -------------------------------- ### Get Orders for a Payment Link Response Source: https://www.cashfree.com/docs/payments/no-code/payment-link Example JSON response containing a list of orders for a given payment link. Each order includes its status, amount, and time. ```json { "link_id": "link_123", "orders": [ { "order_id": "order_001", "order_status": "PAID", "order_amount": 100.00, "order_currency": "INR", "order_time": "2023-10-01T12:10:00+05:30" }, { "order_id": "order_002", "order_status": "FAILED", "order_amount": 100.00, "order_currency": "INR", "order_time": "2023-10-01T12:15:00+05:30" } ] } ``` -------------------------------- ### Update Vendor Request - Auto Collect Source: https://www.cashfree.com/docs/api-reference/payments/latest/split/vendors/update Use this payload for vendors using the auto-collect feature via UPI. This example focuses on essential fields for auto-collect setup. ```json { "name": "john", "email": "john.s@cashfree.com", "phone": "9600176784", "upi": { "vpa": "number@paytm", "account_holder": "holder" }, "kyc_details": { "account_type": "BUSINESS", "business_type": "NBFC", "uidai": "753624181019", "gst": "11AAAAA1111A1Z0", "cin": "L00000Aa0000AaA000000", "pan": "BIAPA2934N", "passport_number": "L6892603" } } ``` -------------------------------- ### Create Subscription using Java (OkHttpClient) Source: https://www.cashfree.com/docs/payments/subscription/hosted-checkout This Java snippet shows the initial setup for creating a subscription using OkHttpClient. It defines the media type for JSON. You will need to complete the request body and execution. ```java OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json"); ``` -------------------------------- ### Initialize Cashfree SDK in PHP Source: https://www.cashfree.com/docs/payments/online/mobile/cordova This PHP snippet shows the initialization of the Cashfree SDK, including setting client ID, secret key, and environment. It prepares the necessary objects for creating an order. ```php \Cashfree\Cashfree::$XClientId = ""; \Cashfree\Cashfree::$XClientSecret = ""; \Cashfree\Cashfree::$XEnvironment = Cashfree\Cashfree::$SANDBOX; $cashfree = new \Cashfree\Cashfree(); $x_api_version = "2023-08-01"; $create_orders_request = new \Cashfree\Model\CreateOrdersRequest(); ``` -------------------------------- ### Retrieve Order Payments via OpenAPI Source: https://www.cashfree.com/docs/api-reference/payments/latest/payments/get-payments-for-order This YAML snippet defines the OpenAPI specification for the GET /orders/{order_id}/payments endpoint, including the schema and example response for card payments. ```yaml openapi: 3.0.0 info: version: '2025-01-01' title: Cashfree Payment Gateway APIs license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html contact: email: developers@cashfree.com name: API Support url: https://discord.com/invite/QdZkNSxXsB description: >- Cashfree's Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites. servers: - url: https://sandbox.cashfree.com/pg description: Sandbox server. - url: https://api.cashfree.com/pg description: Production server. security: [] tags: - name: Orders description: Collection of APIs to handle orders. - name: Payments description: Collection of APIs to handle payments. - name: Refunds description: Collection of APIs to handle refunds. - name: Settlements description: Collection of APIs to handle settlements. - name: Payment Links description: Collection of APIs to handle payment links. - name: Token Vault description: >- Collection of APIs to use Cashfree's token Vault. This helps you save cards and tokenize them in a PCI complaint manner. We support creation of network tokens which can be used across acquiring banks. - name: softPOS description: Collection of APIs to manage softPOS' agent and order. - name: Offers description: Collection of APIs to handle offers. - name: Eligibility description: >- Collection of APIs to check eligibile entities - payment methods, offer, affordibility. - name: Settlement Reconciliation description: Collection of APIs to handle settlements. - name: PG Reconciliation description: Collection of APIs to handle reconciliation. - name: Customers description: Collection of APIs to handle customers. - name: Easy-Split description: Collection of APIs to handle Easy-Split. - name: Simulation description: Collection of APIs to handle simulation. - name: Disputes description: Collection of APIs to handle disputes. - name: Utilities description: Collection of APIs for utility requirement. - name: Downtimes description: Collection of APIs for managing downtimes. externalDocs: url: https://api.cashfree.com/pg description: This url will have the information of all the APIs. paths: /orders/{order_id}/payments: get: tags: - Payments summary: Get Payments for an Order description: Use this API to view all payment details for an order. operationId: PGOrderFetchPayments parameters: - $ref: '#/components/parameters/apiVersionHeader' - $ref: '#/components/parameters/xRequestIDHeader' - $ref: '#/components/parameters/orderIDParam' - $ref: '#/components/parameters/xIdempotencyKeyHeader' responses: '200': description: Success response for viewing all payment details for an order. content: application/json: schema: type: array items: $ref: '#/components/schemas/PaymentEntity' examples: upi: $ref: '#/components/examples/payments_entity_list_example' card: value: - auth_id: '749842' authorization: null bank_reference: '519615460937' cf_payment_id: '4128924251' entity: payment error_details: null international_payment: international: false is_captured: true order_amount: 1 order_currency: INR order_id: order_18482zuD6LhQGYO3OOihGjnlDV4OzpD payment_amount: 1 payment_completion_time: '2025-07-15T15:02:48+05:30' payment_currency: INR payment_gateway_details: gateway_name: CASHFREE gateway_order_id: null gateway_payment_id: null gateway_order_reference_id: null gateway_status_code: null gateway_settlement: cashfree gateway_reference_name: null payment_group: debit_card payment_message: Transaction Success payment_method: card: card_bank_name: KOTAK MAHINDRA BANK card_country: IN card_network: visa card_network_reference_id: null card_number: XXXXXXXXXXXX4738 ``` -------------------------------- ### Create Subscription Request in Go Source: https://www.cashfree.com/docs/payments/subscription/hosted-checkout This Go program demonstrates how to create a subscription using the http package. It sets up the request URL, payload, and headers. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://sandbox.cashfree.com/pg/subscriptions" payload := strings.NewReader("{\"customer_details\":{\"customer_name\":\"Sushane Yadav\",\"customer_email\":\"sushane.yadav@abc.com\",\"customer_phone\":\"9999999999\",\"customer_bank_account_holder_name\":\"Sushane Yadav\",\"customer_bank_account_number\":\"010080198715\",\"customer_bank_ifsc\":\"ICIC0001008\",\"customer_bank_code\":\"ICIC\",\"customer_bank_account_type\":\"SAVINGS\"},\"plan_details\":{\"plan_id\":\"plan_cashfree_sbox\",\"plan_name\":\"Premium_09\",\"plan_type\":\"ON_DEMAND\"},\"authorization_details\":{\"authorization_amount\":1,\"authorization_amount_refund\":true,\"authorization_time\":1},\"subscription_tags\":{\"subscription_note\":\"test create subs\"},\"subscription_meta\":{\"return_url\":\"https://wa.me/8473222?textPayment%20Successfull\",\"notification_channel\":[\"EMAIL\",\"SMS\"]},\"subscription_id\":\"create-ondemand-subs-12\",\"subscription_expiry_time\":\"2028-12-24T14:15:22Z\"}") eq, _ := http.NewRequest("POST", url, payload) eq.Header.Add("accept", "application/json") eq.Header.Add("content-type", "application/json") eq.Header.Add("x-api-version", "2025-01-01") eq.Header.Add("x-client-id", "xyz") eq.Header.Add("x-client-secret", "abc") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Refund Entity Example Source: https://www.cashfree.com/docs/api-reference/payments/latest/refunds/create Example of a complete refund object. ```APIDOC ## Refund Entity Example ### Description Complete refund object. ### Example Value ```json [ { "cf_payment_id": "918812", "cf_refund_id": "1553338", "refund_id": "REF-123", "order_id": "c6G-QMcbm1848", "entity": "refund", "refund_amount": 100.81, "refund_currency": "INR", "refund_note": "Refund for order #123", "refund_status": "SUCCESS", "refund_type": "MERCHANT_INITIATED", "refund_splits": [], "status_description": "In Progress", "refund_arn": "RF12312", "metadata": null } ] ``` ``` -------------------------------- ### Install Cordova Cashfree PG Plugin Source: https://www.cashfree.com/docs/payments/subscription/subscription_checkout_cordova_sdk Install the Cordova Cashfree PG plugin using npm. Supports installation with the latest tag or for Ionic Cordova projects. ```shell npm install cordova-plugin-cashfree-pg # Or Install with latest tag npm install cordova-plugin-cashfree-pg@latest # Add Plugin cordova plugin add cordova-plugin-cashfree-pg # With Ionic Cordova platform ionic cordova plugin add cordova-plugin-cashfree-pg ``` ```shell # Install with capacitor tag npm install cordova-plugin-cashfree-pg@capacitor # Ionic Capacitor setup # Install Core library (once per project) npm install @awesome-cordova-plugins/core # Install Awesome Cordova Plugins TypeScript wrapper for CashFree PG npm install @awesome-cordova-plugins/cashfree-pg # Update native platform project(s) to include newly added plugin ionic cap sync ``` -------------------------------- ### Initialize Cashfree Payouts SDK in Python Source: https://www.cashfree.com/docs/api-reference/payouts/getting-started-with-payouts-apis Initializes the Payouts SDK with client credentials and a public key. ```python from cashfree_sdk.payouts import Payouts // Initialise the SDK, pass public key for dynamic IP Payouts.init("", "", "PROD", public_key= b'public key') ``` -------------------------------- ### Create Subscription Payment Charge Example Source: https://www.cashfree.com/docs/api-reference/payments/latest/subscription/payment/raise Use this example to create a payment for a subscription, specifying details like amount, schedule, and remarks. Ensure all required fields are populated for a successful charge. ```json { "subscription_id": "test-subscription-id", "payment_id": "test-payment-id", "payment_amount": 10, "payment_schedule_date": "2025-06-01T16:40:00", "payment_remarks": "2nd EMI payment", "payment_type": "CHARGE", "payment_method": { "upi": { "upi_id": "john@upi", "channel": "collect" } } } ``` -------------------------------- ### No Data Found Example Source: https://www.cashfree.com/docs/api-reference/vrs/v2/mobile-360-otp-flow/mobile-360-verify-otp Example response when no data is found for a verification. ```APIDOC ## No Data Found ### Description This response is returned when the requested verification details could not be found. ### Response Example ```json { "value": { "verification_id": "test_verification_id", "reference_id": "123456", "status": "DETAILS_NOT_FOUND", "personal_details": null, "phone_numbers": [], "emails": [], "passport_details": [], "bank_account_details": [], "aadhaar_details": [], "ration_card_details": [], "driving_license_details": [], "voter_details": [], "pan_details": [], "addresses": [], "employment_details": {}, "credit_score": null, "risk_intelligence": null } } ``` ``` -------------------------------- ### GET /remitter/status Source: https://www.cashfree.com/docs/api-reference/vrs/v2/reverse-penny-drop/get-reverse-penny-drop-request-details Use this API to get the details of the created reverse penny drop request by passing reference ID or user ID to check if the validation is complete and get the results. ```APIDOC ## GET /remitter/status ### Description Use this API to get the details of the created reverse penny drop request by passing reference ID or user ID to check if the validation is complete and get the results. ### Method GET ### Endpoint /remitter/status ### Parameters #### Query Parameters - **ref_id** (string) - Optional - It is the unique ID created by Cashfree Payments that you receive in the response of Create Reverse Penny Drop Request API. - **verification_id** (string) - Optional - It is the unique ID created by you to identify the reverse penny drop verification request. ### Response #### Success Response (200) - **GetStatusRpdResponse** (object) - Success response for retreiving the status of RPD request. ``` -------------------------------- ### Configure 1-Click Onboarding Callback (Android) Source: https://www.cashfree.com/docs/api-reference/vrs/v2/1-click-onboarding/1-click-onboarding-sdk Set up a callback to handle verification responses, errors, and user drop events from the 1-Click Onboarding SDK. ```kotlin verificationService.set1ClickOnboardingCallback(object : CF1ClickOnboardingCallback { override fun onVerification(response: CF1ClickOnboardingResponse) { // Handle response } override fun onVerificationError(error: CF1ClickOnboardingErrorResponse) { // Handle error } override fun onUserDrop(error: CFUserDropResponse) { // Handle user drop } }) ``` -------------------------------- ### Error Handling Examples Source: https://www.cashfree.com/docs/api-reference/vrs/v2/digilocker/create-digilocker-url Examples of various error responses that can be returned by the API. ```APIDOC ## Error Response Examples ### Description These examples illustrate common error scenarios and their corresponding response formats. ### VerificationIdMissing ```json { "type": "validation_error", "code": "verification_id_missing", "message": "verification_id is missing in the request." } ``` ### VerificationIdWithSpecialCharacter ```json { "type": "validation_error", "code": "verification_id_value_invalid", "message": "verification_id can include only alphanum, dot, hyphen and underscores." } ``` ### DocumentRequestedMissing ```json { "type": "validation_error", "code": "document_requested_missing", "message": "document_requested is missing in the request." } ``` ### DocumentRequestedEmpty ```json { "type": "validation_error", "code": "invalid_request", "message": "Requested Document Type can't be empty" } ``` ### InvalidDocumentRequested ```json { "type": "validation_error", "code": "invalid_request", "message": "Invalid Document Type Submitted" } ``` ### DuplicateDocumentRequested ```json { "type": "validation_error", "code": "invalid_request", "message": "Duplicate Document Type Submitted" } ``` ### InvalidUserFlow ```json { "type": "validation_error", "code": "user_flow_value_invalid", "message": "user_flow should be signin/signup." } ``` ### InvalidRedirectionUrlWithoutHttpsPrefix ```json { "type": "validation_error", "code": "redirect_url_value_invalid", "message": "redirect_url should start with https." } ``` ### InvalidRedirectionUrlWithHttpsPrefix ```json { "type": "validation_error", "code": "redirect_url_value_invalid", "message": "redirect_url should be valid url." } ``` ### XClientIdMissing ```json { "type": "validation_error", "code": "x-client-id_missing", "message": "x-client-id is missing in the request." } ``` ### UsingTestCredentialsInProd ```json { "type": "validation_error", "code": "x-client-secret_value_invalid", "message": "Client secret belongs to test environment" } ``` ``` -------------------------------- ### Create Order using Cashfree SDK in Go Source: https://www.cashfree.com/docs/payments/online/mobile/cordova This Go code snippet shows how to initiate an order creation request with Cashfree. It includes setting up client credentials and environment variables, defining the order request, and making the API call. Error handling and response logging are included. ```go import ( cashfree "github.com/cashfree/cashfree-pg/v3" ) func createOrder() { clientId := {Client ID} clientSecret := {Client Secret Key} cashfree.XClientId = &clientId cashfree.XClientSecret = &clientSecret cashfree.XEnvironment = cashfree.SANDBOX request := cashfree.CreateOrderRequest{ OrderAmount: 1, CustomerDetails: cashfree.CustomerDetails{ CustomerId: "1", CustomerPhone: "9999999999", }, OrderCurrency: "INR", OrderSplits: []cashfree.VendorSplit{}, } version := "2023-08-01" response, httpResponse, err := cashfree.PGCreateOrder(&version, &request, nil, nil, nil) if err != nil { fmt.Println(err.Error()) } else { fmt.Println(httpResponse.StatusCode) fmt.Println(response) } } ``` -------------------------------- ### Error Handling Examples Source: https://www.cashfree.com/docs/api-reference/payouts/v2/beneficiary-v2/create-beneficiary-v2 Examples of common error responses for beneficiary management. ```APIDOC ## Error Responses ### Beneficiary ID Too Large #### Response Example ```json { "type": "invalid_request_error", "code": "beneficiary_id_length_exceeded", "message": "beneficiary_id : should not be more than 50 characters long. value received: kl12b3rkh1bv234lkbr3jl24tbrlk234bkt234t134kbr1hk34jr" } ``` ### Invalid Beneficiary ID Characters #### Response Example ```json { "type": "invalid_request_error", "code": "beneficiary_id_invalid", "message": "beneficiary_id : should contain only letters, numbers, hyphen, underscore, pipe, and dot. Value received: .\qewqefwqev" } ``` ### Missing Bank IFSC #### Response Example ```json { "type": "invalid_request_error", "code": "bank_ifsc_missing", "message": "bank_ifsc : should be provided with the request if bank_account_number is provided" } ``` ### Missing Bank Account Number #### Response Example ```json { "type": "invalid_request_error", "code": "bank_account_number_missing", "message": "bank_account_number: should be provided with the request if bank_ifsc is provided" } ``` ### Bank Account Number Too Large #### Response Example ```json { "type": "invalid_request_error", "code": "bank_account_number_length_exceeded", "message": "bank_account_number : should not be more than 25 characters long. value received: 235142352346523462456345263452345" } ``` ### Bank Account Number Too Short #### Response Example ```json { "type": "invalid_request_error", "code": "bank_account_number_length_short", "message": "bank_account_number : should not be less than 4 characters long. value received: 12" } ``` ### Invalid Bank Account Number Characters #### Response Example ```json { "type": "invalid_request_error", "code": "bank_account_number_invalid", "message": "bank_account_number : should be alphanumeric. value received: 123@" } ``` ### Invalid IFSC #### Response Example ```json { "type": "invalid_request_error", "code": "bank_ifsc_invalid", "message": "bank_ifsc : please provide a valid IFSC. value received: SBIN00708410" } ``` ### APIs Disabled #### Response Example ```json { "type": "invalid_request_error", "code": "apis_not_enabled", "message": "APIs not enabled. Please fill out the [Support Form](https://merchant.cashfree.com/merchants/landing?env=prod&raise_issue=1)" } ``` ``` -------------------------------- ### Create Order using Cashfree SDK in C# Source: https://www.cashfree.com/docs/payments/online/mobile/cordova This C# example demonstrates creating an order via the Cashfree API. It requires setting up client credentials and the environment. The code defines customer and order details, makes the API call, and prints the status code and content of the response. ```csharp using cashfree_pg.Client; using cashfree_pg.Model; Cashfree.XClientId = {Client ID}; Cashfree.XClientSecret = {Client Secret Key}; Cashfree.XEnvironment = Cashfree.PRODUCTION; var cashfree = new Cashfree(); var xApiVersion = "2023-08-01"; void CreateOrder() { var customerDetails = new CustomerDetails("123", null, "9999999999"); var createOrdersRequest = new CreateOrderRequest(null, 1.0, "INR", customerDetails); try { // Create Order var result = cashfree.PGCreateOrder(xApiVersion, createOrdersRequest, null, null, null); Console.WriteLine(result); Console.WriteLine(result.StatusCode); Console.WriteLine((result.Content as OrderEntity)); } catch (ApiException e) { Console.WriteLine("Exception when calling PGCreateOrder: " + e.Message); Console.WriteLine("Status Code: " + e.ErrorCode); Console.WriteLine(e.StackTrace); } } ``` -------------------------------- ### BadRequestError Examples Source: https://www.cashfree.com/docs/api-reference/payments/latest/reconciliation/vendor-recon Examples of error responses returned when a request fails validation. ```APIDOC ## Error Responses ### Description Common error scenarios for pagination and time formatting validation. ### Response Examples #### Pagination Limit Error { "message": "pagination.limit : should be at least 10", "code": "pagination.limit_invalid", "type": "invalid_request_error" } #### Invalid Time Format Error { "message": "time should be ISO8601 string. Example 2021-07-02T10:20:12+05:30 for IST, 2021-07-02T10:20:12Z for UTC", "code": "order_expiry_time_invalid", "type": "invalid_request_error" } #### Invalid Cursor Error { "message": "invalid character '\\n' in literal null (expecting 'l')", "code": "request_failed", "type": "invalid_request_error" } ``` -------------------------------- ### Install iOS Pods Source: https://www.cashfree.com/docs/payments/online/mobile/cordova Commands to update and install CocoaPods for the iOS platform. ```bash cd ios pod install --repo-update ``` -------------------------------- ### Initialise OpenAI Toolkit Source: https://www.cashfree.com/docs/tools-ai/cashfree-agent-toolkit Set up the Cashfree Agent Toolkit for OpenAI using environment credentials. ```javascript import { CashfreeAgentToolkit, CFEnvironment, } from "@cashfreepayments/agent-toolkit/openai"; const cashfreeToolkit = new CashfreeAgentToolkit( CFEnvironment.SANDBOX, process.env.CASHFREE_CLIENT_ID, process.env.CASHFREE_CLIENT_SECRET, ); ```