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:
- In iOS no implementation is needed and web methods to invoke / use camera will work.
- 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
ATTRIBUTE | DESCRIPTION | REQUIRED | EXAMPLE VALUE |
---|---|---|---|
requestCode | request code for the activity(This is dummy no. , Will be given by Android Dev) | Yes | 8778 |
title | Title to be displayed on activity picker dialog | No | Paytm |
Response Attributes
Success:
Note: Response comes in json with 'data' as key
PARAMETER | DESCRIPTION | EXAMPLE VALUE |
---|---|---|
data.base64 | The base 64 string of the image received | 1 |
data.meta.imageName | ImageName | 100002890.jpg |
data.meta.imageSize | Image size in bytes | 1941277 |
data.meta.imageType | This includes image type (jpg, png, etc) | "jpg" |
Error Responses:
PARAMETER | DESCRIPTION | EXAMPLE VALUE |
---|---|---|
error | Error | 2 |
message | Error message | invalid parameters |
Error Codes
CODE | DESCRIPTION |
---|---|
2 | Invalid parameter |
1 | ERR_MSG |
REQUEST CODERESPONSE CODE
JAVASCRIPT
const requestObject={
"requestCode": 8778,
"title": 'Title to be displayed on activity
picker dialog'
};
JSBridge.call{'paytmCaptureImageFromCamera',
requestObject,
function(result) {
console.log(JSON.stringify(result))
});