• Callback Response
  • Getting Started
    • Mobile Integration (Android/IOS)
      Enterprise Solutions
      Retail Solutions
      Accept Payments
      Process Payments
      Disbursals
      API References
      Refunds
      Guides
      Other links
      Mini Program Platform
  • Features for Investments PG
  • Open gallery and pick an image JS API

    Use Case


    Use the bridge below to open a custom image picker, and get a callback once the user has picked an image or has canceled


    Note:

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

    Request Attributes

    Content format: JSON

    ParameterDescriptionRequiredExample Value
    requestCodeAndroid recognizes it, safe to pass for both iOS and AndroidNo456
    titleTitle to be displayed on activity picker dialog(only Android recognizes it, safe to pass for both iOS and Android)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


    Request CodeResponse JSON
    
                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('paytmOpenGallery',requestObject,
                 function(result) {
                    console.log(JSON.stringify(result))
               });