本文整理汇总了Java中com.paypal.android.sdk.payments.PaymentConfirmation类的典型用法代码示例。如果您正苦于以下问题:Java PaymentConfirmation类的具体用法?Java PaymentConfirmation怎么用?Java PaymentConfirmation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PaymentConfirmation类属于com.paypal.android.sdk.payments包,在下文中一共展示了PaymentConfirmation类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
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));
}
示例2: map
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
private PayPalResult map(Result result) {
switch (result.getResultCode()) {
case Activity.RESULT_OK:
final PaymentConfirmation confirmation = result.getData()
.getParcelableExtra(
com.paypal.android.sdk.payments.PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirmation != null && confirmation.getProofOfPayment() != null) {
return new BillingNavigator.PayPalResult(BillingNavigator.PayPalResult.SUCCESS,
confirmation.getProofOfPayment()
.getPaymentId());
} else {
return new BillingNavigator.PayPalResult(BillingNavigator.PayPalResult.ERROR, null);
}
case Activity.RESULT_CANCELED:
return new BillingNavigator.PayPalResult(BillingNavigator.PayPalResult.CANCELLED, null);
case PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID:
default:
return new BillingNavigator.PayPalResult(BillingNavigator.PayPalResult.ERROR, null);
}
}
示例3: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirmation = null;
if (intent.hasExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION)) {
confirmation = intent
.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
this.callbackContext.success(confirmation.toJSONObject());
} else {
this.callbackContext
.error("payment was ok but no confirmation");
}
} else if (resultCode == Activity.RESULT_CANCELED) {
this.callbackContext.error("payment cancelled");
} else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
this.callbackContext.error("payment invalid");
} else {
this.callbackContext.error(resultCode);
}
}
示例4: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@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.");
}
}
}
示例5: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Postpone a Payment-Result to onResumeFragment, back from payment
// returns null-data.
PaymentConfirmation confirm = null;
if (data != null) {
confirm = data
.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
}
paymentResult = new PaymentResult(resultCode, confirm);
}
示例6: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
showThankYouNote();
ParseObject confirmation = new ParseObject("PaymentConfirmatons");
confirmation.put("donorName", getUserFullName());
confirmation.put("donorEmail", getUserEmail());
confirmation.put("patient", Patient.createWithoutData(Patient.class, getPatientId()));
confirmation.put("amount", getDonationAmount());
confirmation.put("confirmation", confirm.toJSONObject().toString(4));
confirmation.put("isAnonymous", isAnonymousDonation());
confirmation.saveInBackground();
prefs.clear();
} catch (JSONException e) {
Log.e(TAG_PAYPAL, "an extremely unlikely failure occurred: ", e);
}
}
}
else if (resultCode == Activity.RESULT_CANCELED) {
Log.i(TAG_PAYPAL, "The user canceled.");
}
else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
Log.i(TAG_PAYPAL, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
}
}
示例7: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@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
*/
Toast.makeText(
getApplicationContext(),
"PaymentConfirmation info received from PayPal", Toast.LENGTH_LONG)
.show();
} 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.");
}
}
}
示例8: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
Log.i("paymentExample", confirm.toJSONObject().toString(4));
String serverUserId = getAccountServerId();
ParseObject gameScore = new ParseObject("Payment");
gameScore.put("gift_Id", g.getServerId());
gameScore.put("person_Id", serverUserId);
gameScore.put("quantity", g.getPrice());
gameScore.put("token_paypal", confirm.getProofOfPayment().getPaymentIdentifier());
gameScore.saveInBackground();
setUpUiBuyed(confirm.getPayment().getAmount());
} catch (JSONException e) {
Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.i("paymentExample", "The user canceled.");
} else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
}
}
示例9: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
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;
}
示例10: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
//If the result is from paypal
if (requestCode == PAYPAL_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
//If the result is OK i.e. user has not canceled the payment
//Getting the payment confirmation
PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
//if confirmation is not null
if (confirm != null) {
try {
//Getting the payment details
JSONObject paypalDetailsJson = confirm.toJSONObject();
JSONObject paypalResponseJson = paypalDetailsJson.getJSONObject("response");
Payment payment = new Payment();
payment.setPaymentId(paypalResponseJson.getString("id"));
payment.setAmount(view.getPaymentAmount());
payment.setTimestamp(System.currentTimeMillis());
//Sending payment info on Firebase
//Registering an payment on server
model.savePaymentInfo(payment);
showLog("PAYPAL: SUCCESS");
showLog("PAYPAL: state -> " + paypalResponseJson.getString("state"));
showLog("PAYPAL: id -> " + paypalResponseJson.getString("id"));
//Show dialog <Payment Success>
new InfoDialogCustom()
.create(getContext(), getContext().getString(R.string.payment_success_title_info),
getContext().getString(R.string.payment_success_description_info))
.setOnOkClickedListener(new IDialogInfoOkClickedListener() {
@Override
public void onOkClick() {
view.clearPaymentAmount();
view.setBtnPayEnabled(true);
}
})
.show(600);
} catch (JSONException e) {
showLog("an extremely unlikely failure occurred: " + e);
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
showLog("The user canceled.");
} else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
showLog("An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
}
}
}
示例11: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//If the result is from paypal
if (requestCode == PAYPAL_REQUEST_CODE) {
//If the result is OK i.e. user has not canceled the payment
if (resultCode == Activity.RESULT_OK) {
//Getting the payment confirmation
PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
//if confirmation is not null
if (confirm != null) {
String state = confirm.getProofOfPayment().getState();
if (state.equals(getString(R.string.approved))) {
enablebutton(false);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
emails = sharedPreferences.getString(getString(R.string.emailaddr), null);
for (int i = 0; i < StartersListClass.starterclasses.size(); i++) {
titles.add(StartersListClass.starterclasses.get(i).getTitles());
prices.add(StartersListClass.starterclasses.get(i).getPrices());
}
new EndpointsAsyncTask().execute();
} else {
Toast.makeText(getContext(), R.string.errorpay, Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(getContext(), R.string.confirmnull, Toast.LENGTH_LONG).show();
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.i("paymentExample", "The user canceled.");
} else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
Log.i("paymentExample", "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
}
}
}
示例12: onResumeFragments
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@Override
protected void onResumeFragments() {
super.onResumeFragments();
// Process a PaymentResult from onActivityResult
if (paymentResult != null) {
int resultCode = paymentResult.resultCode;
PaymentConfirmation confirm = paymentResult.confirmation;
paymentResult = null;
if (resultCode == Activity.RESULT_OK && confirm != null) {
if (selectedPriceId == null) {
MessageDialog.show(R.string.shop_activity_missingprice,
this);
return;
}
JSONObject paymentJson = confirm.toJSONObject();
// Save Payment, so that payment can be verified later.
Account account = new Account(accountName,
Constants.ACCOUNT_TYPE);
AccountManager accountManager = AccountManager.get(this);
SyncUtils.savePayment(account, accountManager, paymentJson,
selectedPriceId);
SyncUtils.startPaymentVerification();
// Start Timer to verify Payment if Verification could not be
// done now.
PaymentVerificationService
.startVerificationTimer(getApplicationContext());
// Send Confirmation to server
boolean verifStarted = false;
try {
String jsonData = paymentJson.toString(1);
VerifyPaymentProgressDialog progressDialog = VerifyPaymentProgressDialog
.newInstance(selectedPriceId, jsonData, accountName);
progressDialog.show(this.getSupportFragmentManager(),
"VerifyPaymentProgressDialog");
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "PaymentConfirmation: " + jsonData);
}
verifStarted = true;
} catch (JSONException e) {
MessageDialog.show(R.string.shop_activity_invalidsyntax,
this);
Log.e(TAG, "Failed to convert Payment to JSON.", e);
SyncUtils.savePayment(account, accountManager, null, null);
} finally {
if (!verifStarted) {
SyncUtils.stopPaymentVerification();
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.i(TAG, "The user canceled the payment-flow");
} else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) {
MessageDialog.show(R.string.shop_activity_invalidpayment, this);
Log.i(TAG, "An invalid payment was submitted.");
} else {
MessageDialog.show(R.string.shop_activity_invalidpayment, this);
Log.e(TAG, "PaymentResult is unknown. Result:" + resultCode
+ " Confirmation:" + confirm);
}
}
getSupportLoaderManager().initLoader(LOADID_PRICES, null, this);
View progressBar = findViewById(R.id.progressBar);
View reloadBtn = findViewById(R.id.reloadBtn);
reloadBtn.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
getListView().setEmptyView(progressBar);
// Show a Message from a delayed Verification
String msg = getIntent().getStringExtra(PARM_MSG);
if (msg != null) {
MessageDialog.show(msg, this);
getIntent().removeExtra(PARM_MSG);
}
}
示例13: PaymentResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
public PaymentResult(int resultCode, PaymentConfirmation confirmation) {
super();
this.resultCode = resultCode;
this.confirmation = confirmation;
}
示例14: onActivityResult
import com.paypal.android.sdk.payments.PaymentConfirmation; //导入依赖的package包/类
@Override
public void onActivityResult( int requestCode, int resultCode, Intent data )
{
if ( requestCode == ACTIVITY_REQUEST_CODE_PAYPAL )
{
if ( resultCode == Activity.RESULT_OK )
{
PaymentConfirmation paymentConfirmation = data.getParcelableExtra( com.paypal.android.sdk.payments.PaymentActivity.EXTRA_RESULT_CONFIRMATION );
if ( paymentConfirmation != null )
{
try
{
ProofOfPayment proofOfPayment = paymentConfirmation.getProofOfPayment();
if ( proofOfPayment != null )
{
String paymentId = proofOfPayment.getPaymentId();
if ( paymentId != null )
{
submitOrderForPrinting( paymentId, KiteSDK.getInstance( getActivity() ).getPayPalAccountId(), PaymentMethod.PAYPAL );
}
else
{
showErrorDialog( R.string.alert_dialog_message_no_payment_id );
}
}
else
{
showErrorDialog( R.string.alert_dialog_message_no_proof_of_payment );
}
}
catch ( Exception exception )
{
showErrorDialog( exception.getMessage() );
}
}
else
{
showErrorDialog( R.string.alert_dialog_message_no_paypal_confirmation );
}
}
return;
}
if ( mCreditCardAgent != null ) mCreditCardAgent.onActivityResult( requestCode, resultCode, data );
super.onActivityResult( requestCode, resultCode, data );
}