Currently, when a user is redirected to the shipping service, Synchweb sends the email and marks the dewar as 'dispatch-requested' instantly, as it doesn't know if/when they have completed the form.
The shipping service now accepts a callback URL, so we can send that in and it will POST to the address with some data about the completed shipment.
Changes:
Create new non-authenticated endpoint at /api/shipment/dewars/confirmdispatch/did/{dewarid}/token/{token}
Create pseudo-random token and store in Dewar.extra column as JSON
Pass callback URL including token to shipping service
Don't update dewar status and history when first redirecting to shipping service
Add function at new endpoint to check token, then update dewar status and history, and send email to stores and return lab contact
Hide email address in dispatch form before redirection to shipping service as it will not be used
To test:
Make sure $use_shipping_service = True;, $use_shipping_service_redirect = True; and $shipping_service_api_url = "https://sample-shipping-staging.diamond.ac.uk/api";
Go to a UK shipment, request dispatch without clicking "Use Facility Account", so it doesnt use the shipping service. Fill in the form and submit, check the dewar & shipping status are both dispatch-requested, the history has a line added, but the tracking number has not been filled in (as it doesn't exist). Check an email has been sent immediately.
Repeat for a non-UK shipment, also without the shipping service
Now try with a UK shipment and click "Use Facility Account". Click "Proceed" to the shipping service, but before filling in the form, check the shipment in another tab, it should not say dispatch-requested, and no email should have been sent. Now fill in the shipping service form and submit, click "Exit" back to Synchweb and the dewar & shipping status should both be dispatch-requested, an email should have been sent, and the tracking number should be in Synchweb too.
Check the email carefully, it should have a link to the AWB in the shipping service, check this works.
JIRA ticket: LIMS-1396
Summary:
Currently, when a user is redirected to the shipping service, Synchweb sends the email and marks the dewar as 'dispatch-requested' instantly, as it doesn't know if/when they have completed the form. The shipping service now accepts a callback URL, so we can send that in and it will POST to the address with some data about the completed shipment.
Changes:
To test:
$use_shipping_service = True;
,$use_shipping_service_redirect = True;
and$shipping_service_api_url = "https://sample-shipping-staging.diamond.ac.uk/api";