Backend

The eCommerce backend is the place where the merchant can configure the modules and follow up pending orders and their deliveries. First, RECShipping extension will have to provide configuration options in a dedicated page within the carriers of the shop. Then, information about Last Mile shipping will be made available in the order details and in all the emairequestl communications to the user and to the merchant. Additionally, buttons will be made available to trigger actions on the shipping that have been confirmed: payment confirmation and cancellation.

1. Configuration

RECShipping configuration page in the eCommerce Backoffice will offer a set of options that can be managed with the SDK.

1.1. Sandbox mode

A test environment is made available in order to use the extension without incurring real orders. Whenever this option is activated, no API key needs to be set up.

``` $response = Client::getInstance()->setEnvironment('sandbox');

```

1.2. API key

A field is available for the merchant to provide the API key that will be used across the service. If the sandbox mode is activated, this field will be ignored (and should be hidden).

When the API key is in use, a test request should be run to inform the merchant if the API key is correct. The result of this test should be visible to the merchant.

try {
    $response = Client::getInstance()
                    ->setApiKey($api_key);
                    ->request(Client::TEST);
} catch (ApiClientException $e) {
    echo "There was an error connecting with the API : ".$e->getMessage();
}

The registration link must be made available next to the api key field: with a label "Sing up or Log In", the link will open a full window popup to a page where the user will be able to create an account. If he is already registered, he will be able to access a control panel with his credentials.

    $response = Client::getInstance()       // no API key is needed
                    ->request(Client::ACCESS_REGISTRATION);

    $url = $response->getRegistrationUrl();

When registration process is over, API key should be automatically filled in the backend. The window that has been opened will do so via a javascript call:

window.opener.postMessage({code:'recs',apikey:'created-api-key'},'*');

the backend should be able to interpret this message and set the created-api-key value in the api key field in the backend.

1.4. Embeded Advanced Configuration

Advanced configuration options are made available on configuration webpage in the eCommerce Backoffice. This url will be retrieved via the ACCESS_BACKEND parameter. It will be made available to the merchant either via an iframe in a modal window, either via a popup window. This url will have a timeout, ideally bigger than the session timeout of the eCommerce backend.

    $response = Client::getInstance()
                    ->request(Client::ACCESS_BACKEND);          
    $url = $response->getBackendUrl();

then in the view we may have something like this (popup version)

    <!-- Module configuration view -->
    <a href="<?php echo $url ?>" target="_blank" onClick="window.open(this.href, this.target, 'width=800,height=600'); return false;">
        Advanced Configuration
    </a>

1.5. Other configuration options

Disable RECShipping for some payment methods

Option to configure manually payment method that are not immediate, and reflect the fact that RECShipping is not compatible with them.

Show RECShipping Last Mile by default

Whenever the proposals for shipping methods are shown before the user enters the address, we may choose to propose RECShipping Last Mile or RECShipping Standard. If this option is chosen, we propose RECShipping Last Mile.

Position

Make the RECShipping option appear first among shipping solutions.

2. Shipping information

Information about a shipping that has been confirmed, or actions that may be taken will be made available in the relevant order.

2.1. Configuration

Different requests related to a shipping service can be set up with the same configuration:

Client::getInstance()->setServiceNumber($service_number);

service_number the number corresponding to the shipping service you are working with

2.2. Last mile details

Information about a given shipping can be displayed using the Service Status Request. The ShowShippingHelper object provides methods to display this response in the backend. Note: if a shipping has no last mile, then nothing has to be shown.

    // Show Shipping Controller
    $response = Client::getInstance()
                    ->request(
                            Client::SERVICE_STATUS
                    );          

    $recs_shipping_info = new Nektria\Recs\MerchantApi\ShowShippingHelper($response,    $locale);
    // Show Shipping View
    <? if($recs_shipping_info->hasLastMile())
       {
         echo "Estado del envĂ­o: ".$recs_shipping_info->getStatus()."<br/>";
         echo "Franjas horarias de entrega: "     
         foreach($recs_shipping_info->getDeliveryWindows() as $window)
            echo $window."<br/>";
       }
    ]);

2.3. Payment confirmation button

Orders whose payment have not been confirmed yet will have a payment confirmation button

Client::getInstance()
        ->request(Client::PAYMENT_CONFIRMATION, 
        [
            'amount' => 97.23,
            'currency_code' => "EUR"
        ]);

amount is the price that has been paid by the shopper

currency_code is the code of the currency used to perform the payment

2.4. Cancel button

If anything goes wrong with the payment or if the shipping has to be cancelled for any reason, the SERVICE_CANCELLATION option will be made available via a button for the eCommerce.

Client::getInstance()
        ->request(Client::SERVICE_CANCELLATION);