GoKwik Flutter Integration

Step 1: Create order from your server.

Sandbox Endpoint: https://sandbox.gokwik.co/v1/order/create

Request Data:


AppidMandatory StringYOUR APPID is different for test and production
AppsecretMandatory StringYOUR APPSECRET is different for test and production
Content-TypeMandatory StringApplication/json


SL no.ObjectParameterTypeDescription
1orderidMandatory Stringorder id which will be unique for all future communication as moid. if you have only cart id then you can send cart id in "id" as well as in "cart_id"
2ordercart_idOptional String
3orderstatusMandatory StringPending would be first order status
4ordersubtotalMandatory Float (2 digits after decimal)total cart value before applying discount
5ordertotal_line_itemsMandatoryInteger number of unique sku's in the order
6ordertotal_line_items_quantityMandatoryInteger total number of items
7ordertotal_tax MandatoryFloat (2 digits after decimal)total calculated tax
8ordertotal_shippingMandatoryFloat (2 digits after decimal)total shipping charges
9ordertotal_discount MandatoryFloat (2 digits after decimal)total discount amount on order value
10ordertotal MandatoryFloat (2 digits after decimal) total = subtotal + total_tax + total_shipping - total_discount(discount due to promocode or cashback discount )
11orderpromo_codeMandatory Stringpromo code applied
12ordersourceMandatory StringExample: organic/facebook/instagram/others
13ordercustomer_ipMandatory StringExample: ""
14ordercustomer_user_agentMandatory StringExample : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:86.0) Gecko/20100101 Firefox/86.0"
15payment_detailsmethod_idMandatory Stringeither "upi" or "cod" both in small case
16line_itemsproduct_idVarchar id of the product, which is used to list the product on the store
17line_itemsline_item_idVarchar line_item id which type of product
18line_itemsvariant_idVarchar variation if for the product
19line_itemsnameStringname of the product
20line_itemsskuMandatory Stringsku of the product
21line_itemspriceMandatory Float (2 digits after decimal)maximum retail price of that product
22line_itemsquantityMandatory Integerquantity of the product
23line_itemssubtotalFloat (2 digits after decimal)Sale price of the products in this line item
24line_itemstotalMandatory Float (2 digits after decimal)total of all the products in line_item after discount, tax and shipping
25line_itemstaxFloat (2 digits after decimal)calculated value for tax
26line_itemsproduct_url Stringurl of the product page
27line_itemsproduct_thumbnail_urlStringurl of the thumbnail image of the product
28productany fieldJsonObjecthere you need to add product more details like colour, size, etc..
29shipping_addressfirst_nameMandatory Stringfirst name of user
30shipping_addresslast_nameMandatory Stringlast name of user
31shipping_addresscompanyStringcompany name of user
32shipping_addressaddress_1Mandatory Stringaddress line 1
33shipping_addressaddress_2Stringaddress line 2
34shipping_addresscityOptional Stringdelivery city
35shipping_addressstateMandatory Stringdelivery state
36shipping_addresspostcodeMandatory Stringdelivery postcode
37shipping_addressemailStringemail id of user
38shipping_addressphoneVarchar Limit10phone number of user
39billing_addressfirst_nameMandatory Stringfirst name of user
40billing_addresslast_nameStringlast name of user
41billing_addresscompanyStringcompany name of user
42billing_addressaddress_1Mandatory Stringaddress line 1
43billing_addressaddress_2Stringaddress line 2
44billing_addresscityMandatory Stringaddress city
45billing_addressstateMandatory Stringaddress state
46billing_addresspostcodeMandatory Stringaddress postcode
47billing_addressemailStringemail id of user
48billing_addressphoneVarchar limit10phone number of user
Curl Example:
curl --location --request POST 'https://sandbox.gokwik.co/v1/order/create' --header 'appid: YOUR APPID' --header 'appsecret: YOUR APPSECRET' --header 'content-type: application/json' --data-raw '{
    "order": {
        ^"id": "240", (string)
        ^"cart_id": "240", (string)
        "status": "pending",(string)
        *"subtotal": "800", //total sale price of line items (string)
        *"total_line_items": "1", (string)
        *"total_line_items_quantity": "1", (string)
        *"total_tax": "160", //tax for entire order (string) 
        *"total_shipping": "50.0", //shipping charges (string)
        *"total_discount": "100", //promo_code related discount or cashback discount (string)
        *"total": "910", // total = subtotal + total_tax + total_shipping - total_discount(discount due to promocode or cashback discount )(string)
        *"source":"organic", //"organic/facebook/instagram/others"(string)+
        *"payment_details": {
            *"method_id": "upi/cod"
        *"billing_address": {
            *"first_name": "Test",
            *"last_name": "Shop",
            "company": "Test",
            *"address_1": "Test",
            "address_2": "",
            *"city": "Delhi",
            *"state": "DL",
            *"postcode": "110092",
            *"country": "IN",
            "email": "xyz@exampal.com",
            "phone": "99XXXXXX99" // 10 digit phone number
        *"shipping_address": {
            *"first_name": "",
            *"last_name": "",
            "company": "",
            *"address_1": "",
            "address_2": "",
            *"city": "",
            *"state": "",
            *"postcode": "",
            *"country": "",
            "email": "xyz@exampal.com",
            "phone": "99XXXXXX99" // 10 digit phone number
        *"customer_ip": "",
        *"customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:86.0) Gecko/20100101 Firefox/86.0",
        *"line_items": [{
            *"product_id": "15",
            "line_item_id" : "id_of_line_item", //can be set as "", this is the sub-order id of an order can have all items as same line_item_id if they have same awb 
            *"variant_id": "0",  // this should be uniq acorss all products.
            "product": {},
            *"name": "Beanie",
            *"sku": "",
            *"price": 1000, //MRP 
            *"quantity": 1,
            "subtotal": "800", // Sale price
            *"total": "800",
            "tax": "0",//
            "awb_number":"", // for initition you can send it blank
            *"product_url": "",
            *"product_thumbnail_url": ""

Status codes:

"statusCode": 200,
"statusMessage": "Placed",
"data": {
    "request_id": "95421d15-c62d-90c64-9673-ee6d37e35374",
    "gokwik_oid": "KWIKOIO8WXO6013589",
    "order_status": "Pending",
    "total": "36.00",
    "moid": "245",
    "mid": "sample_id_by_gokwik",
    "phone": "9876543210",
    "order_type": "upi"
  "statusCode": 201,
  "statusMessage": "Order already exist!"
  "statusCode": 500,
  "statusMessage": "Oops!! Something went wrong" 
  "statusCode": 404,
  "statusMessage": "Merchant not registered!"
  "statusCode": 400,
  "statusMessage": "Order Failed"


Either cart_id or moid must be present when placing the order.

Step 2: Add GoKwik plugin for GoKwik SDK to your project

Download SDK and extract this zip folder in parallel to your app source level.

For example:

 -- flutter_gokwik  
 -- my_app -- lib
           -- android
           -- ios etc etc

Add this to dependencies in your app's pubspec.yaml

      sdk: flutter
  cupertino_icons: ^1.0.2

     Path: ../flutter_gokwik

Step 3: Usage

Import package

import 'package:flutter_gokwik/flutter_gokwik.dart';

Create Gokwik Instance

_gokwik = Gokwik();

Add all details that you've got in response from /order/create and open gokwik payment SDK
String request_id = response["data"]["request_id"];
String gokwik_oid = "XXXX";
String total = "XXXX";
String moid = "XXXX";
String mid = "XXXX";
String phone = "987XXXXX43";
String order_type = "cod/upi";

        production: <true/false>, data: GokwikData(request_id, gokwik_oid, order_status, total, moid, mid, phone, order_type));

Step 4: Register call back for payment success and failure.

The plugin uses event-based communication and emits events when a payment fails or succeeds.

The event names are exposed via the constants EVENT_PAYMENT_SUCCESS and EVENT_PAYMENT_ERROR from the Gokwik class.

Register Event Listeners
_gokwik.on(EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
_gokwik.on(EVENT_PAYMENT_ERROR, _handlePaymentError);
The handlers would be defined somewhere as
void _handleSuccess(PaymentResponse paymentResponse) {
  // Do something when payment succeeds

void _handleError(String response) {
  // Do something when payment fails


BASE URL: base URL for test and production environment

Test Server: https://sandbox.gokwik.co

Production Server: https://api.gokwik.co

Other important info:



Above two things you need to send in order create API that you will get once you register with GoKwik.