PaymentCoordinator.h [plain text]
#pragma once
#if ENABLE(APPLE_PAY)
#include "ApplePaySessionPaymentRequest.h"
#include <wtf/Function.h>
namespace WebCore {
class Payment;
class PaymentCoordinatorClient;
class PaymentContact;
class PaymentMerchantSession;
class PaymentMethod;
class PaymentSession;
class URL;
enum class PaymentAuthorizationStatus;
struct PaymentAuthorizationResult;
struct PaymentMethodUpdate;
struct ShippingContactUpdate;
struct ShippingMethodUpdate;
class PaymentCoordinator {
public:
WEBCORE_EXPORT explicit PaymentCoordinator(PaymentCoordinatorClient&);
WEBCORE_EXPORT ~PaymentCoordinator();
bool supportsVersion(unsigned version) const;
bool canMakePayments();
void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
bool hasActiveSession() const { return m_activeSession; }
bool beginPaymentSession(PaymentSession&, const URL& originatingURL, const Vector<URL>& linkIconURLs, const ApplePaySessionPaymentRequest&);
void completeMerchantValidation(const PaymentMerchantSession&);
void completeShippingMethodSelection(std::optional<ShippingMethodUpdate>&&);
void completeShippingContactSelection(std::optional<ShippingContactUpdate>&&);
void completePaymentMethodSelection(std::optional<PaymentMethodUpdate>&&);
void completePaymentSession(std::optional<PaymentAuthorizationResult>&&);
void abortPaymentSession();
void cancelPaymentSession();
WEBCORE_EXPORT void validateMerchant(const URL& validationURL);
WEBCORE_EXPORT void didAuthorizePayment(const Payment&);
WEBCORE_EXPORT void didSelectPaymentMethod(const PaymentMethod&);
WEBCORE_EXPORT void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&);
WEBCORE_EXPORT void didSelectShippingContact(const PaymentContact&);
WEBCORE_EXPORT void didCancelPaymentSession();
std::optional<String> validatedPaymentNetwork(unsigned version, const String&) const;
private:
PaymentCoordinatorClient& m_client;
RefPtr<PaymentSession> m_activeSession;
};
}
#endif