Commit 78a434e0 authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Cancel fix

parent 22ff6701
...@@ -135,90 +135,110 @@ public class BuyerInfoActivity extends BaseActivity { ...@@ -135,90 +135,110 @@ public class BuyerInfoActivity extends BaseActivity {
.setCancelable(true) .setCancelable(true)
.setPositiveButton(R.string.cancel, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int id) { public void onClick(DialogInterface dialogInterface, int id) {
new Thread() { hasRights(getString(R.string.cancel_transaction), new String[]{
"GESSALES"
}, new Runnable() {
@Override @Override
public void run() { public void run() {
try { new Thread() {
hasRights(getString(R.string.configurate), new String[]{ @Override
"GESSALES" public void run() {
}, new Runnable() { try {
@Override nemopaySession.cancelTransaction(article.get("fundation_id").intValue(), article.get("purchase_id").intValue(), true);
public void run() { Thread.sleep(100);
} catch (final Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
try { try {
nemopaySession.cancelTransaction(article.get("fundation_id").intValue(), article.get("purchase_id").intValue(), true); final JsonNode response = nemopaySession.getRequest().getJSONResponse();
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage()); if (response.has("error") && response.get("error").has("message")) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.stopLoading();
dialog.errorDialog(BuyerInfoActivity.this, getString(R.string.cancel_transaction), response.get("error").get("message").textValue());
}
});
} else
throw new Exception("");
} catch (Exception e1) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.stopLoading();
dialog.errorDialog(BuyerInfoActivity.this, getString(R.string.cancel_transaction), e.getMessage());
}
});
} }
} }
}, new Runnable() { }
@Override }.start();
public void run() { }
}, new Runnable() {
@Override
public void run() {
new Thread() {
@Override
public void run() {
try {
nemopaySession.cancelTransaction(article.get("fundation_id").intValue(), article.get("purchase_id").intValue(), false);
Thread.sleep(100);
} catch (final Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
try { try {
nemopaySession.cancelTransaction(article.get("fundation_id").intValue(), article.get("purchase_id").intValue(), false); final JsonNode response = nemopaySession.getRequest().getJSONResponse();
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage()); if (response.has("error") && response.get("error").has("message")) {
} runOnUiThread(new Runnable() {
} @Override
}); public void run() {
Thread.sleep(100); dialog.stopLoading();
dialog.errorDialog(BuyerInfoActivity.this, getString(R.string.cancel_transaction), response.get("error").get("message").textValue());
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.stopLoading();
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(BuyerInfoActivity.this);
alertDialogBuilder
.setTitle(R.string.cancel_transaction)
.setMessage(getString(R.string.transaction_canceled))
.setCancelable(true)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int id) {
try {
startBuyerInfoActivity(BuyerInfoActivity.this, badgeId);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
dialog.errorDialog(BuyerInfoActivity.this, getResources().getString(R.string.information_collection), getResources().getString(R.string.error_view), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int id) {
finish();
}
});
}
} }
}); });
} else
dialog.createDialog(alertDialogBuilder); throw new Exception("");
} catch (Exception e1) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.stopLoading();
dialog.errorDialog(BuyerInfoActivity.this, getString(R.string.cancel_transaction), e.getMessage());
}
});
}
} }
}); }
} catch (final Exception e) { }.start();
Log.e(LOG_TAG, "error: " + e.getMessage()); }
});
try {
final JsonNode response = nemopaySession.getRequest().getJSONResponse(); dialog.stopLoading();
if (response.has("error") && response.get("error").has("message")) { final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(BuyerInfoActivity.this);
runOnUiThread(new Runnable() { alertDialogBuilder
.setTitle(R.string.cancel_transaction)
.setMessage(getString(R.string.transaction_canceled))
.setCancelable(true)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int id) {
try {
startBuyerInfoActivity(BuyerInfoActivity.this, badgeId);
} catch (Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
dialog.errorDialog(BuyerInfoActivity.this, getResources().getString(R.string.information_collection), getResources().getString(R.string.error_view), new DialogInterface.OnClickListener() {
@Override @Override
public void run() { public void onClick(DialogInterface dialogInterface, int id) {
dialog.stopLoading(); finish();
dialog.errorDialog(BuyerInfoActivity.this, getString(R.string.cancel_transaction), response.get("error").get("message").textValue());
} }
}); });
} else }
throw new Exception("");
} catch (Exception e1) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.stopLoading();
dialog.errorDialog(BuyerInfoActivity.this, getString(R.string.cancel_transaction), e.getMessage());
}
});
} }
} });
}
}.start(); dialog.createDialog(alertDialogBuilder);
} }
}) })
.setNegativeButton(R.string.do_nothing, null); .setNegativeButton(R.string.do_nothing, null);
......
...@@ -223,27 +223,27 @@ public class NemopaySession { ...@@ -223,27 +223,27 @@ public class NemopaySession {
if (hasSalesRights) if (hasSalesRights)
return request( return request(
"POSS3", "GESSALES",
"cancel", "cancelTransactionRow",
new HashMap<String, Object>() {{ new HashMap<String, Object>() {{
put("fun_id", foundationId); put("fun_id", foundationId);
put("pur_id", purchaseId); put("id", purchaseId);
}}, }},
new String[]{ new String[]{
"POSS3" "POSS3",
"GESSALES"
} }
); );
else else
return request( return request(
"GESSALES", "POSS3",
"cancelTransactionRow", "cancel",
new HashMap<String, Object>() {{ new HashMap<String, Object>() {{
put("fun_id", foundationId); put("fun_id", foundationId);
put("pur_id", purchaseId); put("pur_id", purchaseId);
}}, }},
new String[]{ new String[]{
"POSS3", "POSS3"
"GESSALES"
} }
); );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment