本文整理汇总了Java中org.chromium.chrome.browser.payments.ui.PaymentOption类的典型用法代码示例。如果您正苦于以下问题:Java PaymentOption类的具体用法?Java PaymentOption怎么用?Java PaymentOption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PaymentOption类属于org.chromium.chrome.browser.payments.ui包,在下文中一共展示了PaymentOption类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getShippingOptions
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
/**
* Converts a list of shipping options and returns their parsed representation.
*
* @param options The raw shipping options to parse and validate.
* @param totalCurrency The currency code for the total amount of payment.
* @param formatter A formatter and validator for the currency amount value.
* @return The UI representation of the shipping options.
*/
private static SectionInformation getShippingOptions(PaymentShippingOption[] options,
String totalCurrency, CurrencyStringFormatter formatter) {
// Shipping options are optional.
if (options == null || options.length == 0) {
return new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_OPTIONS);
}
List<PaymentOption> result = new ArrayList<>();
int selectedItemIndex = SectionInformation.NO_SELECTION;
for (int i = 0; i < options.length; i++) {
PaymentShippingOption option = options[i];
result.add(new PaymentOption(option.id, option.label,
formatter.format(option.amount.value), null));
if (option.selected) selectedItemIndex = i;
}
return new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_OPTIONS, selectedItemIndex,
result);
}
示例2: onSectionEditOption
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
@Override
@PaymentRequestUI.SelectionResult
public int onSectionEditOption(@PaymentRequestUI.DataType int optionType, PaymentOption option,
Callback<PaymentInformation> callback) {
if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) {
assert option instanceof AutofillAddress;
editAddress((AutofillAddress) option);
mPaymentInformationCallback = callback;
return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION;
}
if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) {
assert option instanceof AutofillContact;
editContact((AutofillContact) option);
return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
}
if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) {
assert option instanceof AutofillPaymentInstrument;
editCard((AutofillPaymentInstrument) option);
return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
}
assert false;
return PaymentRequestUI.SELECTION_RESULT_NONE;
}
示例3: onPayClicked
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
@Override
public boolean onPayClicked(PaymentOption selectedShippingAddress,
PaymentOption selectedShippingOption, PaymentOption selectedPaymentMethod) {
assert selectedPaymentMethod instanceof PaymentInstrument;
PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod;
mPaymentAppRunning = true;
PaymentOption selectedContact =
mContactSection != null ? mContactSection.getSelectedItem() : null;
mPaymentResponseHelper = new PaymentResponseHelper(
selectedShippingAddress, selectedShippingOption, selectedContact, this);
instrument.getInstrumentDetails(mMerchantName, mOrigin, mRawTotal, mRawLineItems,
mMethodData.get(instrument.getInstrumentMethodName()), this);
recordSuccessFunnelHistograms("PayClicked");
return !(instrument instanceof AutofillPaymentInstrument);
}
示例4: getShippingOptions
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
/**
* Converts a list of shipping options and returns their parsed representation.
*
* @param options The raw shipping options to parse. Can be null.
* @return The UI representation of the shipping options.
*/
private SectionInformation getShippingOptions(@Nullable PaymentShippingOption[] options) {
// Shipping options are optional.
if (options == null || options.length == 0) {
return new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_OPTIONS);
}
List<PaymentOption> result = new ArrayList<>();
int selectedItemIndex = SectionInformation.NO_SELECTION;
for (int i = 0; i < options.length; i++) {
PaymentShippingOption option = options[i];
CurrencyFormatter formatter = getOrCreateCurrencyFormatter(option.amount);
String currencyPrefix = isMixedOrChangedCurrency()
? formatter.getFormattedCurrencyCode() + "\u0020"
: "";
result.add(new PaymentOption(option.id, option.label,
currencyPrefix + formatter.format(option.amount.value), null));
if (option.selected) selectedItemIndex = i;
}
return new SectionInformation(PaymentRequestUI.TYPE_SHIPPING_OPTIONS, selectedItemIndex,
Collections.unmodifiableList(result));
}
示例5: complete
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
/**
* Called when the merchant website has processed the payment.
*/
@Override
public void complete(int result) {
if (mClient == null) return;
mJourneyLogger.setCompleted();
if (!PaymentPreferencesUtil.isPaymentCompleteOnce()) {
PaymentPreferencesUtil.setPaymentCompleteOnce();
}
/**
* Update records of the used payment instrument for sorting payment apps and instruments
* next time.
*/
PaymentOption selectedPaymentMethod = mPaymentMethodsSection.getSelectedItem();
PaymentPreferencesUtil.increasePaymentInstrumentUseCount(
selectedPaymentMethod.getIdentifier());
PaymentPreferencesUtil.setPaymentInstrumentLastUseDate(
selectedPaymentMethod.getIdentifier(), System.currentTimeMillis());
closeUI(PaymentComplete.FAIL != result);
}
示例6: onInstrumentDetailsReady
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
/**
* Called after retrieving instrument details.
*/
@Override
public void onInstrumentDetailsReady(String methodName, String stringifiedDetails) {
if (mClient == null || mPaymentResponseHelper == null) return;
// Record the payment method used to complete the transaction. If the payment method was an
// Autofill credit card with an identifier, record its use.
PaymentOption selectedPaymentMethod = mPaymentMethodsSection.getSelectedItem();
if (selectedPaymentMethod instanceof AutofillPaymentInstrument) {
if (!selectedPaymentMethod.getIdentifier().isEmpty()) {
PersonalDataManager.getInstance().recordAndLogCreditCardUse(
selectedPaymentMethod.getIdentifier());
}
PaymentRequestMetrics.recordSelectedPaymentMethodHistogram(
PaymentRequestMetrics.SELECTED_METHOD_CREDIT_CARD);
} else if (methodName.equals(ANDROID_PAY_METHOD_NAME)) {
PaymentRequestMetrics.recordSelectedPaymentMethodHistogram(
PaymentRequestMetrics.SELECTED_METHOD_ANDROID_PAY);
} else {
PaymentRequestMetrics.recordSelectedPaymentMethodHistogram(
PaymentRequestMetrics.SELECTED_METHOD_OTHER_PAYMENT_APP);
}
recordSuccessFunnelHistograms("ReceivedInstrumentDetails");
mPaymentResponseHelper.onInstrumentDetailsReceived(methodName, stringifiedDetails);
}
示例7: onPayClicked
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
@Override
public boolean onPayClicked(PaymentOption selectedShippingAddress,
PaymentOption selectedShippingOption, PaymentOption selectedPaymentMethod) {
assert selectedPaymentMethod instanceof PaymentInstrument;
PaymentInstrument instrument = (PaymentInstrument) selectedPaymentMethod;
mPaymentAppRunning = true;
PaymentOption selectedContact = mContactSection != null ? mContactSection.getSelectedItem()
: null;
mPaymentResponseHelper = new PaymentResponseHelper(
selectedShippingAddress, selectedShippingOption, selectedContact, this);
// Create maps that are subsets of mMethodData and mModifiers, that contain
// the payment methods supported by the selected payment instrument. If the
// intersection of method data contains more than one payment method, the
// payment app is at liberty to choose (or have the user choose) one of the
// methods.
Map<String, PaymentMethodData> methodData = new HashMap<>();
Map<String, PaymentDetailsModifier> modifiers = new HashMap<>();
for (String instrumentMethodName : instrument.getInstrumentMethodNames()) {
if (mMethodData.containsKey(instrumentMethodName)) {
methodData.put(instrumentMethodName, mMethodData.get(instrumentMethodName));
}
if (mModifiers != null && mModifiers.containsKey(instrumentMethodName)) {
modifiers.put(instrumentMethodName, mModifiers.get(instrumentMethodName));
}
}
instrument.invokePaymentApp(mId, mMerchantName, mTopLevelOrigin, mPaymentRequestOrigin,
mCertificateChain, Collections.unmodifiableMap(methodData), mRawTotal,
mRawLineItems, Collections.unmodifiableMap(modifiers), this);
mJourneyLogger.setEventOccurred(Event.PAY_CLICKED);
return !(instrument instanceof AutofillPaymentInstrument);
}
示例8: onInstrumentDetailsReady
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
/**
* Called after retrieving instrument details.
*/
@Override
public void onInstrumentDetailsReady(String methodName, String stringifiedDetails) {
if (mClient == null || mPaymentResponseHelper == null) return;
// Record the payment method used to complete the transaction. If the payment method was an
// Autofill credit card with an identifier, record its use.
PaymentOption selectedPaymentMethod = mPaymentMethodsSection.getSelectedItem();
if (selectedPaymentMethod instanceof AutofillPaymentInstrument) {
if (!selectedPaymentMethod.getIdentifier().isEmpty()) {
PersonalDataManager.getInstance().recordAndLogCreditCardUse(
selectedPaymentMethod.getIdentifier());
}
mJourneyLogger.setSelectedPaymentMethod(SelectedPaymentMethod.CREDIT_CARD);
} else if (methodName.equals(ANDROID_PAY_METHOD_NAME)
|| methodName.equals(PAY_WITH_GOOGLE_METHOD_NAME)) {
mJourneyLogger.setSelectedPaymentMethod(SelectedPaymentMethod.ANDROID_PAY);
} else {
mJourneyLogger.setSelectedPaymentMethod(SelectedPaymentMethod.OTHER_PAYMENT_APP);
}
// Showing the payment request UI if we were previously skipping it so the loading
// spinner shows up until the merchant notifies that payment was completed.
if (mShouldSkipShowingPaymentRequestUi) mUI.showProcessingMessageAfterUiSkip();
mJourneyLogger.setEventOccurred(Event.RECEIVED_INSTRUMENT_DETAILS);
mPaymentResponseHelper.onInstrumentDetailsReceived(methodName, stringifiedDetails);
}
示例9: onSectionOptionSelected
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
@Override
@PaymentRequestUI.SelectionResult
public int onSectionOptionSelected(@PaymentRequestUI.DataType int optionType,
PaymentOption option, Callback<PaymentInformation> callback) {
if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) {
assert option instanceof AutofillAddress;
// Log the change of shipping address.
mJourneyLogger.incrementSelectionChanges(
PaymentRequestJourneyLogger.SECTION_SHIPPING_ADDRESS);
AutofillAddress address = (AutofillAddress) option;
if (address.isComplete()) {
mShippingAddressesSection.setSelectedItem(option);
// This updates the line items and the shipping options asynchronously.
mClient.onShippingAddressChange(address.toPaymentAddress());
} else {
editAddress(address);
}
mPaymentInformationCallback = callback;
return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION;
} else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) {
// This may update the line items.
mUiShippingOptions.setSelectedItem(option);
mClient.onShippingOptionChange(option.getIdentifier());
mPaymentInformationCallback = callback;
return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION;
} else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) {
assert option instanceof AutofillContact;
// Log the change of contact info.
mJourneyLogger.incrementSelectionChanges(
PaymentRequestJourneyLogger.SECTION_CONTACT_INFO);
AutofillContact contact = (AutofillContact) option;
if (contact.isComplete()) {
mContactSection.setSelectedItem(option);
} else {
editContact(contact);
return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
}
} else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) {
assert option instanceof PaymentInstrument;
if (option instanceof AutofillPaymentInstrument) {
// Log the change of credit card.
mJourneyLogger.incrementSelectionChanges(
PaymentRequestJourneyLogger.SECTION_CREDIT_CARDS);
AutofillPaymentInstrument card = (AutofillPaymentInstrument) option;
if (!card.isComplete()) {
editCard(card);
return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
}
}
mPaymentMethodsSection.setSelectedItem(option);
}
return PaymentRequestUI.SELECTION_RESULT_NONE;
}
示例10: PaymentResponseHelper
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
/**
* Builds a helper to contruct and fill a PaymentResponse.
*
* @param selectedShippingAddress The shipping address picked by the user.
* @param selectedShippingOption The shipping option picked by the user.
* @param selectedContact The contact info picked by the user.
* @param delegate The object that will recieve the completed PaymentResponse.
*/
public PaymentResponseHelper(PaymentOption selectedShippingAddress,
PaymentOption selectedShippingOption, PaymentOption selectedContact,
PaymentResponseRequesterDelegate delegate) {
mPaymentResponse = new PaymentResponse();
mDelegate = delegate;
// Set up the contact section of the response.
if (selectedContact != null) {
// Contacts are created in PaymentRequestImpl.init(). These should all be instances of
// AutofillContact.
assert selectedContact instanceof AutofillContact;
mPaymentResponse.payerName = ((AutofillContact) selectedContact).getPayerName();
mPaymentResponse.payerPhone = ((AutofillContact) selectedContact).getPayerPhone();
mPaymentResponse.payerEmail = ((AutofillContact) selectedContact).getPayerEmail();
}
// Set up the shipping section of the response.
if (selectedShippingOption != null && selectedShippingOption.getIdentifier() != null) {
mPaymentResponse.shippingOption = selectedShippingOption.getIdentifier();
}
// Set up the shipping address section of the response.
if (selectedShippingAddress != null) {
// Shipping addresses are created in PaymentRequestImpl.init(). These should all be
// instances of AutofillAddress.
assert selectedShippingAddress instanceof AutofillAddress;
mSelectedShippingAddress = (AutofillAddress) selectedShippingAddress;
// Addresses to be sent to the merchant should always be complete.
assert mSelectedShippingAddress.isComplete();
// Record the use of the profile.
PersonalDataManager.getInstance().recordAndLogProfileUse(
mSelectedShippingAddress.getProfile().getGUID());
mPaymentResponse.shippingAddress = mSelectedShippingAddress.toPaymentAddress();
// The shipping address needs to be normalized before sending the response to the
// merchant.
mIsWaitingForShippingNormalization = true;
PersonalDataManager.getInstance().normalizeAddress(
mSelectedShippingAddress.getProfile().getGUID(),
AutofillAddress.getCountryCode(mSelectedShippingAddress.getProfile()), this);
}
}
示例11: onSectionOptionSelected
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
@Override
@PaymentRequestUI.SelectionResult
public int onSectionOptionSelected(@PaymentRequestUI.DataType int optionType,
PaymentOption option, Callback<PaymentInformation> callback) {
if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) {
assert option instanceof AutofillAddress;
// Log the change of shipping address.
mJourneyLogger.incrementSelectionChanges(Section.SHIPPING_ADDRESS);
AutofillAddress address = (AutofillAddress) option;
if (address.isComplete()) {
mShippingAddressesSection.setSelectedItem(option);
startShippingAddressChangeNormalization(address);
} else {
editAddress(address);
}
mPaymentInformationCallback = callback;
return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION;
} else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) {
// This may update the line items.
mUiShippingOptions.setSelectedItem(option);
mClient.onShippingOptionChange(option.getIdentifier());
mPaymentInformationCallback = callback;
return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION;
} else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) {
assert option instanceof AutofillContact;
// Log the change of contact info.
mJourneyLogger.incrementSelectionChanges(Section.CONTACT_INFO);
AutofillContact contact = (AutofillContact) option;
if (contact.isComplete()) {
mContactSection.setSelectedItem(option);
} else {
editContact(contact);
return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
}
} else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) {
assert option instanceof PaymentInstrument;
if (option instanceof AutofillPaymentInstrument) {
// Log the change of credit card.
mJourneyLogger.incrementSelectionChanges(Section.CREDIT_CARDS);
AutofillPaymentInstrument card = (AutofillPaymentInstrument) option;
if (!card.isComplete()) {
editCard(card);
return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
}
}
updateOrderSummary((PaymentInstrument) option);
mPaymentMethodsSection.setSelectedItem(option);
}
return PaymentRequestUI.SELECTION_RESULT_NONE;
}
示例12: PaymentResponseHelper
import org.chromium.chrome.browser.payments.ui.PaymentOption; //导入依赖的package包/类
/**
* Builds a helper to contruct and fill a PaymentResponse.
*
* @param selectedShippingAddress The shipping address picked by the user.
* @param selectedShippingOption The shipping option picked by the user.
* @param selectedContact The contact info picked by the user.
* @param delegate The object that will recieve the completed PaymentResponse.
*/
public PaymentResponseHelper(PaymentOption selectedShippingAddress,
PaymentOption selectedShippingOption, PaymentOption selectedContact,
PaymentResponseRequesterDelegate delegate) {
mPaymentResponse = new PaymentResponse();
mDelegate = delegate;
// Set up the contact section of the response.
if (selectedContact != null) {
// Contacts are created in PaymentRequestImpl.init(). These should all be instances of
// AutofillContact.
assert selectedContact instanceof AutofillContact;
mPaymentResponse.payerName = ((AutofillContact) selectedContact).getPayerName();
mPaymentResponse.payerPhone = ((AutofillContact) selectedContact).getPayerPhone();
mPaymentResponse.payerEmail = ((AutofillContact) selectedContact).getPayerEmail();
// Normalize the phone number only if it's not null since this calls native code.
if (mPaymentResponse.payerPhone != null) {
mPaymentResponse.payerPhone =
PhoneNumberUtil.formatForResponse(mPaymentResponse.payerPhone);
}
}
// Set up the shipping section of the response.
if (selectedShippingOption != null && selectedShippingOption.getIdentifier() != null) {
mPaymentResponse.shippingOption = selectedShippingOption.getIdentifier();
}
// Set up the shipping address section of the response.
if (selectedShippingAddress != null) {
// Shipping addresses are created in PaymentRequestImpl.init(). These should all be
// instances of AutofillAddress.
assert selectedShippingAddress instanceof AutofillAddress;
mSelectedShippingAddress = (AutofillAddress) selectedShippingAddress;
// Addresses to be sent to the merchant should always be complete.
assert mSelectedShippingAddress.isComplete();
// Record the use of the profile.
PersonalDataManager.getInstance().recordAndLogProfileUse(
mSelectedShippingAddress.getProfile().getGUID());
mPaymentResponse.shippingAddress = mSelectedShippingAddress.toPaymentAddress();
// The shipping address needs to be normalized before sending the response to the
// merchant.
mIsWaitingForShippingNormalization = true;
PersonalDataManager.getInstance().normalizeAddress(
mSelectedShippingAddress.getProfile(),
AutofillAddress.getCountryCode(mSelectedShippingAddress.getProfile()), this);
}
}