I'm developing a mcommerce on the android platform with integration with paypal, the question I have is how to return the payment transaction id?
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_PAYMENT) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirm =
data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
//Paypal
if (confirm != null) {
// try { WrapperLog.info ("Paypal Return:" + confirm.toJSONObject (). ToString ()); WrapperLog.info ("Return getPaypal:" + confirm.getPayment (). ToJSONObject () .ToString ());
JSONObject resultPaypal;
try {
resultPaypal = new JSONObject(confirm.toJSONObject().toString()).optJSONObject("response");
this.status_pagamento = resultPaypal.optString("state");
// String idPagamento = resultPaypal.optString ("id");
WrapperLog.info("Retorno Status: "+this.status_pagamento);
} catch (org.codehaus.jettison.json.JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
FragmentBuilder.replaceFragment(getActivity(), android.R.id.content, FragmentsEnum.PRODUTO_LIST);
Toast.makeText(
getActivity(),
"PaymentConfirmation info received from PayPal", Toast.LENGTH_LONG)
.show();
//} catch (JSONException e) { // Log.e (TAG, "an extremely unlikely failure occurred:", e); //} } Here is the return result: remembering that it is the "Quick payment received (transaction unique ID 03E88457BL964445L)" that I want to return to
Paypal return: {"response": {"state": "approved", "id": "PAY-code", "create_time": "2015-04-16T20: 06: 58Z", "intent": "paypal_sdk_version": "2.8.8", "product_name": "PayPal-Android-SDK", "environment": "sandbox"}, response_type ":" payment "}
GetPaypal return: {"amount": "1.00", "short_description": "Mobile", "details": {"tax": "0.00", "subtotal": "1.00" "" "," intent ":" sale "," currency_code ":" BRL "," item_list ": {" items ": [" quantity ":" 1 "," price ":" 1.00 " "s", "currency": "BRL", "name": "memory card."}]}}
If anyone can help me I will be very grateful.