Android Question JavaObject And AAR Error.

evbedp

Member
Licensed User
i'm already search in forum how to use javaObject.

https://www.b4x.com/android/forum/threads/javaobject-aar-call.73634/#content

and here

https://www.b4x.com/android/forum/t...tion-method-parsepdf-not-found.81470/#content

and other i can't add all the link.

i try this code
B4X:
#Region  Project Attributes
    #ApplicationLabel: dOKU sAMPLE
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
#AdditionalJar: sdkocov2-release.aar
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    
End Sub

Sub CartDetail As JavaObject
    Dim Cart As JavaObject
    Cart.InitializeNewInstance("com.doku.sdkocov2.model.PaymentItems",Null)
    Cart.RunMethod("setDataAmount",Array("20.000"))
    Dim m As Map
    m.Initialize
    m.Put("name","sayur")
    m.Put("amount","10000.00")
    m.Put("quantity","1")
    m.Put("subtotal","10000.00")
    Dim l As List
    l.Initialize
    l.Add(m)
    Dim m2 As Map
    m2.Initialize
    m2.Put("name","bon bon")
    m2.Put("amount","10000.00")
    m2.Put("quantity","1")
    m2.Put("subtotal","10000.00")
    l.Add(m2)
    Dim json As JSONGenerator
    json.Initialize2(l)
    Cart.RunMethod("setDataBasket",Array(json.ToString))
    Cart.RunMethod("setDataCurrency",Array("360"))
    Cart.RunMethod("setDataMerchantChain",Array("NA"))
    Cart.RunMethod("setDataSessionID",Array("982798371"))
    Cart.RunMethod("setDataTransactionID",Array("12352"))
    Cart.RunMethod("setDataMerchantCode",Array("2074"))
    Cart.RunMethod("setDataImei",Array(GetDeviceId))
    Cart.RunMethod("setMobilePhone",Array("08123123112"))
    Cart.RunMethod("setPublicKey",Array("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsBkd2EipFMMn3hy/rgQ3UBYs0WFPiei2RFSU0r/ClJXgyh88Eq+BpKtSCivbCjCZE7YOhcdbtYonFIi+isheNv00zqo5msQNCvhT45uYZ2Arvh8+F9xGE+y1KTS7ruYnzsDHYTBv+MHOJxs0Yn1mi3+y0KSMIBhz5iSIPzQgnLdNww0VnhwNdCwlm1EeBBE4ijWAm7IWxrFAsmMynUVCZRzZ5tTU4mb8BEDc854Pu94m1YAugw74f7JzMol7tPf5MO79moXdvDmPKVzNrEvMVFDLk+KnvI/yYe4uReQA4H2glNB+hGRPjqDXztY/6EJBHDo79cjKSBmuU5WGYReRiwIDAQAB"))
    Cart.RunMethod("isProduction",Array(False))
    'paymentItems.setDataWords(AppsUtil.SHA1(AppsUtil.generateMoneyFormat("15000") + "2074" + "eaM6i1JjS19J" + invoiceNumber + 360 + telephonyManager.getDeviceId()));
    Return Cart
End Sub
Sub GetDeviceId As String
    Dim r As Reflector
    Dim Api As Int
    Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
    If Api < 9 Then
        'Old device
        If File.Exists(File.DirInternal, "__id") Then
            Return File.ReadString(File.DirInternal, "__id")
        Else
            Dim id As Int
            id = Rnd(0x10000000, 0x7FFFFFFF)
            File.WriteString(File.DirInternal, "__id", id)
            Return id
        End If
    Else
        'New device
        Return r.GetStaticField("android.os.Build", "SERIAL")
    End If
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Dim jo As JavaObject
    jo.InitializeStatic("com.doku.sdkocov2.DirectSDK")
    
    Log(jo.RunMethodJO("setPaymentChannel",Array(15)))
    Log(jo.RunMethod("setCart_details",Array(CartDetail)))
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

but got some error in this code
Logger connected to: samsung SM-G532G
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
true
Error occurred on line: 88 (Main)
java.lang.IllegalArgumentException: Expected receiver of type com.doku.sdkocov2.DirectSDK, but got java.lang.Class<com.doku.sdkocov2.DirectSDK>
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:138)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 85 (Main)
java.lang.ClassNotFoundException: com$doku1$sdkocov2$DirectSDK
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:288)
at anywheresoftware.b4j.object.JavaObject.InitializeStatic(JavaObject.java:74)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 88 (Main)
java.lang.IllegalArgumentException: Expected receiver of type com.doku.sdkocov2.DirectSDK, but got java.lang.Class<com.doku.sdkocov2.DirectSDK>
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:138)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 87 (Main)
java.lang.IllegalArgumentException: Expected receiver of type com.doku.sdkocov2.DirectSDK, but got java.lang.Class<com.doku.sdkocov2.DirectSDK>
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:138)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **

Original running in android studio

package com.doku.integratesdkocov2;

import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.doku.sdkocov2.DirectSDK;
import com.doku.sdkocov2.interfaces.iPaymentCallback;
import com.doku.sdkocov2.model.LayoutItems;
import com.doku.sdkocov2.model.PaymentItems;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

//declare variable
DirectSDK directSDK;
String invoiceNumber;
JSONObject respongetTokenSDK;
String jsonRespon;
Button buttonCC, buttonDOKU, buttonMandiri, buttonVA, buttonAlfa, buttonFirstPay, buttonSecondPay;
int REQUEST_CODE_MANDIRI = 3;
int REQUEST_CODE_VIRTUALACCOUNT = 4;
TelephonyManager telephonyManager;
String responseToken, Challenge1, Challenge2, Challenge3, debitCard;
int PayChanChoosed = 0;
private static final int REQUEST_PHONE = 1;
private static String[] PERMISSION_PHONE = {Manifest.permission.READ_PHONE_STATE};
String tokenPayment = null;
String customerID = null;
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

setupLayout();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setLogo(R.drawable.ico_merchant);
toolbar.setTitle("Payment");
TextView mTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
AppsUtil.applyFont(getApplicationContext(), mTitle, "fonts/dokuregular.ttf");

setSupportActionBar(toolbar);

buttonCC = (Button) findViewById(R.id.buttonCCBiasa);
buttonDOKU = (Button) findViewById(R.id.buttonDOKU);
buttonMandiri = (Button) findViewById(R.id.buttonMandiri);
buttonVA = (Button) findViewById(R.id.buttonVA);
buttonAlfa = (Button) findViewById(R.id.buttonAlfa);
buttonSecondPay = (Button) findViewById(R.id.buttonSecondPay);
buttonFirstPay = (Button) findViewById(R.id.buttonCC);

telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

buttonCC.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
!= PackageManager.PERMISSION_GRANTED) {
getPermissionFirst(1);
} else {
connectSDK(1);
}

}
});

