Migrating from 1.0.x to 2.x
We have released our latest version 2.0.+ to make our integration more secure for merchants and customers to use. In the this latest version, we have revamped the integration method for using our pre-built checkout and made some changes in our SDKs.
Following are the key changes made in the latest version. Please check respective pages for detailed changes.
- Create Order API Change
We have deprecated the use of order_token and instead introducedpayment_session_id
in response of Create Order API.
Please change the the header value x-api-version
for order creation API in your existing code to receive payment_session_id
instead of order_token
in the response.
x-api-version: "2022-09-01"
-
New React-Native SDK
Please use the new improvised Android SDK which will take inpayment_session_id
React Native SDK -
CFSession
In the new SDK, CFSession objects will takepayment_session_id
as input instead of theorderToken
.
const session = new CFSession(
'payment_session_id',
'order_id',
CFEnvironment.SANDBOX
);
- New SDKs
Going forward, all SDKs will usepayment_session_id
instead oforder_token
to complete the payment.
import * as React from 'react';
import { Component } from 'react';
import {
CFErrorResponse,
CFPaymentGatewayService,
} from 'react-native-cashfree-pg-api';
import {
CFDropCheckoutPayment,
CFEnvironment,
CFPaymentComponentBuilder,
CFPaymentModes,
CFSession,
CFThemeBuilder,
} from 'cashfree-pg-api-contract';
export default class App extends Component {
constructor() {
super();
}
componentDidMount() {
console.log('MOUNTED');
CFPaymentGatewayService.setCallback({
onVerify(orderID: string): void {
this.changeResponseText('orderId is :' + orderID);
},
onError(error: CFErrorResponse, orderID: string): void {
this.changeResponseText(
'exception is : ' + JSON.stringify(error) + '\norderId is :' + orderID
);
},
});
}
componentWillUnmount() {
console.log('UNMOUNTED');
CFPaymentGatewayService.removeCallback();
}
async _startWebCheckout() {
try {
const session = new CFSession(
'payment_session_id',
'order_Id',
CFEnvironment.SANDBOX
);
console.log('Session', JSON.stringify(session));
CFPaymentGatewayService.doWebPayment(JSON.stringify(session));
} catch (e: any) {
console.log(e.message);
}
}
}
Subscribe to Developer Updates
Updated 6 months ago