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;
}
}