search

paytmCaptureImageFromCamera JS API

Use Case

This bridge when invoked (assuming that camera permissions are already granted), opens the camera, and once the user clicks a picture, passes data to the web context. To enable the Camera functionality for your PWA in Android you need to implement this JS API Bridge. Without this implementation the camera functionality might not work as intended.


Note:

  1. In iOS no implementation is needed and web methods to invoke / use camera will work.
  2. In Android merchant must call paytmCheckPermission JS API & paytmRequestPermission JS API to check if camera permission is granted or not before calling paytmCaptureImageFromCamera.

Request Attributes

API Content format: JSON

ATTRIBUTEDESCRIPTIONREQUIREDEXAMPLE VALUE
requestCoderequest code for the activity(This is dummy no. , Will be given by Android Dev)Yes8778
titleTitle to be displayed on activity picker dialog NoPaytm

Response Attributes

Success:

Note: Response comes in json with 'data' as key


PARAMETERDESCRIPTIONEXAMPLE VALUE
data.base64The base 64 string of the image received1
data.meta.imageNameImageName100002890.jpg
data.meta.imageSizeImage size in bytes1941277
data.meta.imageTypeThis includes image type (jpg, png, etc)"jpg"

Error Responses:

PARAMETERDESCRIPTIONEXAMPLE VALUE
errorError2
messageError messageinvalid parameters

Error Codes

CODEDESCRIPTION
2Invalid parameter
1ERR_MSG
REQUEST CODE
RESPONSE CODE
JAVASCRIPT
copy content icon

const requestObject={
    "requestCode": 8778,
    "title": 'Title to be displayed on activity
  picker dialog'
};

JSBridge.call{'paytmCaptureImageFromCamera',
requestObject,
   function(result) {
       console.log(JSON.stringify(result))
});