Ir para o conteúdo

Methods that encrypt the terminal logos and the acquirer’s receipt in base64 previously adjusted in the PayStore portal.


This method must be called when you want to encrypt the terminal logo and the receipt previously added to the Paystore portal. At the end of the method execution, the base64 encrypted logo value will be returned..

Methods

Signature Description
getBase64FromImageUrl(String uri) Start the process of converting the logo to a bitmap and encrypting it in base64

Warning

The method returns the encrypted logo that must be decrypted to be consumed after being sent to another application, the method converting the image to Bitmap and encrypting it in Base64..

Example

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.util.Base64;

public class MyActivity {


    //[...]

    public String getBase64FromImageUrl(String uri) {

        URL url = null;
        try {
            url = new URL(uri);

        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        Bitmap bmp = null;
        try {
            bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());

        } catch (IOException e) {
            e.printStackTrace();
        }

        ByteArrayOutputStream bytes = new ByteArrayOutputStream();

        if (bmp != null) {
            bmp.compress(Bitmap.CompressFormat.PNG, 100, bytes);
        }
        byte[] byteArr = bytes.toByteArray();

        return Base64.encodeToString(byteArr, Base64.DEFAULT);
    }

}
Parâmetros

Name Type Required Description
uri String Yes Field indicated to assign the Logo URL Address parameter.

Parameter details

uri

Name Type Required Description
uri String Yes Url that contains the address of the logo that will be consumed by the method, the objects themePreference.getLogo() and themePreference.getReceiptLogo() were used that contain the information of the URL

Return

Nome Tipo Descrição
getReceiptLogoInitialization String Returns the Logo from Initialization.
getBase64FromImageUrl String Returns the Logo encrypted in Base64.