search

paytmCaptureImageFromCamera JS API

Use Case

This bridge when invoked (assuming that camera permissions are already granted), opens the camera. 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, camera functionality might not work as intended.

 

Note:

  • In iOS, no implementation is needed and web methods to invoke/use camera will work.
  • In Android, the 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

Attributes Description
requestCode
mandatory
Request code for the activity (It's a dummy number, will be given by Android Dev)
Example: 8778
title
optional
Title to be displayed on activity picker dialog
Example: Paytm

Response Attributes

SUCCESS

 

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

 

Attributes Description
data.base64 The base 64 string of the image received
Example: 1
data.meta.imageName Image Name
Example: 100002890.jpg
data.meta.imageSize

Image size in bytes

Example: 1941277

data.meta.imageType

It includes image type (jpg, png, etc.)

Example: jpg

 

ERROR SUCCESS

Attributes Description
error Error
Example: 2
message Error Message
Example: Invalid Parameters

ERROR CODES

Attributes Description
2 Invalid Parameters
1 ERR_MSG
⇾
REQUEST
RESPONSE
JAVASCRIPT
const requestObject = {
    requestCode: 456, //only Android recognizes it, safe to pass for both iOS and Android
    title: 'Title to be displayed on activity picker dialog'//only Android recognizes it, safe to pass for both iOS and Android}
JSBridge.call{'paytmCaptureImageFromCamera',requestObje ct,
    function(result) {
       console.log(JSON.stringify(result))
});
copy icon