buttonDOKU.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
!= PackageManager.PERMISSION_GRANTED) {
getPermissionFirst(2);
} else {
connectSDK(2);
}
}
});

buttonMandiri.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, MandiriClickPay.class);
startActivityForResult(i, REQUEST_CODE_MANDIRI);
}
});

buttonVA.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, VirtualAccount.class);
startActivityForResult(i, REQUEST_CODE_VIRTUALACCOUNT);
}
});

buttonAlfa.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, VirtualAccountAlfa.class);
startActivityForResult(i, REQUEST_CODE_VIRTUALACCOUNT);
}
});

buttonFirstPay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
customerID = String.valueOf(AppsUtil.nDigitRandomNo(8));

if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
!= PackageManager.PERMISSION_GRANTED) {
getPermissionFirst(1);
} else {
connectFirstPay(1);
}

}
});

buttonSecondPay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tokenPayment = "b194ee1e5305c3990015972243a6c7e24ef361f7";

if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
!= PackageManager.PERMISSION_GRANTED) {
getPermissionFirst(1);
} else {
connectSecondPay(1);
}
}
});


// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}

private void setupLayout() {

Button buttonVA, buttonMandiri, buttonDOKU, buttonCC, buttonAlfa;
TextView priceValue, price, qtyValue, qty, textProduct;

buttonVA = (Button) findViewById(R.id.buttonVA);
buttonMandiri = (Button) findViewById(R.id.buttonMandiri);
buttonDOKU = (Button) findViewById(R.id.buttonDOKU);
buttonCC = (Button) findViewById(R.id.buttonCC);
buttonAlfa = (Button) findViewById(R.id.buttonAlfa);

priceValue = (TextView) findViewById(R.id.priceValue);
price = (TextView) findViewById(R.id.price);
qtyValue = (TextView) findViewById(R.id.qtyValue);
qty = (TextView) findViewById(R.id.qty);
textProduct = (TextView) findViewById(R.id.textProduct);

AppsUtil.applyFont(getApplicationContext(), buttonVA, "fonts/dokuregular.ttf");
AppsUtil.applyFont(getApplicationContext(), buttonMandiri, "fonts/dokuregular.ttf");
AppsUtil.applyFont(getApplicationContext(), buttonDOKU, "fonts/dokuregular.ttf");
AppsUtil.applyFont(getApplicationContext(), buttonCC, "fonts/dokuregular.ttf");
AppsUtil.applyFont(getApplicationContext(), buttonAlfa, "fonts/dokuregular.ttf");

AppsUtil.applyFont(getApplicationContext(), priceValue, "fonts/dokuregular.ttf");
AppsUtil.applyFont(getApplicationContext(), price, "fonts/dokuregular.ttf");
AppsUtil.applyFont(getApplicationContext(), qtyValue, "fonts/dokuregular.ttf");
AppsUtil.applyFont(getApplicationContext(), qty, "fonts/dokuregular.ttf");
AppsUtil.applyFont(getApplicationContext(), textProduct, "fonts/dokuregular.ttf");


}


@TargetApi(Build.VERSION_CODES.M)
private void getPermissionFirst(int paymentChanel) {
PayChanChoosed = paymentChanel;
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.READ_PHONE_STATE)) {

ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.READ_PHONE_STATE},
REQUEST_PHONE);

} else {

ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE},
REQUEST_PHONE);
}

}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_PHONE) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (PayChanChoosed != 0) {
if (PayChanChoosed == 1 || PayChanChoosed == 2) {

if (tokenPayment != null) {
connectSecondPay(PayChanChoosed);
} else if (customerID != null) {
connectFirstPay(PayChanChoosed);
} else {
connectSDK(PayChanChoosed);
}
} else if (PayChanChoosed == 3) {
new MandiriPayment().execute();
}
} else {
Toast.makeText(getApplicationContext(), "PAYCHAN ERROR", Toast.LENGTH_SHORT);
}
} else {
Toast.makeText(getApplicationContext(), "Permission Failed", Toast.LENGTH_SHORT);
}
}
}


@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (requestCode == 3 && data.getStringExtra("responseValue") != null) {
responseToken = data.getStringExtra("responseValue");
Challenge1 = data.getStringExtra("challenge1");
Challenge2 = data.getStringExtra("challenge2");
Challenge3 = data.getStringExtra("challenge3");
debitCard = data.getStringExtra("debitCard");

if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
!= PackageManager.PERMISSION_GRANTED) {
getPermissionFirst(3);
} else {

new MandiriPayment().execute();
}

} else if (requestCode == 4) {
Log.d("Memilih : ", "payment Channel Virtual Account");
Log.d("data VA", data.getStringExtra("data"));

} else {
Log.d("data", "KOSONG");
}
}
}


private void connectSDK(int menuPaymentChannel) {

//set payment parameter
invoiceNumber = String.valueOf(AppsUtil.nDigitRandomNo(10));

directSDK = new DirectSDK();

PaymentItems cardDetails = null;
cardDetails = InputCard();
directSDK.setCart_details(cardDetails);

//set layout parameter
// LayoutItems layoutItems = null;
// layoutItems = setLayout();
// directSDK.setLayout(layoutItems);

directSDK.setPaymentChannel(menuPaymentChannel);
directSDK.getResponse(new iPaymentCallback() {

@Override
public void onSuccess(final String text) {
Log.d("RESPONSE", text);
try {
respongetTokenSDK = new JSONObject(text);

if (respongetTokenSDK.getString("res_response_code").equalsIgnoreCase("0000")) {
jsonRespon = text;
new RequestPayment().execute();
}
} catch (JSONException e) {
e.printStackTrace();
}

}

@Override
public void onError(final String text) {
Log.d("onError", text);
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
}

@Override
public void onException(Exception eSDK) {
eSDK.printStackTrace();
}
}, getApplicationContext());
}


private PaymentItems InputCard() {

PaymentItems paymentItems = new PaymentItems();
paymentItems.setDataAmount(AppsUtil.generateMoneyFormat("15000"));
paymentItems.setDataBasket("[{\"name\":\"sayur\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"},{\"name\":\"buah\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"}]");
paymentItems.setDataCurrency("360");
paymentItems.setDataWords(AppsUtil.SHA1(AppsUtil.generateMoneyFormat("15000") + "2074" + "eaM6i1JjS19J" + invoiceNumber + 360 + telephonyManager.getDeviceId()));
paymentItems.setDataMerchantChain("NA");
paymentItems.setDataSessionID(String.valueOf(AppsUtil.nDigitRandomNo(9)));
paymentItems.setDataTransactionID(invoiceNumber);
paymentItems.setDataMerchantCode("2074");
paymentItems.setDataImei(telephonyManager.getDeviceId());
paymentItems.setMobilePhone("08123123112");
paymentItems.setPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsBkd2EipFMMn3hy/rgQ3UBYs0WFPiei2RFSU0r/ClJXgyh88Eq+BpKtSCivbCjCZE7YOhcdbtYonFIi+isheNv00zqo5msQNCvhT45uYZ2Arvh8+F9xGE+y1KTS7ruYnzsDHYTBv+MHOJxs0Yn1mi3+y0KSMIBhz5iSIPzQgnLdNww0VnhwNdCwlm1EeBBE4ijWAm7IWxrFAsmMynUVCZRzZ5tTU4mb8BEDc854Pu94m1YAugw74f7JzMol7tPf5MO79moXdvDmPKVzNrEvMVFDLk+KnvI/yYe4uReQA4H2glNB+hGRPjqDXztY/6EJBHDo79cjKSBmuU5WGYReRiwIDAQAB");
paymentItems.isProduction(false);
return paymentItems;
}


