GoKwik React Native Integration

Step 1: Adding GoKwik package in your project.

Download the GoKwik npm package from here and execute the following command

npm install ‘GoKwik npm package path’

Step 2: iOS changes

You need to add the names of all UPI payment apps below in info.plist
Copy
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>phonepe</string>
    <string>paytm</string>
    <string>gpay</string>
    <string>bhim</string>
</array>

Step 3: Create order from the backend

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

Request Data:

Header

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

Body

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: "103.82.80.57"
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
COUNT 48
Curl Example:
Copy
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)
        *"promo_code":"XYZ_20",(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": "103.82.80.57",
        *"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
            "shipping_provider":"",
            *"product_url": "",
            *"product_thumbnail_url": ""
        }]
    }
}

Response:

Copy
{
"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"
}
}
Copy
{
  "statusCode": 201,
  "statusMessage": "Order already exist!"
}
Copy
{
  "statusCode": 404,
  "statusMessage": "Merchant not registered!"
}
Copy
{
  "statusCode": 400,
  "statusMessage": "Order Failed"
}
Copy
{
  "statusCode": 500,
  "statusMessage": "Oops!! Something went wrong"
}

Note:

^ Anyone either cart_id or moid should be present when placing the order

Step 4: Open GoKwik app for payment.

Import GokwikCheckout component
Copy
import GokwikCheckout from 'react-native-gokwik-sdk';
Open GokwikCheckout and define the callback for success and failure
Copy
GokwikCheckout.open(JSON.stringify(createOrderResponse), isProduction)
          .then(data => {
            // handle success
            showMessage(`Success: ${JSON.stringify(data.msg)}`);
          })
          .catch(error => {
            // handle failure
            showMessage(`Error: ${"error.message"}`);
          });

Note:

isProduction: Boolean variable to specify whether it is test or production environment

Test Server: false

Production Server: true

Note:

BASE URL: base URL for test and production environment. It is different for test/staging server and live/production server.

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

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

Other important info:

GoKwik will provide the App ID and App Secret which are passed in the Order Create API after you register on GoKwik.

appid: YOUR APPID

appsecret: YOUR APPSECRET