本文整理汇总了Java中org.chromium.payments.mojom.PaymentDetails类的典型用法代码示例。如果您正苦于以下问题:Java PaymentDetails类的具体用法?Java PaymentDetails怎么用?Java PaymentDetails使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PaymentDetails类属于org.chromium.payments.mojom包,在下文中一共展示了PaymentDetails类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateWith
import org.chromium.payments.mojom.PaymentDetails; //导入依赖的package包/类
/**
* Called by merchant to update the shipping options and line items after the user has selected
* their shipping address or shipping option.
*/
@Override
public void updateWith(PaymentDetails details) {
if (mClient == null) return;
if (mUI == null) {
disconnectFromClientWithDebugMessage(
"PaymentRequestUpdateEvent.updateWith() called without PaymentRequest.show()");
recordAbortReasonHistogram(
PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return;
}
if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return;
if (mUiShippingOptions.isEmpty() && mShippingAddressesSection.getSelectedItem() != null) {
mShippingAddressesSection.getSelectedItem().setInvalid();
mShippingAddressesSection.setSelectedItemIndex(SectionInformation.INVALID_SELECTION);
}
if (mPaymentInformationCallback != null) {
providePaymentInformation();
} else {
mUI.updateOrderSummarySection(mUiShoppingCart);
mUI.updateSection(PaymentRequestUI.TYPE_SHIPPING_OPTIONS, mUiShippingOptions);
}
}
示例2: parseAndValidateDetailsOrDisconnectFromClient
import org.chromium.payments.mojom.PaymentDetails; //导入依赖的package包/类
/**
* Sets the total, display line items, and shipping options based on input and returns the
* status boolean. That status is true for valid data, false for invalid data. If the input is
* invalid, disconnects from the client. Both raw and UI versions of data are updated.
*
* @param details The total, line items, and shipping options to parse, validate, and save in
* member variables.
* @return True if the data is valid. False if the data is invalid.
*/
private boolean parseAndValidateDetailsOrDisconnectFromClient(PaymentDetails details) {
if (!PaymentValidator.validatePaymentDetails(details)) {
disconnectFromClientWithDebugMessage("Invalid payment details");
recordAbortReasonHistogram(
PaymentRequestMetrics.ABORT_REASON_INVALID_DATA_FROM_RENDERER);
return false;
}
String totalCurrency = details.total.amount.currency;
CurrencyStringFormatter formatter =
new CurrencyStringFormatter(totalCurrency, Locale.getDefault());
// Total is never pending.
LineItem uiTotal = new LineItem(
details.total.label, formatter.getFormattedCurrencyCode(),
formatter.format(details.total.amount.value), /* isPending */ false);
List<LineItem> uiLineItems = getLineItems(details.displayItems, totalCurrency, formatter);
mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems);
mRawTotal = details.total;
mRawLineItems = Arrays.asList(details.displayItems);
mUiShippingOptions = getShippingOptions(details.shippingOptions, totalCurrency, formatter);
return true;
}
示例3: updateWith
import org.chromium.payments.mojom.PaymentDetails; //导入依赖的package包/类
/**
* Called by merchant to update the shipping options and line items after the user has selected
* their shipping address or shipping option.
*/
@Override
public void updateWith(PaymentDetails details) {
if (mClient == null) return;
if (mUI == null) {
mJourneyLogger.setAborted(AbortReason.INVALID_DATA_FROM_RENDERER);
disconnectFromClientWithDebugMessage(
"PaymentRequestUpdateEvent.updateWith() called without PaymentRequest.show()");
return;
}
if (!parseAndValidateDetailsOrDisconnectFromClient(details)) return;
if (mUiShippingOptions.isEmpty() && mShippingAddressesSection.getSelectedItem() != null) {
mShippingAddressesSection.getSelectedItem().setInvalid();
mShippingAddressesSection.setSelectedItemIndex(SectionInformation.INVALID_SELECTION);
mShippingAddressesSection.setErrorMessage(details.error);
}
if (mPaymentInformationCallback != null) {
providePaymentInformation();
} else {
mUI.updateOrderSummarySection(mUiShoppingCart);
mUI.updateSection(PaymentRequestUI.TYPE_SHIPPING_OPTIONS, mUiShippingOptions);
}
}
示例4: loadCurrencyFormattersForPaymentDetails
import org.chromium.payments.mojom.PaymentDetails; //导入依赖的package包/类
/**
* Load required currency formatter for a given PaymentDetails.
*
* Note that the cache (mCurrencyFormatterMap) is not cleared for
* updated payment details so as to indicate the currency has been changed.
*
* @param details The given payment details.
*/
private void loadCurrencyFormattersForPaymentDetails(PaymentDetails details) {
if (details.total != null) {
getOrCreateCurrencyFormatter(details.total.amount);
}
if (details.displayItems != null) {
for (PaymentItem item : details.displayItems) {
getOrCreateCurrencyFormatter(item.amount);
}
}
if (details.shippingOptions != null) {
for (PaymentShippingOption option : details.shippingOptions) {
getOrCreateCurrencyFormatter(option.amount);
}
}
if (details.modifiers != null) {
for (PaymentDetailsModifier modifier : details.modifiers) {
if (modifier.total != null) getOrCreateCurrencyFormatter(modifier.total.amount);
for (PaymentItem displayItem : modifier.additionalDisplayItems) {
getOrCreateCurrencyFormatter(displayItem.amount);
}
}
}
}
示例5: init
import org.chromium.payments.mojom.PaymentDetails; //导入依赖的package包/类
@Override
public void init(PaymentRequestClient client, PaymentMethodData[] methodData,
PaymentDetails details, PaymentOptions options) {
mClient = client;
}
示例6: updateWith
import org.chromium.payments.mojom.PaymentDetails; //导入依赖的package包/类
@Override
public void updateWith(PaymentDetails details) {}
示例7: validatePaymentDetails
import org.chromium.payments.mojom.PaymentDetails; //导入依赖的package包/类
public static boolean validatePaymentDetails(PaymentDetails details) {
if (details == null) {
return false;
}
return nativeValidatePaymentDetails(details.serialize());
}
示例8: parseAndValidateDetailsOrDisconnectFromClient
import org.chromium.payments.mojom.PaymentDetails; //导入依赖的package包/类
/**
* Sets the total, display line items, and shipping options based on input and returns the
* status boolean. That status is true for valid data, false for invalid data. If the input is
* invalid, disconnects from the client. Both raw and UI versions of data are updated.
*
* @param details The total, line items, and shipping options to parse, validate, and save in
* member variables.
* @return True if the data is valid. False if the data is invalid.
*/
private boolean parseAndValidateDetailsOrDisconnectFromClient(PaymentDetails details) {
if (!PaymentValidator.validatePaymentDetails(details)) {
mJourneyLogger.setAborted(AbortReason.INVALID_DATA_FROM_RENDERER);
disconnectFromClientWithDebugMessage("Invalid payment details");
return false;
}
if (details.total != null) {
mRawTotal = details.total;
}
loadCurrencyFormattersForPaymentDetails(details);
if (mRawTotal != null) {
// Total is never pending.
CurrencyFormatter formatter = getOrCreateCurrencyFormatter(mRawTotal.amount);
LineItem uiTotal = new LineItem(mRawTotal.label, formatter.getFormattedCurrencyCode(),
formatter.format(mRawTotal.amount.value), /* isPending */ false);
List<LineItem> uiLineItems = getLineItems(details.displayItems);
mUiShoppingCart = new ShoppingCart(uiTotal, uiLineItems);
}
mRawLineItems = Collections.unmodifiableList(Arrays.asList(details.displayItems));
mUiShippingOptions = getShippingOptions(details.shippingOptions);
for (int i = 0; i < details.modifiers.length; i++) {
PaymentDetailsModifier modifier = details.modifiers[i];
String[] methods = modifier.methodData.supportedMethods;
for (int j = 0; j < methods.length; j++) {
if (mModifiers == null) mModifiers = new ArrayMap<>();
mModifiers.put(methods[j], modifier);
}
}
updateInstrumentModifiedTotals();
return true;
}