private LayoutItems setLayout() {

LayoutItems layoutItems = new LayoutItems();
layoutItems.setFontPath("fonts/dinbold.ttf");
layoutItems.setToolbarColor("#289c64");
layoutItems.setToolbarTextColor("#FFFFFF");
layoutItems.setFontColor("#121212");
layoutItems.setBackgroundColor("#eaeaea");
layoutItems.setLabelTextColor("#9a9a9a");
layoutItems.setButtonBackground(getResources().getDrawable(R.drawable.button_orange));
layoutItems.setButtonTextColor("#FFFFFF");

return layoutItems;
}


@Override
public void onStart() {
super.onStart();

// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
client.connect();
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"Main Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app deep link URI is correct.
Uri.parse("android-app://com.doku.integratesdkocov2/http/host/path")
);
AppIndex.AppIndexApi.start(client, viewAction);
}

@Override
public void onStop() {
super.onStop();

// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"Main Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app deep link URI is correct.
Uri.parse("android-app://com.doku.integratesdkocov2/http/host/path")
);
AppIndex.AppIndexApi.end(client, viewAction);
client.disconnect();
}


private class RequestPayment extends AsyncTask<String, String, JSONObject> {

private ProgressDialog pDialog;

@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Mohon Tunggu ...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();

}

@Override
protected JSONObject doInBackground(String... args) {
JSONObject defResp = null;

try {
List<NameValuePair> data = new ArrayList<NameValuePair>(3);
data.add(new BasicNameValuePair("data", jsonRespon));

// Getting JSON from URL
String conResult = ApiConnection.httpsConnection(MainActivity.this,
Constants.URL_CHARGING_DOKU_DAN_CC, data);
Log.d("CHARGING PAYMENT", conResult);

defResp = new JSONObject(conResult);

} catch (JSONException e) {
e.printStackTrace();
}
return defResp;
}

@Override
protected void onPostExecute(JSONObject json) {

pDialog.dismiss();

if (json != null) {
try {

if (json.getString("res_response_code").equalsIgnoreCase("0000") && json != null) {
Intent intent = new Intent(getApplicationContext(), ResultPayment.class);
intent.putExtra("data", json.toString());
startActivity(intent);
finish();
Toast.makeText(getApplicationContext(), " PAYMENT SUKSES", Toast.LENGTH_SHORT).show();
} else {
Intent intent = new Intent(getApplicationContext(), ResultPayment.class);
intent.putExtra("data", json.toString());
startActivity(intent);
finish();
Toast.makeText(getApplicationContext(), "PAYMENT ERROR", Toast.LENGTH_SHORT).show();
}

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

}

}
}
}


private class MandiriPayment extends AsyncTask<String, String, JSONObject> {

private ProgressDialog pDialog;

@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Mohon Tunggu ...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();

}

@Override
protected JSONObject doInBackground(String... args) {
JSONObject defResp = null;

try {

JSONObject jGroup = new JSONObject();// /main Object
try {

invoiceNumber = String.valueOf(AppsUtil.nDigitRandomNo(10));

jGroup.put("req_transaction_id", invoiceNumber);
jGroup.put("req_payment_channel", "02");
jGroup.put("req_card_number", debitCard);
jGroup.put("req_device_id", telephonyManager.getDeviceId());
jGroup.put("req_challenge_code_1", Challenge1);
jGroup.put("req_challenge_code_2", Challenge2);
jGroup.put("req_challenge_code_3", Challenge3);
jGroup.put("req_response_token", responseToken);

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

Log.d("request Mandiri", jGroup.toString());
List<NameValuePair> data = new ArrayList<NameValuePair>(3);
data.add(new BasicNameValuePair("data", jGroup.toString()));

// Getting JSON from URL
String conResult = ApiConnection.httpsConnection(MainActivity.this,
Constants.URL_CHARGING_MANDIRI_CLICKPAY, data);
Log.d("DATA PAYMENT", conResult);

defResp = new JSONObject(conResult);

} catch (JSONException e) {
e.printStackTrace();
}
return defResp;
}

@Override
protected void onPostExecute(JSONObject json) {

pDialog.dismiss();

if (json != null) {
try {
if (json.getString("res_response_code").equalsIgnoreCase("0000") && json != null) {
Intent intent = new Intent(getApplicationContext(), ResultPayment.class);
intent.putExtra("data", json.toString());
startActivity(intent);
finish();
Toast.makeText(getApplicationContext(), " PAYMENT SUKSES", Toast.LENGTH_SHORT).show();
} else {
Intent intent = new Intent(getApplicationContext(), ResultPayment.class);
intent.putExtra("data", json.toString());
startActivity(intent);
finish();
Toast.makeText(getApplicationContext(), "PAYMENT ERROR", Toast.LENGTH_SHORT).show();
}

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

}

}
}
}


private void connectSecondPay(int menuPaymentChannel) {

//set payment parameter
invoiceNumber = String.valueOf(AppsUtil.nDigitRandomNo(10));

directSDK = new DirectSDK();

PaymentItems paymentItems = new PaymentItems();
paymentItems.setDataAmount(AppsUtil.generateMoneyFormat("15000"));
paymentItems.setDataBasket("[{\"name\":\"sayur\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"},{\"name\":\"buah\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"}]");
paymentItems.setDataCurrency("360");
paymentItems.setDataWords(AppsUtil.SHA1(AppsUtil.generateMoneyFormat("15000") + "2074" + "eaM6i1JjS19J" + invoiceNumber + 360 + telephonyManager.getDeviceId()));
paymentItems.setDataMerchantChain("NA");
paymentItems.setDataSessionID(String.valueOf(AppsUtil.nDigitRandomNo(9)));
paymentItems.setDataTransactionID(invoiceNumber);
paymentItems.setDataMerchantCode("2074");
paymentItems.setDataImei(telephonyManager.getDeviceId());
paymentItems.setMobilePhone("08123123112");
paymentItems.setPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsBkd2EipFMMn3hy/rgQ3UBYs0WFPiei2RFSU0r/ClJXgyh88Eq+BpKtSCivbCjCZE7YOhcdbtYonFIi+isheNv00zqo5msQNCvhT45uYZ2Arvh8+F9xGE+y1KTS7ruYnzsDHYTBv+MHOJxs0Yn1mi3+y0KSMIBhz5iSIPzQgnLdNww0VnhwNdCwlm1EeBBE4ijWAm7IWxrFAsmMynUVCZRzZ5tTU4mb8BEDc854Pu94m1YAugw74f7JzMol7tPf5MO79moXdvDmPKVzNrEvMVFDLk+KnvI/yYe4uReQA4H2glNB+hGRPjqDXztY/6EJBHDo79cjKSBmuU5WGYReRiwIDAQAB");
paymentItems.isProduction(false);
paymentItems.setCustomerID("97842933");
paymentItems.setTokenPayment(tokenPayment);
directSDK.setCart_details(paymentItems);

