1.0.2 • Published 2 years ago

cashfree-pg-capacitor v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

cashfree-pg-capacitor

The Cashfree Capacitor SDK allows you to integrate Cashfree Payment Gateway into your application and start collecting payments from your customers. It opens the payment page in a webview. The Capacitor SDK has been designed to minimise the complexity of handling and integrating payments in your Capacitor project.

Click here for more Documentation.

Install

Step 1 (Install the plugin)

Run the following commands in your capacitor project.

npm install cashfree-pg-capacitor
npx cap sync

Step 2 (Configure for Android and iOS)

Android

If the project's targetSdkVersion is 30 or above, add the following to your app Android Manifest file.

<manifest ...> 
	<queries>  
		<intent>  
			<action  android:name="android.intent.action.VIEW"  />  
			<data  android:scheme="upi"  android:host="pay"/>  
		</intent>  
		<package  android:name="com.android.chrome"  />  
	</queries>
<application ...>

also register the plugin in MainActivity.java of your app. Example

import com.cashfree.capacitor.CFBridge;
...
public class MainActivity extends BridgeActivity {  
  
 @Override  
 protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    registerPlugin(CFBridge.class); // register the plugin here
  }  
}

iOS

Add the following code to application's info.plist file.

<key>LSApplicationCategoryType</key> 
<string></string> 
<key>LSApplicationQueriesSchemes</key> 
<array> 
<string>phonepe</string> 
<string>tez</string> 
<string>paytm</string> 
<string>bhim</string> 
</array>

API

startPaymentWEB()

startPaymentWEB(params: Object | Map<string, string>) => Object  

Parameters

Returns An Object containing the Response Parameters.


startPaymentUPI()

startPaymentUPI(params: Object | Map<string, string>) => Object  

Parameters

Returns An Object containing the Response Parameters.


getUPIApps()

getUPIApps() => Object  

Returns An Object containing the list of UPI apps installed in the User Phone supporting UPI intent payment mode.

Response Parameters:

  • displayName: Display name of the app to be used to show in the UI.
  • id: UPI app id to be used in UPI seamless Flow (with key appName).
  • icon: Icon of the UPI app encoded in Base64 to show in the UI.

Sample response parsed to JSON:

[
	{ 
		“displayName”: “Gpay”, 
		“id”: “com.google.android.apps.nbu.paisa.user”, 
		“icon”: “iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAAAXNSR0IArs4c6QAA... (in base64)” 
	}, 
	{ 
		“displayName”: “PHONEPE”, 
		“id”: “com.phonepe.app”, 
		“icon”: “iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAAAXNSR0IArs4c6QAA... (in base64)” 
	} 
]

getIcon()

getIcon(base64String: string) => string  

Parameters

  • base64String : A base64 icon string obtained from 'icon' field of a UPIApp from getUPIApps.

Returns A string prepended with data:image/png;base64, to make it usable as a source for image.


transFormUPIResponse()

This function is created as a helper function specifially for typescript.

transFormUPIResponse(result: any) => UPIApp[]  

Parameters

Returns An array of UPIApp.


Request and Response Parameters

Request Parameters

ParameterRequiredDescription
appIdYesYour app ID
orderIdYesOrder or Invoice ID
orderCurrencyYesCurrency code for the order.
orderAmountYesBill amount of the order
orderNoteNoHelp text to provide customers with more information about the order.
customerNameNoName of the customer
customerPhoneYesPhone number of the customer
customerEmailYesEmail ID of the customer
notifyUrlNoNotification URL for server-server communication. Useful when a user's connection drops after completing the payment.
paymentModesNoAllowed payment modes for this order. Available values: cc, dc, nb, paypal, upi, wallet.Leave it blank if you want to display all modes.
tokenDataYesToken generated for the payment.
stageYesEnvironment of the project setup (TEST or PROD)
appNameNoUPI app id when invoking seamless UPI intent.

Response Parameters

These parameters are sent in the response Object. They contain the details of the transaction.

ParameterDescription
orderIdOrder id for which transaction has been processed. Example, GZ-212.
orderAmountOrder amount. Example, 256.00
paymentModePayment mode of the transaction.
referenceIdCashfree generated unique transaction ID. Example, 140388038803.
txStatusPayment status for that order. Values can be, SUCCESS, FLAGGED, PENDING, FAILED, CANCELLED.
paymentModePayment mode used by customers to make the payment. Example, DEBIT_CARD, MobiKwik.
txMsgMessage related to the transaction. Will have the reason, if payment failed.
txTimeTime of the transaction.
typeFixed value : CashFreeResponse. To identify the response is from Cashfree SDK.
signatureResponse signature, more here.

1.0.2

2 years ago

1.0.2-dev.1

2 years ago

1.0.1-demand.2

2 years ago

1.0.1-demand.1

2 years ago

1.0.1-dev.1

2 years ago

1.0.1-dev.2

2 years ago

1.0.1-dev.3

2 years ago

1.0.1-dev.4

2 years ago

1.0.0

3 years ago

1.0.0-beta.4

3 years ago

1.0.0-beta.3

3 years ago

1.0.0-beta.2

3 years ago

1.0.0-beta.1

3 years ago

0.1.0-dev.9

3 years ago

0.1.0-dev.8

3 years ago

0.1.0-dev.7

3 years ago

0.1.0-dev.6

3 years ago

0.1.0-dev.5

3 years ago

0.1.0-dev.4

3 years ago

0.1.0-dev.3

3 years ago

0.1.0-dev.2

3 years ago

0.1.0-dev.1

3 years ago