com.paypal.android.sdk.payments.PaymentConfirmation Java Examples
The following examples show how to use
com.paypal.android.sdk.payments.PaymentConfirmation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PayPal.java From react-native-paypal with MIT License | 6 votes |
public void handleActivityResult(final int requestCode, final int resultCode, final Intent data) { if (requestCode != paymentIntentRequestCode) { return; } if (resultCode == Activity.RESULT_OK) { PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if (confirm != null) { successCallback.invoke( confirm.toJSONObject().toString(), confirm.getPayment().toJSONObject().toString() ); } } else if (resultCode == Activity.RESULT_CANCELED) { errorCallback.invoke(ERROR_USER_CANCELLED); } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { errorCallback.invoke(ERROR_INVALID_CONFIG); } currentActivity.stopService(new Intent(currentActivity, PayPalService.class)); }
Example #2
Source File: ShoppingCardActivity.java From android-paypal-example with Apache License 2.0 | 5 votes |
@Override protected 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); if (confirm != null) { try { Log.i(TAG, confirm.toJSONObject().toString(4)); Log.i(TAG, confirm.getPayment().toJSONObject().toString(4)); /** * TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification * or consent completion. * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ * for more details. * * For sample mobile backend interactions, see * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend */ String payment_id = confirm.toJSONObject().getJSONObject("response").getString("id"); verifyPaymentOnServer(payment_id , confirm); displayResultText("PaymentConfirmation info received from PayPal"); } catch (JSONException e) { Log.e(TAG, "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i(TAG, "The user canceled."); } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { Log.i( TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } } }
Example #3
Source File: HistorySingleActivity.java From UberClone with MIT License | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PAYPAL_REQUEST_CODE){ if(resultCode == Activity.RESULT_OK){ PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if(confirm != null){ try{ JSONObject jsonObj = new JSONObject(confirm.toJSONObject().toString()); String paymentResponse = jsonObj.getJSONObject("response").getString("state"); if(paymentResponse.equals("approved")){ Toast.makeText(getApplicationContext(), "Payment successful", Toast.LENGTH_LONG).show(); historyRideInfoDb.child("customerPaid").setValue(true); mPay.setEnabled(false); } } catch (JSONException e) { e.printStackTrace(); } } }else{ Toast.makeText(getApplicationContext(), "Payment unsuccessful", Toast.LENGTH_LONG).show(); } } }
Example #4
Source File: Utils.java From flickr-uploader with GNU General Public License v2.0 | 5 votes |
public static boolean onActivityResult(int requestCode, int resultCode, Intent data) { boolean consumed = false; if (requestCode == PAYPAL_REQUEST_CODE_PAYMENT) { consumed = true; if (resultCode == Activity.RESULT_OK) { PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if (confirm != null) { String paypal_result_confirmation = confirm.toJSONObject().toString(); LOG.info(paypal_result_confirmation); Utils.setStringProperty("paypal_result_confirmation", paypal_result_confirmation); validatePaypalPayment(paypal_result_confirmation); // TODO: send 'confirm' to your server for verification // or consent // completion. // see // https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ // for more details. } } else if (resultCode == Activity.RESULT_CANCELED) { LOG.info("The user canceled."); } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { LOG.warn("An invalid Payment was submitted. Please see the docs."); } } else if (IabHelper.get(false) != null && IabHelper.get(false).handleActivityResult(requestCode, resultCode, data)) { consumed = true; } return consumed; }