//set layout parameter
// LayoutItems layoutItems = null;
// layoutItems = setLayout();
// directSDK.setLayout(layoutItems);

directSDK.setPaymentChannel(menuPaymentChannel);
directSDK.getResponse(new iPaymentCallback() {

@Override
public void onSuccess(final String text) {

try {
respongetTokenSDK = new JSONObject(text);

if (respongetTokenSDK.getString("res_response_code").equalsIgnoreCase("0000")) {
jsonRespon = text;
new RequestPayment().execute();
}
} catch (JSONException e) {
e.printStackTrace();
}

}

@Override
public void onError(final String text) {
Log.d("onError", text);
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
}

@Override
public void onException(Exception eSDK) {
eSDK.printStackTrace();
}
}, getApplicationContext());

tokenPayment = null;
customerID = null;
}

private void connectFirstPay(int menuPaymentChannel) {

//set payment parameter
invoiceNumber = String.valueOf(AppsUtil.nDigitRandomNo(10));
customerID = String.valueOf(AppsUtil.nDigitRandomNo(8));

directSDK = new DirectSDK();

PaymentItems paymentItems = new PaymentItems();
paymentItems.setDataAmount(AppsUtil.generateMoneyFormat("15000"));
paymentItems.setDataBasket("[{\"name\":\"sayur\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"},{\"name\":\"buah\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"}]");
paymentItems.setDataCurrency("360");
paymentItems.setDataWords(AppsUtil.SHA1(AppsUtil.generateMoneyFormat("15000") + "2074" + "eaM6i1JjS19J" + invoiceNumber + 360 + telephonyManager.getDeviceId()));
paymentItems.setDataMerchantChain("NA");
paymentItems.setDataSessionID(String.valueOf(AppsUtil.nDigitRandomNo(9)));
paymentItems.setDataTransactionID(invoiceNumber);
paymentItems.setDataMerchantCode("2074");
paymentItems.setDataImei(telephonyManager.getDeviceId());
paymentItems.setMobilePhone("08123123112");
paymentItems.setPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsBkd2EipFMMn3hy/rgQ3UBYs0WFPiei2RFSU0r/ClJXgyh88Eq+BpKtSCivbCjCZE7YOhcdbtYonFIi+isheNv00zqo5msQNCvhT45uYZ2Arvh8+F9xGE+y1KTS7ruYnzsDHYTBv+MHOJxs0Yn1mi3+y0KSMIBhz5iSIPzQgnLdNww0VnhwNdCwlm1EeBBE4ijWAm7IWxrFAsmMynUVCZRzZ5tTU4mb8BEDc854Pu94m1YAugw74f7JzMol7tPf5MO79moXdvDmPKVzNrEvMVFDLk+KnvI/yYe4uReQA4H2glNB+hGRPjqDXztY/6EJBHDo79cjKSBmuU5WGYReRiwIDAQAB");
paymentItems.isProduction(false);
paymentItems.setCustomerID(customerID);
directSDK.setCart_details(paymentItems);


//set layout parameter
// LayoutItems layoutItems = null;
// layoutItems = setLayout();
// directSDK.setLayout(layoutItems);

directSDK.setPaymentChannel(menuPaymentChannel);
directSDK.getResponse(new iPaymentCallback() {

@Override
public void onSuccess(final String text) {

try {
respongetTokenSDK = new JSONObject(text);

if (respongetTokenSDK.getString("res_response_code").equalsIgnoreCase("0000")) {
jsonRespon = text;
new RequestPayment().execute();
}
} catch (JSONException e) {
e.printStackTrace();
}

}

@Override
public void onError(final String text) {
Log.d("onError", text);
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
}

@Override
public void onException(Exception eSDK) {
eSDK.printStackTrace();
}
}, getApplicationContext());


tokenPayment = null;
customerID = null;
}

}
 

evbedp

Member
Licensed User
thank you erel it work now.

i need some help again... because i don't know how to call this code in B4A.
i have try with this code :
B4X:
jo.InitializeNewInstance("com.doku.sdkocov2.DirectSDK",Null)
    
    Log(jo.RunMethod("setCart_details",Array(CartDetail)))
    Log(jo.RunMethod("setPaymentChannel",Array(15)))
    Dim jb As JavaObject
    jb.InitializeNewInstance("com.doku.sdkocov2.interfaces.iPaymentCallback",Null)
    Log(jo.RunMethodjo("getResponse",Array(jb))) ---> this Code Error
'    Wait For (jb) JobDone(jb As HttpJob)

i Got this Error

Logger connected to: samsung SM-G532G
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
null
null
Error occurred on line: 90 (Main)
java.lang.RuntimeException: Method: getResponse not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:129)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:138)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
null
null
Error occurred on line: 90 (Main)
java.lang.RuntimeException: Method: getResponse not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:129)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:138)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
null
null
Error occurred on line: 90 (Main)
java.lang.RuntimeException: Method: getResponse not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:129)
at anywheresoftware.b4j.object.JavaObject.RunMethodJO(JavaObject.java:138)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
null
null
Error occurred on line: 90 (Main)
java.lang.InstantiationException: java.lang.Class<com.doku.sdkocov2.interfaces.iPaymentCallback> cannot be instantiated
at java.lang.Class.newInstance(Native Method)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:85)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **

this in android studio code
directSDK.getResponse(new iPaymentCallback() {

@Override
public void onSuccess(final String text) {
Log.d("RESPONSE", text);
try {
respongetTokenSDK = new JSONObject(text);

if (respongetTokenSDK.getString("res_response_code").equalsIgnoreCase("0000")) {
jsonRespon = text;
new RequestPayment().execute();
}
} catch (JSONException e) {
e.printStackTrace();
}

}

@Override
public void onError(final String text) {
Log.d("onError", text);
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
}

@Override
public void onException(Exception eSDK) {
eSDK.printStackTrace();
}
}, getApplicationContext());

how to call it in javaobject?
 
