本文整理汇总了Java中com.paypal.android.sdk.payments.PaymentActivity类的典型用法代码示例。如果您正苦于以下问题:Java PaymentActivity类的具体用法?Java PaymentActivity怎么用?Java PaymentActivity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PaymentActivity类属于com.paypal.android.sdk.payments包,在下文中一共展示了PaymentActivity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
@Override
public void onClick(View view) {
valuesToVerify = new ValuesToVerify();
valuesToVerify.currency = this.currency;
valuesToVerify.price = this.price;
valuesToVerify.tax = this.tax;
valuesToVerify.repo = this.repo;
PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(price), currency, description,
PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent = new Intent(BasePurchaseActivity.this, PaymentActivity.class);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
startActivityForResult(intent, REQUEST_CODE_PAYMENT);
// FlurryAgent.logEvent("Purchase_Page_Clicked_On_Paypal_Button");
}
示例2: handleActivityResult
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的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));
}
示例3: onBuyPressed
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
public void onBuyPressed(View pressed) {
/*
* PAYMENT_INTENT_SALE will cause the payment to complete immediately.
* Change PAYMENT_INTENT_SALE to
* - PAYMENT_INTENT_AUTHORIZE to only authorize payment and capture funds later.
* - PAYMENT_INTENT_ORDER to create a payment for authorization and capture
* later via calls from your server.
*
* Also, to include additional payment details and an item list, see getStuffToBuy() below.
*/
PayPalPayment thingToBuy = getThingToBuy(PayPalPayment.PAYMENT_INTENT_SALE);
/*
* See getStuffToBuy(..) for examples of some available payment options.
*/
Intent intent = new Intent(SampleActivity.this, PaymentActivity.class);
// send the same configuration for restart resiliency
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
startActivityForResult(intent, REQUEST_CODE_PAYMENT);
}
示例4: setEnvironment
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
private void setEnvironment(JSONArray args) throws JSONException {
// make sure we use the same environment ids
String env = args.getString(0);
if (env.equals("PayPalEnvironmentNoNetwork")) {
this.environemnt = PaymentActivity.ENVIRONMENT_NO_NETWORK;
} else if (env.equals("PayPalEnvironmentProduction")) {
this.environemnt = PaymentActivity.ENVIRONMENT_LIVE;
} else if (env.equals("PayPalEnvironmentSandbox")) {
this.environemnt = PaymentActivity.ENVIRONMENT_SANDBOX;
} else {
this.callbackContext
.error("The provided environment is not supported");
return;
}
this.callbackContext.success();
}
示例5: onActivityResult
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的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);
}
}
示例6: startActivityPaypal
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
public static void startActivityPaypal(Activity context, CharSequence price, CharSequence description,String email_receptor) {
PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal(price.toString()), "EUR", description.toString());
Intent intent = new Intent(context, PaymentActivity.class);
intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, email_receptor);
// It's important to repeat the clientId here so that the SDK has it if Android restarts your
// app midway through the payment UI flow.
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, CONFIG_RECEIVER_EMAIL);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
context.startActivityForResult(intent, 6660);
}
示例7: onCreate
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payments);
String[] tickerSymbols = new String[] { "Beef&Broccoli: $9", "Noodle Soup: $10", "Fried Rice: $8"};
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
tickerSymbols));
// Show the Up button in the action bar.
getActionBar().setDisplayHomeAsUpEnabled(true);
//paypal functionality
Intent intent = new Intent(this, PayPalService.class);
intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);
startService(intent);
}
示例8: onBuyPressed
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
public void onBuyPressed(View pressed) {
PayPalPayment thingToBuy = new PayPalPayment(new BigDecimal("41.75"), "USD", "Cheese Cake Factory");
Intent intent = new Intent(this, PaymentActivity.class);
intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT, CONFIG_ENVIRONMENT);
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, CONFIG_CLIENT_ID);
intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL, CONFIG_RECEIVER_EMAIL);
// It's important to repeat the clientId here so that the SDK has it if Android restarts your
// app midway through the payment UI flow.
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID, "seller zhupani");
intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, "AldiZhupani");
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
startActivityForResult(intent, 0);
}
示例9: onActivityResult
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的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.");
}
}
}
示例10: donatePayPalClicked
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
@Override
public void donatePayPalClicked() {
//Getting the amount from editText
String paymentAmount = view.getPaymentAmount();
//Check if it is empty
if (paymentAmount.isEmpty()) {
view.setPaymentAmountError(getContext().getString(R.string.empty_payment_amount));
return;
}
//Creating a paypalpayment
PayPalPayment payment = new PayPalPayment(new BigDecimal(String.valueOf(paymentAmount))
, "USD", getContext().getString(R.string.paiment_app_detail),
PayPalPayment.PAYMENT_INTENT_SALE);
//Creating Paypal Payment activity intent
Intent intent = new Intent(getContext(), PaymentActivity.class);
//putting the paypal configuration to the intent
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, PayPalSettings.PAYPAL_CONFIG);
//Puting paypal payment to the intent
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);
//Starting the intent activity for result
//the request code will be used on the method onActivityResult
view.startActivityWithResult(intent, PAYPAL_REQUEST_CODE);
view.setBtnPayEnabled(false);
}
示例11: paymentRequest
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
@ReactMethod
public void paymentRequest(
final ReadableMap payPalParameters,
final Callback successCallback,
final Callback errorCallback
) {
this.successCallback = successCallback;
this.errorCallback = errorCallback;
final String environment = payPalParameters.getString("environment");
final String clientId = payPalParameters.getString("clientId");
final String price = payPalParameters.getString("price");
final String currency = payPalParameters.getString("currency");
final String description = payPalParameters.getString("description");
PayPalConfiguration config =
new PayPalConfiguration().environment(environment).clientId(clientId);
startPayPalService(config);
PayPalPayment thingToBuy =
new PayPalPayment(new BigDecimal(price), currency, description,
PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent =
new Intent(activityContext, PaymentActivity.class)
.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config)
.putExtra(PaymentActivity.EXTRA_PAYMENT, thingToBuy);
currentActivity.startActivityForResult(intent, paymentIntentRequestCode);
}
示例12: handleBuy
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
public void handleBuy(View view) {
int position = getListView()
.getPositionForView((View) view.getParent());
Price price = (Price) getListView().getItemAtPosition(position);
if (price != null) {
String description = getOrderText(price);
PayPalPayment payment = new PayPalPayment(price.getPrice(),
price.getCurrency(), description);
Intent intent = new Intent(this, PaymentActivity.class);
if (Constants.USE_RELEASE_CONFIG) {
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID,
PAYPAL_RELEASE_CLIENTID);
intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL,
"[email protected]");
} else {
// sandbox: use PaymentActivity.ENVIRONMENT_SANDBOX
intent.putExtra(PaymentActivity.EXTRA_PAYPAL_ENVIRONMENT,
PaymentActivity.ENVIRONMENT_SANDBOX);
intent.putExtra(PaymentActivity.EXTRA_CLIENT_ID,
PAYPAL_SANDBOX_CLIENTID);
intent.putExtra(PaymentActivity.EXTRA_RECEIVER_EMAIL,
"[email protected]");
}
// Direct Credit is only possible with a UK/Canada PayPal-Account
intent.putExtra(PaymentActivity.EXTRA_SKIP_CREDIT_CARD, true);
// Provide a payerId that uniquely identifies a user within the
// scope of your system, such as an email address or user ID.
intent.putExtra(PaymentActivity.EXTRA_PAYER_ID, accountName);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);
selectedPriceId = price.getPriceId();
startActivityForResult(intent, 0);
}
}
示例13: onActivityResult
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的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);
}
示例14: getFundTreatmentIntent
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的package包/类
public static Intent getFundTreatmentIntent(Activity activity,DonationInfoStorage donationInfo,String donationTo) {
float amount=donationInfo.getDonationAmount();
BigDecimal donation=BigDecimal.valueOf(amount);
PayPalPayment payment = new PayPalPayment(donation,
"USD", donationTo, PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent = new Intent(activity, PaymentActivity.class);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);
return intent;
}
示例15: onActivityResult
import com.paypal.android.sdk.payments.PaymentActivity; //导入依赖的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.");
}
}