ApplePayShippingMethodSelectedEvent.cpp [plain text]
#include "config.h"
#include "ApplePayShippingMethodSelectedEvent.h"
#if ENABLE(APPLE_PAY)
#include <wtf/text/StringBuilder.h>
namespace WebCore {
static inline String convert(int64_t amount)
{
StringBuilder amountString;
amountString.appendNumber(amount / 100);
amountString.append('.');
unsigned decimals = amount % 100;
if (decimals < 10)
amountString.append('0');
amountString.appendNumber(decimals);
return amountString.toString();
}
static inline ApplePayShippingMethod convert(const PaymentRequest::ShippingMethod& shippingMethod)
{
ApplePayShippingMethod convertedMethod;
convertedMethod.label = shippingMethod.label;
convertedMethod.detail = shippingMethod.detail;
convertedMethod.identifier = shippingMethod.identifier;
convertedMethod.amount = convert(shippingMethod.amount);
return convertedMethod;
}
ApplePayShippingMethodSelectedEvent::ApplePayShippingMethodSelectedEvent(const AtomicString& type, const PaymentRequest::ShippingMethod& shippingMethod)
: Event(type, false, false)
, m_shippingMethod(convert(shippingMethod))
{
}
ApplePayShippingMethodSelectedEvent::~ApplePayShippingMethodSelectedEvent()
{
}
EventInterface ApplePayShippingMethodSelectedEvent::eventInterface() const
{
return ApplePayShippingMethodSelectedEventInterfaceType;
}
}
#endif