Upvote 0

evbedp

Member
Licensed User
may i create the iPaymentCallback Interface ? because in sample code android studio i just need call in "import com.doku.sdkocov2.interfaces.iPaymentCallback".
B4X:
import com.doku.sdkocov2.DirectSDK;
import com.doku.sdkocov2.interfaces.iPaymentCallback;
import com.doku.sdkocov2.model.LayoutItems;
import com.doku.sdkocov2.model.PaymentItems;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
 
Upvote 0

evbedp

Member
Licensed User
this interface will show up new page activity interface and after user input all require information this code will give me code from this aar library. how can i use javacode for this code?

i don't know how this code can be give me activity show.

android studio sample source code
B4X:
package com.doku.integratesdkocov2;

import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.doku.sdkocov2.DirectSDK;
import com.doku.sdkocov2.interfaces.iPaymentCallback;
import com.doku.sdkocov2.model.LayoutItems;
import com.doku.sdkocov2.model.PaymentItems;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    //declare variable
    DirectSDK directSDK;
    String invoiceNumber;
    JSONObject respongetTokenSDK;
    String jsonRespon;
    Button buttonCC, buttonDOKU, buttonMandiri, buttonVA, buttonAlfa, buttonFirstPay, buttonSecondPay;
    int REQUEST_CODE_MANDIRI = 3;
    int REQUEST_CODE_VIRTUALACCOUNT = 4;
    TelephonyManager telephonyManager;
    String responseToken, Challenge1, Challenge2, Challenge3, debitCard;
    int PayChanChoosed = 0;
    private static final int REQUEST_PHONE = 1;
    private static String[] PERMISSION_PHONE = {Manifest.permission.READ_PHONE_STATE};
    String tokenPayment = null;
    String customerID = null;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        setupLayout();
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setLogo(R.drawable.ico_merchant);
        toolbar.setTitle("Payment");
        TextView mTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
        AppsUtil.applyFont(getApplicationContext(), mTitle, "fonts/dokuregular.ttf");

        setSupportActionBar(toolbar);

        buttonCC = (Button) findViewById(R.id.buttonCCBiasa);
        buttonDOKU = (Button) findViewById(R.id.buttonDOKU);
        buttonMandiri = (Button) findViewById(R.id.buttonMandiri);
        buttonVA = (Button) findViewById(R.id.buttonVA);
        buttonAlfa = (Button) findViewById(R.id.buttonAlfa);
        buttonSecondPay = (Button) findViewById(R.id.buttonSecondPay);
        buttonFirstPay = (Button) findViewById(R.id.buttonCC);

        telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

        buttonCC.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
                        != PackageManager.PERMISSION_GRANTED) {
                    getPermissionFirst(1);
                } else {
                    connectSDK(1);
                }

            }
        });

        buttonDOKU.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
                        != PackageManager.PERMISSION_GRANTED) {
                    getPermissionFirst(2);
                } else {
                    connectSDK(2);
                }
            }
        });

        buttonMandiri.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(MainActivity.this, MandiriClickPay.class);
                startActivityForResult(i, REQUEST_CODE_MANDIRI);
            }
        });

        buttonVA.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(MainActivity.this, VirtualAccount.class);
                startActivityForResult(i, REQUEST_CODE_VIRTUALACCOUNT);
            }
        });

        buttonAlfa.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(MainActivity.this, VirtualAccountAlfa.class);
                startActivityForResult(i, REQUEST_CODE_VIRTUALACCOUNT);
            }
        });

        buttonFirstPay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                customerID = String.valueOf(AppsUtil.nDigitRandomNo(8));

                if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
                        != PackageManager.PERMISSION_GRANTED) {
                    getPermissionFirst(1);
                } else {
                    connectFirstPay(1);
                }

            }
        });

        buttonSecondPay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tokenPayment = "b194ee1e5305c3990015972243a6c7e24ef361f7";

                if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
                        != PackageManager.PERMISSION_GRANTED) {
                    getPermissionFirst(1);
                } else {
                    connectSecondPay(1);
                }
            }
        });


        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

    private void setupLayout() {

        Button buttonVA, buttonMandiri, buttonDOKU, buttonCC, buttonAlfa;
        TextView priceValue, price, qtyValue, qty, textProduct;

        buttonVA = (Button) findViewById(R.id.buttonVA);
        buttonMandiri = (Button) findViewById(R.id.buttonMandiri);
        buttonDOKU = (Button) findViewById(R.id.buttonDOKU);
        buttonCC = (Button) findViewById(R.id.buttonCC);
        buttonAlfa = (Button) findViewById(R.id.buttonAlfa);

        priceValue = (TextView) findViewById(R.id.priceValue);
        price = (TextView) findViewById(R.id.price);
        qtyValue = (TextView) findViewById(R.id.qtyValue);
        qty = (TextView) findViewById(R.id.qty);
        textProduct = (TextView) findViewById(R.id.textProduct);

        AppsUtil.applyFont(getApplicationContext(), buttonVA, "fonts/dokuregular.ttf");
        AppsUtil.applyFont(getApplicationContext(), buttonMandiri, "fonts/dokuregular.ttf");
        AppsUtil.applyFont(getApplicationContext(), buttonDOKU, "fonts/dokuregular.ttf");
        AppsUtil.applyFont(getApplicationContext(), buttonCC, "fonts/dokuregular.ttf");
        AppsUtil.applyFont(getApplicationContext(), buttonAlfa, "fonts/dokuregular.ttf");

        AppsUtil.applyFont(getApplicationContext(), priceValue, "fonts/dokuregular.ttf");
        AppsUtil.applyFont(getApplicationContext(), price, "fonts/dokuregular.ttf");
        AppsUtil.applyFont(getApplicationContext(), qtyValue, "fonts/dokuregular.ttf");
        AppsUtil.applyFont(getApplicationContext(), qty, "fonts/dokuregular.ttf");
        AppsUtil.applyFont(getApplicationContext(), textProduct, "fonts/dokuregular.ttf");


    }


    @TargetApi(Build.VERSION_CODES.M)
    private void getPermissionFirst(int paymentChanel) {
        PayChanChoosed = paymentChanel;
        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                Manifest.permission.READ_PHONE_STATE)) {

            ActivityCompat.requestPermissions(MainActivity.this,
                    new String[]{Manifest.permission.READ_PHONE_STATE},
                    REQUEST_PHONE);

        } else {

            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE},
                    REQUEST_PHONE);
        }

    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == REQUEST_PHONE) {
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                if (PayChanChoosed != 0) {
                    if (PayChanChoosed == 1 || PayChanChoosed == 2) {

                        if (tokenPayment != null) {
                            connectSecondPay(PayChanChoosed);
                        } else if (customerID != null) {
                            connectFirstPay(PayChanChoosed);
                        } else {
                            connectSDK(PayChanChoosed);
                        }
                    } else if (PayChanChoosed == 3) {
                        new MandiriPayment().execute();
                    }
                } else {
                    Toast.makeText(getApplicationContext(), "PAYCHAN ERROR", Toast.LENGTH_SHORT);
                }
            } else {
                Toast.makeText(getApplicationContext(), "Permission Failed", Toast.LENGTH_SHORT);
            }
        }
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK) {
            if (requestCode == 3 && data.getStringExtra("responseValue") != null) {
                responseToken = data.getStringExtra("responseValue");
                Challenge1 = data.getStringExtra("challenge1");
                Challenge2 = data.getStringExtra("challenge2");
                Challenge3 = data.getStringExtra("challenge3");
                debitCard = data.getStringExtra("debitCard");

                if (ActivityCompat.checkSelfPermission(MainActivity.this, String.valueOf(PERMISSION_PHONE))
                        != PackageManager.PERMISSION_GRANTED) {
                    getPermissionFirst(3);
                } else {

                    new MandiriPayment().execute();
                }

            } else if (requestCode == 4) {
                Log.d("Memilih : ", "payment Channel Virtual Account");
                Log.d("data VA", data.getStringExtra("data"));

            } else {
                Log.d("data", "KOSONG");
            }
        }
    }


    private void connectSDK(int menuPaymentChannel) {

        //set payment parameter
        invoiceNumber = String.valueOf(AppsUtil.nDigitRandomNo(10));

        directSDK = new DirectSDK();

        PaymentItems cardDetails = null;
        cardDetails = InputCard();
        directSDK.setCart_details(cardDetails);

        //set layout parameter
//        LayoutItems layoutItems = null;
//        layoutItems = setLayout();
//        directSDK.setLayout(layoutItems);

        directSDK.setPaymentChannel(menuPaymentChannel);
        directSDK.getResponse(new iPaymentCallback() {

            @Override
            public void onSuccess(final String text) {
                Log.d("RESPONSE", text);
                try {
                    respongetTokenSDK = new JSONObject(text);

                    if (respongetTokenSDK.getString("res_response_code").equalsIgnoreCase("0000")) {
                        jsonRespon = text;
                        new RequestPayment().execute();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onError(final String text) {
                Log.d("onError", text);
                Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onException(Exception eSDK) {
                eSDK.printStackTrace();
            }
        }, getApplicationContext());
    }


    private PaymentItems InputCard() {

        PaymentItems paymentItems = new PaymentItems();
        paymentItems.setDataAmount(AppsUtil.generateMoneyFormat("15000"));
        paymentItems.setDataBasket("[{\"name\":\"sayur\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"},{\"name\":\"buah\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"}]");
        paymentItems.setDataCurrency("360");
        paymentItems.setDataWords(AppsUtil.SHA1(AppsUtil.generateMoneyFormat("15000") + "2074" + "eaM6i1JjS19J" + invoiceNumber + 360 + telephonyManager.getDeviceId()));
        paymentItems.setDataMerchantChain("NA");
        paymentItems.setDataSessionID(String.valueOf(AppsUtil.nDigitRandomNo(9)));
        paymentItems.setDataTransactionID(invoiceNumber);
        paymentItems.setDataMerchantCode("2074");
        paymentItems.setDataImei(telephonyManager.getDeviceId());
        paymentItems.setMobilePhone("08123123112");
        paymentItems.setPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsBkd2EipFMMn3hy/rgQ3UBYs0WFPiei2RFSU0r/ClJXgyh88Eq+BpKtSCivbCjCZE7YOhcdbtYonFIi+isheNv00zqo5msQNCvhT45uYZ2Arvh8+F9xGE+y1KTS7ruYnzsDHYTBv+MHOJxs0Yn1mi3+y0KSMIBhz5iSIPzQgnLdNww0VnhwNdCwlm1EeBBE4ijWAm7IWxrFAsmMynUVCZRzZ5tTU4mb8BEDc854Pu94m1YAugw74f7JzMol7tPf5MO79moXdvDmPKVzNrEvMVFDLk+KnvI/yYe4uReQA4H2glNB+hGRPjqDXztY/6EJBHDo79cjKSBmuU5WGYReRiwIDAQAB");
        paymentItems.isProduction(false);
        return paymentItems;
    }


    private LayoutItems setLayout() {

        LayoutItems layoutItems = new LayoutItems();
        layoutItems.setFontPath("fonts/dinbold.ttf");
        layoutItems.setToolbarColor("#289c64");
        layoutItems.setToolbarTextColor("#FFFFFF");
        layoutItems.setFontColor("#121212");
        layoutItems.setBackgroundColor("#eaeaea");
        layoutItems.setLabelTextColor("#9a9a9a");
        layoutItems.setButtonBackground(getResources().getDrawable(R.drawable.button_orange));
        layoutItems.setButtonTextColor("#FFFFFF");

        return layoutItems;
    }


    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.doku.integratesdkocov2/http/host/path")
        );
        AppIndex.AppIndexApi.start(client, viewAction);
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.doku.integratesdkocov2/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        client.disconnect();
    }


    private class RequestPayment extends AsyncTask<String, String, JSONObject> {

        private ProgressDialog pDialog;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(MainActivity.this);
            pDialog.setMessage("Mohon Tunggu ...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(false);
            pDialog.show();

        }

        @Override
        protected JSONObject doInBackground(String... args) {
            JSONObject defResp = null;

            try {
                List<NameValuePair> data = new ArrayList<NameValuePair>(3);
                data.add(new BasicNameValuePair("data", jsonRespon));

                // Getting JSON from URL
                String conResult = ApiConnection.httpsConnection(MainActivity.this,
                        Constants.URL_CHARGING_DOKU_DAN_CC, data);
                Log.d("CHARGING PAYMENT", conResult);

                defResp = new JSONObject(conResult);

            } catch (JSONException e) {
                e.printStackTrace();
            }
            return defResp;
        }

        @Override
        protected void onPostExecute(JSONObject json) {

            pDialog.dismiss();

            if (json != null) {
                try {

                    if (json.getString("res_response_code").equalsIgnoreCase("0000") && json != null) {
                        Intent intent = new Intent(getApplicationContext(), ResultPayment.class);
                        intent.putExtra("data", json.toString());
                        startActivity(intent);
                        finish();
                        Toast.makeText(getApplicationContext(), " PAYMENT SUKSES", Toast.LENGTH_SHORT).show();
                    } else {
                        Intent intent = new Intent(getApplicationContext(), ResultPayment.class);
                        intent.putExtra("data", json.toString());
                        startActivity(intent);
                        finish();
                        Toast.makeText(getApplicationContext(), "PAYMENT ERROR", Toast.LENGTH_SHORT).show();
                    }

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

                }

            }
        }
    }


    private class MandiriPayment extends AsyncTask<String, String, JSONObject> {

        private ProgressDialog pDialog;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(MainActivity.this);
            pDialog.setMessage("Mohon Tunggu ...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(false);
            pDialog.show();

        }

        @Override
        protected JSONObject doInBackground(String... args) {
            JSONObject defResp = null;

            try {

                JSONObject jGroup = new JSONObject();// /main Object
                try {

                    invoiceNumber = String.valueOf(AppsUtil.nDigitRandomNo(10));

                    jGroup.put("req_transaction_id", invoiceNumber);
                    jGroup.put("req_payment_channel", "02");
                    jGroup.put("req_card_number", debitCard);
                    jGroup.put("req_device_id", telephonyManager.getDeviceId());
                    jGroup.put("req_challenge_code_1", Challenge1);
                    jGroup.put("req_challenge_code_2", Challenge2);
                    jGroup.put("req_challenge_code_3", Challenge3);
                    jGroup.put("req_response_token", responseToken);

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

                Log.d("request Mandiri", jGroup.toString());
                List<NameValuePair> data = new ArrayList<NameValuePair>(3);
                data.add(new BasicNameValuePair("data", jGroup.toString()));

                // Getting JSON from URL
                String conResult = ApiConnection.httpsConnection(MainActivity.this,
                        Constants.URL_CHARGING_MANDIRI_CLICKPAY, data);
                Log.d("DATA PAYMENT", conResult);

                defResp = new JSONObject(conResult);

            } catch (JSONException e) {
                e.printStackTrace();
            }
            return defResp;
        }

        @Override
        protected void onPostExecute(JSONObject json) {

            pDialog.dismiss();

            if (json != null) {
                try {
                    if (json.getString("res_response_code").equalsIgnoreCase("0000") && json != null) {
                        Intent intent = new Intent(getApplicationContext(), ResultPayment.class);
                        intent.putExtra("data", json.toString());
                        startActivity(intent);
                        finish();
                        Toast.makeText(getApplicationContext(), " PAYMENT SUKSES", Toast.LENGTH_SHORT).show();
                    } else {
                        Intent intent = new Intent(getApplicationContext(), ResultPayment.class);
                        intent.putExtra("data", json.toString());
                        startActivity(intent);
                        finish();
                        Toast.makeText(getApplicationContext(), "PAYMENT ERROR", Toast.LENGTH_SHORT).show();
                    }

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

                }

            }
        }
    }


    private void connectSecondPay(int menuPaymentChannel) {

        //set payment parameter
        invoiceNumber = String.valueOf(AppsUtil.nDigitRandomNo(10));

        directSDK = new DirectSDK();

        PaymentItems paymentItems = new PaymentItems();
        paymentItems.setDataAmount(AppsUtil.generateMoneyFormat("15000"));
        paymentItems.setDataBasket("[{\"name\":\"sayur\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"},{\"name\":\"buah\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"}]");
        paymentItems.setDataCurrency("360");
        paymentItems.setDataWords(AppsUtil.SHA1(AppsUtil.generateMoneyFormat("15000") + "2074" + "eaM6i1JjS19J" + invoiceNumber + 360 + telephonyManager.getDeviceId()));
        paymentItems.setDataMerchantChain("NA");
        paymentItems.setDataSessionID(String.valueOf(AppsUtil.nDigitRandomNo(9)));
        paymentItems.setDataTransactionID(invoiceNumber);
        paymentItems.setDataMerchantCode("2074");
        paymentItems.setDataImei(telephonyManager.getDeviceId());
        paymentItems.setMobilePhone("08123123112");
        paymentItems.setPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsBkd2EipFMMn3hy/rgQ3UBYs0WFPiei2RFSU0r/ClJXgyh88Eq+BpKtSCivbCjCZE7YOhcdbtYonFIi+isheNv00zqo5msQNCvhT45uYZ2Arvh8+F9xGE+y1KTS7ruYnzsDHYTBv+MHOJxs0Yn1mi3+y0KSMIBhz5iSIPzQgnLdNww0VnhwNdCwlm1EeBBE4ijWAm7IWxrFAsmMynUVCZRzZ5tTU4mb8BEDc854Pu94m1YAugw74f7JzMol7tPf5MO79moXdvDmPKVzNrEvMVFDLk+KnvI/yYe4uReQA4H2glNB+hGRPjqDXztY/6EJBHDo79cjKSBmuU5WGYReRiwIDAQAB");
        paymentItems.isProduction(false);
        paymentItems.setCustomerID("97842933");
        paymentItems.setTokenPayment(tokenPayment);
        directSDK.setCart_details(paymentItems);

        //set layout parameter
//        LayoutItems layoutItems = null;
//        layoutItems = setLayout();
//        directSDK.setLayout(layoutItems);

        directSDK.setPaymentChannel(menuPaymentChannel);
        directSDK.getResponse(new iPaymentCallback() {

            @Override
            public void onSuccess(final String text) {

                try {
                    respongetTokenSDK = new JSONObject(text);

                    if (respongetTokenSDK.getString("res_response_code").equalsIgnoreCase("0000")) {
                        jsonRespon = text;
                        new RequestPayment().execute();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onError(final String text) {
                Log.d("onError", text);
                Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onException(Exception eSDK) {
                eSDK.printStackTrace();
            }
        }, getApplicationContext());

        tokenPayment = null;
        customerID = null;
    }

    private void connectFirstPay(int menuPaymentChannel) {

        //set payment parameter
        invoiceNumber = String.valueOf(AppsUtil.nDigitRandomNo(10));
        customerID = String.valueOf(AppsUtil.nDigitRandomNo(8));

        directSDK = new DirectSDK();

        PaymentItems paymentItems = new PaymentItems();
        paymentItems.setDataAmount(AppsUtil.generateMoneyFormat("15000"));
        paymentItems.setDataBasket("[{\"name\":\"sayur\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"},{\"name\":\"buah\",\"amount\":\"10000.00\",\"quantity\":\"1\",\"subtotal\":\"10000.00\"}]");
        paymentItems.setDataCurrency("360");
        paymentItems.setDataWords(AppsUtil.SHA1(AppsUtil.generateMoneyFormat("15000") + "2074" + "eaM6i1JjS19J" + invoiceNumber + 360 + telephonyManager.getDeviceId()));
        paymentItems.setDataMerchantChain("NA");
        paymentItems.setDataSessionID(String.valueOf(AppsUtil.nDigitRandomNo(9)));
        paymentItems.setDataTransactionID(invoiceNumber);
        paymentItems.setDataMerchantCode("2074");
        paymentItems.setDataImei(telephonyManager.getDeviceId());
        paymentItems.setMobilePhone("08123123112");
        paymentItems.setPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsBkd2EipFMMn3hy/rgQ3UBYs0WFPiei2RFSU0r/ClJXgyh88Eq+BpKtSCivbCjCZE7YOhcdbtYonFIi+isheNv00zqo5msQNCvhT45uYZ2Arvh8+F9xGE+y1KTS7ruYnzsDHYTBv+MHOJxs0Yn1mi3+y0KSMIBhz5iSIPzQgnLdNww0VnhwNdCwlm1EeBBE4ijWAm7IWxrFAsmMynUVCZRzZ5tTU4mb8BEDc854Pu94m1YAugw74f7JzMol7tPf5MO79moXdvDmPKVzNrEvMVFDLk+KnvI/yYe4uReQA4H2glNB+hGRPjqDXztY/6EJBHDo79cjKSBmuU5WGYReRiwIDAQAB");
        paymentItems.isProduction(false);
        paymentItems.setCustomerID(customerID);
        directSDK.setCart_details(paymentItems);


        //set layout parameter
//        LayoutItems layoutItems = null;
//        layoutItems = setLayout();
//        directSDK.setLayout(layoutItems);

        directSDK.setPaymentChannel(menuPaymentChannel);
        directSDK.getResponse(new iPaymentCallback() {

            @Override
            public void onSuccess(final String text) {

                try {
                    respongetTokenSDK = new JSONObject(text);

                    if (respongetTokenSDK.getString("res_response_code").equalsIgnoreCase("0000")) {
                        jsonRespon = text;
                        new RequestPayment().execute();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onError(final String text) {
                Log.d("onError", text);
                Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onException(Exception eSDK) {
                eSDK.printStackTrace();
            }
        }, getApplicationContext());


        tokenPayment = null;
        customerID = null;
    }

}
 
Upvote 0

evbedp

Member
Licensed User
like this thread : https://www.b4x.com/android/forum/t...ateevent-createeventfromui.40856/#post-244834

i have tried
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Dim jo As JavaObject
    Dim context As Object = GetBA
    jo.InitializeNewInstance("com.doku.sdkocov2.DirectSDK",Null)
  
    Log(jo.RunMethod("setCart_details",Array(CartDetail)))
    Log(jo.RunMethod("setPaymentChannel",Array(15)))
    Dim IPaymentCallBack As Object = jo.CreateEventFromUI("com.doku.sdkocov2.interfaces.iPaymentCallback","Doku",Null)
    Log(IPaymentCallBack)
    jo.RunMethod("getResponse",Array(IPaymentCallBack,context))
    Dim dokuview As View
    dokuview = jo
    Activity.AddView(dokuview,0,0,100%x,100%y)
End Sub

got this error
Logger connected to: samsung SM-G532G
--------- beginning of main
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
null
null
null
Error occurred on line: 92 (Main)
java.lang.RuntimeException: Method: getResponse not matched.
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:129)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.example.main.afterFirstLayout(main.java:104)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
** Activity (main) Resume **
 
Last edited:
Upvote 0

evbedp

Member
Licensed User
it should be only one iPaymentCallBack. because when i remove

import com.doku.sdkocov2.interfaces.iPaymentCallback;

in source code in android studio.

the code in
directSDK.getResponse(new iPaymentCallback() {
will be error.
 
Upvote 0

evbedp

Member
Licensed User
i had try make wrapper library for this AAR library. but i'm still beginner in java programming language.
i have some trouble calling event.

B4X:
pBA.raiseEvent(this,mEventName + "_created",true);

in b4a log i got ignoring event:doku_created

Logger connected to: samsung SM-G532G
--------- beginning of main
[+]r_hnd(0xae478500), client(37), share_fd(43)
register, handle(0xae478500) (w:540 h:960 s:544 f:0x1 u:0x000b00)
-1 received
writer error
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1988)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:357)
at anywheresoftware.b4a.remotelogger.Connector$Writer.run(Connector.java:160)
at java.lang.Thread.run(Thread.java:818)
** Activity (main) Pause, UserClosed = true **
System.exit called, status: 0
VM exiting with result code 0, cleanup skipped.
SELinux: seapp_context_lookup: seinfo=default, level=s0:c512,c768, pkgname=b4a.example
TimaSignature is unavailable
Added TimaKeyStore provider
ClassLoader referenced unknown path: /data/app/b4a.example-2/lib/arm
Starting remote logger. Port: 35352
#1 mView = com.android.internal.policy.PhoneWindow$DecorView{6a605f3 I.E...... R.....ID 0,0-0,0}
Use EGL_SWAP_BEHAVIOR_PRESERVED: false
Initialized EGL, version 1.4
Surface::connect(this=0xae1f5f00,api=1)
new_window_surface returns 0x3000
Surface::allocateBuffers(this=0xae1f5f00)
*** Debugger waiting for connection (0) ***
MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
DTS_GLAPI : DTS is not allowed for Package : b4a.example
[+]r_hnd(0xae4781e0), client(38), share_fd(37)
register, handle(0xae4781e0) (w:540 h:960 s:544 f:0x1 u:0x000b00)
#1 mView = android.widget.LinearLayout{c014786 V.E...... ......I. 0,0-0,0 #10203a4 android:id/toast_layout_root}
Surface::connect(this=0xae1f7400,api=1)
new_window_surface returns 0x3000
Surface::allocateBuffers(this=0xae1f7400)
MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
[+]r_hnd(0xae4783c0), client(38), share_fd(41)
register, handle(0xae4783c0) (w:408 h:75 s:416 f:0x1 u:0x000b00)
*** Debugger waiting for connection (1) ***
*** Service (starter) Create ***
After accept
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
doku
ignoring event: doku_created
Permintaan Permission
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Timeline: Activity_idle id: android.os.BinderProxy@a091062 time:239413321
[+]r_hnd(0xae478500), client(38), share_fd(45)
register, handle(0xae478500) (w:540 h:960 s:544 f:0x1 u:0x000b00)
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
** Activity (main) Resume **
Timeline: Activity_idle id: android.os.BinderProxy@a091062 time:239413423
[+]r_hnd(0xae478640), client(38), share_fd(47)
register, handle(0xae478640) (w:540 h:960 s:544 f:0x1 u:0x000b00)
Surface::disconnect(this=0xae1f7400,api=1)
unregister, handle(0xae4783c0) (w:408 h:75 s:416 f:0x1 u:0x000b00)
[-]r_hnd(0xae4783c0), client(38), share_fd(41)
#3 mView = null
-1 received
writer error
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1988)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:357)
at anywheresoftware.b4a.remotelogger.Connector$Writer.run(Connector.java:160)
at java.lang.Thread.run(Thread.java:818)
Starting remote logger. Port: 35352
After accept
-1 received
writer error
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1988)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:357)
at anywheresoftware.b4a.remotelogger.Connector$Writer.run(Connector.java:160)
at java.lang.Thread.run(Thread.java:818)
Starting remote logger. Port: 35352
After accept
 
Upvote 0
Top