Product Checkout module
Learn more about the Product Checkout module.
The ProductCheckout
module handles syncing data to the Digital River platform during the whole checkout process.
Specifications
This module is responsible for calculating the tax based on shipping address if available, or billing address if the shipping address is not available.
This module contains a Drop-in integration provided by Digital River for the checkout process. This includes legal content that is fetched from Digital River.js.
Customer checkouts can process from the US or from outside the US. If you will have customers with shipping addresses to the US, add a file uploader on the Checkout page for uploading tax certificates. If you will have customers with shipping addresses outside of the US, add a text field for adding the tax ID for the customer.
Pass the tax certificate
Complete the following tasks to pass the tax certificate.
After order placement, pass the tax certificate to Digital River for verifications. Based on the verification, buyers will be notified whether or not their tax exemption certificate is valid.
For the Input field tax ID, verify the tax ID during order placement.
On the
My Account
page, create a section under the Account page for tax certificate verification. The buyer will see their tax certificate status.Create a Drop-in payment gateway for rendering payment options on the checkout page. The buyer will select the payment options, complete the necessary fields, and process the payment.
After successful payment, pass all order instance data with customer data to Digital River API via the Drop-in gateway.
Add a Save payment option for the Drop-in gateway to allow buyers to save their payment data for future purchases. Customers can process payments via Save Cards.
Add the Save payment option on the My Account page so that customers can manage (add, update, remove, and save) their card and save payment options.
Hide others' default gateway from the customer checkout end when the Digital River gateway is enabled. Show a message in Admin Payment tab settings that other gateways are not showing either they are enabled.
Naming Conventions
For naming conventions:
On the Checkout page, add two fields depending on customer billing or shipping country chosen.
Tax Certificate
Type: File field
Description: Enter your tax certificate
id/key:
dr_customer_tax_certificate
Condition: Showing only if Shipping country is in the US
Tax ID
Type: number fields
Description: Enter your tax id number
id/key:
dr_customer_tax_id_number
Condition: Showing only if shipping country is outside of the US
On the My Account page, add a tax details section.
Product Checkout Methods
Product Checkout class
The class describes the module's entry point.
Method | Args, Return, and Description |
name | Args: - Return: string Description: Returns the name of the module |
__construct | Args: CheckoutContainer $container, Path: Settings $settings /src/Modules/ProductCheckout/CheckoutContainer.php Args: TaxExemption $tax_exemption Path: /src/Modules/ProductCheckout/TaxExemption.php Args: CustomerMyAccount $customer_myaccount Path: /src/Modules/ProductCheckout/CustomerMyAccount.php Return: void Description: Initializes the object by passing in dependencies |
init | Args: - Return: void Description: Initializes the module, register necessary hooks, and call certain methods to complete the setup |
render_gateway_class | Args: array $gateways Return: array Description: Adds the DropIn class to the list of gateways |
hide_default_gateways | Args: array $gateways Return: array Description: Remove all gateways other than Digital River if the plugin is enabled. |
show_gateway_message | Args: - Return: void Description: Displays a message on the payment gateway settings page that if the Digital River gateway is activated, other payment methods will be hidden from checkout. |
add_to_cart_redirect | Args: String $url, int $product_id Return: String Description: Returns add to cart redirect URL |
Drop-in class
This gateway class will be added to the list of supported payment gateways from the ProductCheckout
class.
Method | Args, Return, and Description |
__construct | Args: - Return: void Description: Constructs the object |
init | Args: - Return: void Description: Sets Payment gateway title, description, and enqueue payment scripts by calling the |
payment_scripts | Args: - Return: void Description: Enqueue necessary scripts on the |
payment_fields | Args: - Return: void Description: Render the payment fields |
process_payment | Args: int $order_id Return: void Description: Processes the order after final payment |
Tax Exemption class
This class adds Tax exemption
fields to the Checkout
page.
Method | Args and Return |
__construct | Args: Return: void |
init | Args: - Return: void |
tax_identifier_types | Args: String $country Return: array |
tax_authority_data | Args: - Return: array |
assets | Args: - Return: void |
Customer My Account class
This class handles adding a new subpage to the user's My Account
page where the payment sources of a user can be viewed.
Method | Args, Return, and Description |
__construct | Args: Return: void Description: Constructs the object by passing in dependencies |
init | Args: - Return: void Description: Registers necessary hooks |
add_myaccount_endpoint | Args: - Return: void Description: Adds a new rewrite endpoint |
add_query_vars | Args: array Return: array Description: Adds the |
myaccount_scripts | Args: - Return: void Description: Load scripts only on the |
endpoint_title | Args: String $title Return: String Description: Sets the title for the |
dr_payment_link | Args: array $menu_links Return: array Description: Adds a new link |
dr_payment_content | Args: - Return: void Description: Renders content callback for when the link |
get_sources | Args: Return: array Description: Returns an array containing the payment sources of the customer with the default source placed as the first element |
handle_payment_methods | Args: - Return: void Description: Handles payment method operations |
create_customer_source | Args: - Return: void Description: Gets |
Customer Handler class
This class creates required data for a customer by using the Customer Digital River Handler class.
Method | Args, Returns, and Descriptions |
__construct | Arg: Return: void Description: Constructs the object by passing in dependencies |
create_dr_customer_from_postdata | Arg: - Return: void Description: Creates customer on Digital River from parsed post data sent by WooCommerce |
create_dr_customer | Arg: array $data Return: Customer Description: Creates customer on Digital River from parameters. Returns the |
fetch_dr_customer | Arg: string $id Return: Customer Description: Fetches customer from Digital River Returns Customer object and throws Exception if the data is invalid |
create_dr_customer_source | Arg: string $source_id Return: Source Description: Creates customer source on Digital River. Returns the |
compare_customer_data | Arg: array $data Return: Description: Compares customer data to check whether the customer needs an update. Returns the |
dr_customer_object | Arg: String $action, Return: Customer/null Description: Gets, saves, and deletes the Digital River customer object from the |
Checkout Handler class
This class creates required data for checkout by using the Checkout Digital River Handler class.
Method | Args, Returns, and Descriptions |
__construct | Args:
Return: void Description: Construct the object by passing in dependencies |
init | Arg: - Return: void Description: Register necessary hooks |
render_checkout_submit | Arg: - Return: void Description: Adds tax exemption fields on the checkout page |
render_customer_type_option | Arg: - Return: void Description: Appends customer type option in checkout billing fields |
woocommerce_cart_shipping_method_full_label | Arg: string $label, Return: String Description: Callback for woocommerce_cart_shipping_method_full_label filter used to display the tax information |
update_wc_order_data | Arg: Return: void Description: Modifies WooCommerce order data and save according to Digital River checkout |
replace_wc_order_details | Arg: array $total_rows, Return: array Description: Shows Digital River checkout total on order details |
dr_product_subtotal | Arg: String $subtotal, Object $item, Return: String Description: Shows the item total according to |
validate_order_data | Arg: $default_value Return: mixed Description: Filters before creating Woocommerce order. Checks whether checkout object is stored in session and contains the source and customer ID |
replace_checkout_order_review_template | Arg: array $fragments Return: array Description: Modifies order review table HTML contents to show Digital River's calculated taxes |
assets | Arg: - Return: void Description: Enqueues the necessary scripts and stylesheets |
process_checkout | Arg: - Return: void Description: Processes checkout, creates customer and returns calculated tax |
handle_update_checkout_with_payment_source | Arg: - Return: void Description: Handles update checkout with payment source identifier ajax request |
handle_update_source_checkout | Arg: - Return: void Description: Updates checkout with source ID if the billing address has changed |
handle_checkout_get_payment_session_id | Arg: - Return: void Description: Handles get checkout payment session ID ajax request |
include_templates | Arg: - Return: void Description: Includes WordPress templates in the footer |
Compliance class
This class responsible for displaying the legal information from Digital River on the Cart, Checkout, and Thank You pages in WooCommerce.
Only the _construct
method for this class has an arg.
Method | Returns and Descriptions |
__construct | Return: void Description: Construct the object by passing in dependencies |
init | Return: void Description: Registers necessary hooks |
assets | Return: void Description: Loads compliance scripts and stylesheets for rendering legal content on the store |
show_compliance | Return: void Description: Renders Digital River compliance message |
prepare_checkout_request | Return: array Description: Prepares request data for checkout |
Digital River Handlers/checkout class
Method | Args, Returns, and Descriptions |
get | Args: string $checkout_id Return: Description: Retrieves a checkout API call to Digital River, returns the |
update | Args: array $data Return: Description: Updates a checkout API call to Digital River and returns |
delete | Args: Checkout $checkout Return: Description: Deletes a checkout API call to Digital River and returns |
Digital River Handlers\Customer class
Method | Args, Returns, and Descriptions |
get | Args: string $checkout_id Return: Description: Retrieves a customer API call to Digital River, returns |
create | Args: array $data Return: Description: Creates a customer API call to Digital River and returns the |
update | Args: array $data Return: Description: Updates a customer API call to Digital River, returns |
delete | Args: string $customer_id Return: Description: Deletes a customer API call to Digital River, returns the deleted |
create_source | Args: string $customer_id, string $customer_id Return: Description: Creates a Customer Source API call to Digital River, returns |
delete_source | Args: string $customer_id, string $customer_id Return: Description: Deletes a Customer Source API call to Digital River, returns the deleted |
get_tax_certificate | Args: array $data Return: Description: Retrieves tax certificate data from the data array and returns new |
Digital River Handlers\File class
Method | Args, Returns, and Descriptions |
create | Args: String $file, String $purpose Return: Description: Creates a |
get | Args: String $file Return: Description: Retrieves File API call to Digital River and returns |
delete | Args: String $file Return: Description: Deletes File API call to Digital River and returns the deleted |
create_file_link | Args: String $file Return: Description: Creates file link for file object for download and view and returns a |
Digital River Handlers\Source class
Method | Args, Returns, and Descriptions |
get | Args: String $source_id Return: Description: Makes retrieve Source API call to Digital River and returns |
Checkout Container class
This class acts as a Dependency Injection container for providing dependencies to classes present in the ProductCheckout
module.
Method | Args, Returns, and Descriptions |
__construct | Args: Return: void Description: Accepts a Dependency Injection container as an argument and assigns it to a container attribute |
define_services | Args: - Return: void Description: Defines all the classes present within the module |
Last updated