react-native-tamara-sdk
v1.0.8
Published
Tamara React Native SDK
Downloads
650
Maintainers
Readme
React Native SDK
Setup SDK
Install
- run command line TamaraSDK Module: #Case use sdk from local:
- npm install + npm run example
- cd example + npm start ================================== #Case use sdk from link npmjs: Add dependencies "react-native-webview":"version" -> package.json in example project
- npm install
- cd example + npm install + npm start ==================================
How to use it
Include function:
- Init: Initialize before using it:
TamaraPayment.initialize(AUTH_TOKEN, API_URL, NOTIFICATION_WEB_HOOK_URL, PUBLISH_KEY, NOTIFICATION_TOKEN, isSandbox)
Create and pay order
Before adding order's information, create Order by call this method with referenceOrderId and description. RefId is your unique id of your order.
TamaraPayment.createOrder(referenceOrderId, description)
These informations are mandatory:
Set customer's information:
TamaraPayment.setCustomerInfo(firstName, lastName,
phoneNumber, email, isFirstOrder)
Example: import { setCustomerInfo} from 'react-native-tamara-sdk' setCustomerInfo(textInputFirstName, textInputLastName, textInputPhone, textInputEmail, isChecked);
Set payment type (optional: default: PAY_BY_INSTALMENTS):
TamaraPayment.setPaymentType(paymentType)
Example:
import { setPaymentType} from 'react-native-tamara-sdk'
setPaymentType("PAY_BY_INSTALMENTS");
Add Item with its price, tax and discount:
TamaraPayment.addItem(name, referenceId ,sku, type, unitPrice,
taxAmount ,discountAmount, quantity)
Set shipping address and billing address:
TamaraPayment.setShippingAddress(firstName,lastName, phone,
addressLine1, addressLine2, country, region, city)
TamaraPayment.setBillingAddress(firstName,lastName, phone,
addressLine1, addressLine2, country, region, city)
Set shipping fee:
TamaraPayment.setShippingAmount(shippingFee)
Set discount (optional):
TamaraPayment.setDiscount(discount, name)
Set instalments:
TamaraPayment.setInstalments(instalments)
Set platform: import { setPlatform } from 'react-native-tamara-sdk' setPlatform("Android");//IOS
Set locale:
TamaraPayment.setLocale(locale)
Set order number:
TamaraPayment.setOrderNumber(orderNumber)
Set expires in minutes:
TamaraPayment.setExpiresInMinutes(expiresInMinutes)
Set risk assessment:
TamaraPayment.setRiskAssessment(jsonData)
Example:
import {setRiskAssessment} from 'react-native-tamara-sdk'
let result = await setRiskAssessment(jsonData); // return value true or false
if (result) {
//json ok
}
Set additional data:
TamaraPayment.setAdditionalData(jsonData)
Add Custom Fields AdditionalData: Example val jsonData = "{"custom_field1": 42, "custom_field2": "value2" }"
TamaraPayment.addCustomFieldsAdditionalData(jsonData)
Example: import { addCustomFieldsAdditionalData } from 'react-native-tamara-sdk' addCustomFieldsAdditionalData("{"custom_field1": 42, "custom_field2": "value2" }");
Processes to Tamara payment page using:
TamaraPayment.paymentOrder()
Example:
import {paymentOrder} from 'react-native-tamara-sdk';
const jsonString = await paymentOrder();
const result = JSON.parse(jsonString);
Order detail
Get order detail param mandatory: orderId
TamaraPayment.getOrderDetail(orderId)
Example: Import function
import { orderDetail } from 'react-native-tamara-sdk'
After get response json string and parse to json
const result = await orderDetail(orderId);
const data = JSON.parse(result)
Authorise order
Authorise order by call this method with orderId. param mandatory: orderId
TamaraPayment.authoriseOrder(orderId)
Example: Import function
import { authoriseOrder } from 'react-native-tamara-sdk'
Get response json string and parse to json
const result = await authoriseOrder(orderId)
const data = JSON.parse(result)
Cancel order
Note: Need call authorise order method before call cancel order Cancel order reference by call this method with orderId and jsonData.
param mandatory: orderId jsonData: use library convert class CancelOrderRequest to json (Gson)
TamaraPayment.cancelOrder(orderId, jsonData)
Example: Import function
import { cancelOrder } from 'react-native-tamara-sdk'
Get response json string and parse to json
const result = await cancelOrder(JSON.stringify(jsonData))
const data = JSON.parse(result)
Update order reference
Update order reference by call this method with orderId and orderReference.
param mandatory: orderId, orderReference
TamaraPayment.updateOrderReference(orderId, orderReference)
Example: Import function
import { updateOrderReference } from 'react-native-tamara-sdk'
Get response json string and parse to json
const result = await updateOrderReference(orderId, orderReference)
const data = JSON.parse(result)
Capture a payment
Note: Need call authorise order method before call capture a payment Cancel order reference by call this method with orderId and jsonData.
param mandatory: orderId jsonData: use library convert class Capture to json (Gson)
TamaraPayment.getCapturePayment(jsonData)
Example: Import function
import { capturePayment } from 'react-native-tamara-sdk'
Get response json string and parse to json
const result = await capturePayment(JSON.stringify(jsonData))
const data = JSON.parse(result)
Refunds
Cancel order reference by call this method with orderId and jsonData. Note: Need call authorise order method before call Refunds
param mandatory: orderId jsonData: use library convert class Refund to json (Gson)
TamaraPayment.refunds(orderId, jsonData)
Example: Import function
import { refunds } from 'react-native-tamara-sdk'
Get response json string and parse to json
const result = await refunds(orderId, jsonData)
const data = JSON.parse(result)
Render widget cart page
Render widget cart page reference by call this method with language, country, publicKey, amount. param mandatory: language, country, publicKey, amount
TamaraPayment.renderWidgetCartPage(language, country, publicKey, amount)
Example: Import function
import { renderCartPage } from 'react-native-tamara-sdk'
Get response json string and parse to json
const result = await renderCartPage(language, country, publicKey, amount)
const data = JSON.parse(result)
Render widget product
Render widget cart page reference by call this method with language, country, publicKey, amount. param mandatory: language, country, publicKey, amount
TamaraPayment.renderWidgetProduct(language, country, publicKey, amount)
Example: Import function
import { renderProduct } from 'react-native-tamara-sdk'
Get response json string and parse to json
const result = await renderProduct(language, country, publicKey, amount)
const data = JSON.parse(result)
Check payment options available
Check payment option by call this method with orderId and jsonData. jsonData: use library convert class PaymentOptions to json (Gson)
TamaraPayment.paymentOptions(jsonData)
Example: Import function
import { checkPaymentOptions } from 'react-native-tamara-sdk'
Get response json string and parse to json
const result = await await checkPaymentOptions(JSON.stringify(jsonData))
const data = JSON.parse(result)
Checkout URL
Checkout URL is a component and displays when passed in the url. Example: Import component
import { TamaraCheckoutURL } from 'react-native-tamara-sdk'
Use component
<TamaraCheckoutURL
checkoutURL={checkout_url}
successURL={success_url}
failURL={fail_url}
cancelURL={cancel_url}
onSuccess={handleSuccess}
onFail={handleFail}
onCancel={handleCancel}
/>