Wt  4.11.1
Public Member Functions | List of all members
Wt::Payment::PayPalExpressCheckout Class Reference

A paypal express checkout process. More...

#include <Wt/Payment/Paypal>

Inheritance diagram for Wt::Payment::PayPalExpressCheckout:
[legend]

Public Member Functions

void setPaymentAction (PaymentAction action)
 Sets the payment action. More...
 
PaymentAction paymentAction () const
 Returns the payment action. More...
 
void setParameter (const std::string &name, const std::string &value)
 Adds or overrides a PayPal API request parameter. More...
 
const Customercustomer () const
 Returns the customer information. More...
 
const Orderorder () const
 Returns the order information. More...
 
Signal< Result > & setup ()
 Setup the transaction. More...
 
void startPayment ()
 Start the payment. More...
 
Signal< Result > & updateCustomerDetails ()
 Updates customer information from PayPal. More...
 
Signal< Result > & completePayment (const Money &totalAmount)
 Completes the payment. More...
 
Signal< Approval > & paymentApproved ()
 The payment approval signal. More...
 
- Public Member Functions inherited from Wt::WObject
void addChild (std::unique_ptr< WObject > child)
 Add a child WObject whose lifetime is determined by this WObject.
 
template<typename Child >
Child * addChild (std::unique_ptr< Child > child)
 Add a child WObject, returning a raw pointer. More...
 
std::unique_ptr< WObjectremoveChild (WObject *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject.
 
template<typename Child >
std::unique_ptr< Child > removeChild (Child *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject. More...
 
virtual const std::string id () const
 Returns the (unique) identifier for this object. More...
 
virtual void setObjectName (const std::string &name)
 Sets an object name. More...
 
virtual std::string objectName () const
 Returns the object name. More...
 
void resetLearnedSlots ()
 Resets learned stateless slot implementations. More...
 
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance. More...
 
void isNotStateless ()
 Marks the current function as not stateless. More...
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method. More...
 
- Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
 Default constructor.
 
virtual ~observable ()
 Destructor. More...
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...)) noexcept
 Protects a method call against object destruction. More...
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...) const) const noexcept
 Protects a const method call against object destruction. More...
 
template<typename Function >
auto bindSafe (const Function &function) noexcept
 Protects a function against object destruction. More...
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation. More...
 

Detailed Description

A paypal express checkout process.

This implements the PayPal Express Checkout process.

For more information about the PayPal API see: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECGettingStarted

Use flow:

  1. use PayPalService to create a PayPalExpressCheckout instance.
  2. setup() - sends SetExpressCheckout API call returns a result signal.
  3. startPayment() - Redirects to PayPal. Use it after receiving the setup() result signal.
  4. paymentApproved signal will be emitted with the result of SetExpressCheckout API call.
  5. updateCustomerDetails() - GetExpressCheckoutDetails API call returns a result signal.
  6. completePayment() - DoExpressCheckoutPayment API call returns a result signal.

For an example, see the paypal feature example. This example reads the necessary variables from the wt_config.xml file.

For the api server url you should use API signature with the SOAP format. More information about the necessary url's and SOAP: https://developer.paypal.com/docs/classic/api/endpoints/ and https://developer.paypal.com/docs/integration/direct/identity/seamless-checkout/#nvp-soap-credentials.

The login credentials can be found in a paypal business account. You can create a sandbox test account by following the documentantion: https://developer.paypal.com/docs/classic/lifecycle/sb_create-accounts.

See also
PayPalService

Member Function Documentation

◆ completePayment()

Signal< Result > & Wt::Payment::PayPalExpressCheckout::completePayment ( const Money totalAmount)

Completes the payment.

This is the last step of a PayPal checkout, which uses the PayPal DoExpressCheckoutPayment API call to confirm the payment.

This may update the exact amount (for example to reflect accurate shipping information knowing the customer's shipping address).

This is an asynchronous call, which returns a signal that is emitted when the call has finished.

◆ customer()

const Customer & Wt::Payment::PayPalExpressCheckout::customer ( ) const

Returns the customer information.

See also
Customer

◆ order()

const Order & Wt::Payment::PayPalExpressCheckout::order ( ) const

Returns the order information.

See also
Order

◆ paymentAction()

PaymentAction Wt::Payment::PayPalExpressCheckout::paymentAction ( ) const

Returns the payment action.

See also
setPaymentAction()

◆ paymentApproved()

Signal< Approval > & Wt::Payment::PayPalExpressCheckout::paymentApproved ( )

The payment approval signal.

See also
startPayment()

◆ setParameter()

void Wt::Payment::PayPalExpressCheckout::setParameter ( const std::string &  name,
const std::string &  value 
)

Adds or overrides a PayPal API request parameter.

If value is empty, then this will remove a request parameter.

Useful use examples:

//send to paypal - &REQCONFIRMSHIPPING=1
setParameter("REQCONFIRMSHIPPING", 1);
//send to paypal - &NOSHIPPING=1
setParameter("NOSHIPPING", 1);
//send to paypal - &LOGOIMG=https://www.../logo.gif
setParameter("LOGOIMG", "https://www.../logo.gif");
//send to paypal - &CARTBORDERCOLOR=00CD
setParameter("CARTBORDERCOLOR", "00CD");
void setParameter(const std::string &name, const std::string &value)
Adds or overrides a PayPal API request parameter.
Definition: PayPal.C:182

◆ setPaymentAction()

void Wt::Payment::PayPalExpressCheckout::setPaymentAction ( PaymentAction  action)

Sets the payment action.

The default payment action is SaleAction.

◆ setup()

Signal< Result > & Wt::Payment::PayPalExpressCheckout::setup ( )

Setup the transaction.

This uses the PayPal SetExpressCheckout API call to initiate the payment process, preparing things for a subsequent call to startPayment().

This is an asynchronous call, which returns a signal that is emitted when the call has finished.

◆ startPayment()

void Wt::Payment::PayPalExpressCheckout::startPayment ( )

Start the payment.

This redirects to PayPal. It should be directly connected to a clicked event (on the PayPal button), to allow a JavaScript popup window to be used.

This is an asynchronous call, whose result will be indicated using the paymentApproved() signal.

◆ updateCustomerDetails()

Signal< Result > & Wt::Payment::PayPalExpressCheckout::updateCustomerDetails ( )

Updates customer information from PayPal.

This fetches customer information that is kept at PayPal for the current user. This call is optional, and can be used only after the user approved the payment (see paymentApproved()).

This uses the PayPal GetExpressCheckoutDetails API call.

This is an asynchronous call, which returns a signal that is emitted when the call has finished.