PDA

View Full Version : Web Shipping Javascript SDK Questions



RogerH
02-17-2017, 11:56 AM
Hello, I am currently integrating the Web Shipping Javascript SDK into my custom ecommerce site to create shipments. I can view orders in my system that do not have tracking information and click a button that launches My.ShipRush with a new shipment, pre-populated with data I have passed in. Once I click the "ship" link the label is created, my account is charged and I am able to persist data (shipmentId, trackingNumber, etc...) returned by Shiprush Web into my system.

What I would like to do next is to be able to click an order in my system that has a tracking number, launch My.ShipRush and be able to view that specific shipment and either void it or reprint. Right now I am running into a couple problems.

1. Using the JS SDK, the only way I can "view" an order is to pass in a populated shipment object with the existing tracking number. However if I navigate to the shipped folder, it creates a duplicate of the shipment (that pre-populates with whatever data I pass in). Is there a way to view an existing shipment using the JS SDK without creating a duplicate?

2. Assuming I can view an existing shipment, if a user clicks the "void" button in the right column, a callback to "OnShipmentCompleted" is never fired. I was hoping it would and the "EventName" value would be something like "shipment_voided".

3. If I view a shipment and click the re-print link in the right column, the "OnShipmentCompleted" callback is fired but the event name value is "shipment_completed" and the shipment object is empty. Is there a way to know that a user clicked the reprint link?


Hopefully this makes sense. What I want to avoid is having a bunch of drafts, dupes or accidentally voided shipments in my system and in ship rush.

Thanks

SYSOPS
02-17-2017, 12:21 PM
We will get a developer to review this in greater detail. Case 56880

Thank you,
SYSOPS

SYSOPA
02-17-2017, 05:56 PM
This all sounds reasonable.

We added all these features in 99949 (will be on sandbox tomorrow, will be on production in ~10 days)

- You have to save somewhere on your system our internal "ShipmentId". You get it inside "OnShipmentCompleted(data)" event via "data.Shipment.ShipmentId".
- When you you want to open this shipment again - set "Shipment.ShipmentId" property to the saved value when calling "shipRushClient.Open()". In this case all other shipment properties will be ignored (and we will not create a new shipment on our side). We will just open a form with a saved shipment.
- We added a new event "OnAction" that has 2 parameters (event_name, data), where "event_name" could be any system event (currently "shipment_completed", "void", "reprint" and "close". Most likely that we will add more events in the future).
- Note that after printing shipping label BOTH "OnShipmentCompleted" and "OnAction" will be called ("OnShipmentCompleted" first).

Here is a demo
https://sandbox.my.shiprush.com/static.shiprush.com/ship.app/demos/javascript-api-openexisting-demo.html

2143

RogerH
02-20-2017, 08:04 AM
Wow talk about service - those features are exactly what I was looking for. Actually I do persist the shipment ID so that shouldn't be a problem. I will implement in my sandbox environment and get back to you with any questions/feedback. Thank you so much!

RogerH
02-21-2017, 08:41 AM
Hello, I just tried this in our sandbox environment but I am still getting the same results. Has the new build with the new features been deployed yet to the sandbox environment? Thanks in advance.

SYSOPS
02-21-2017, 09:46 AM
Checking to see if this update made it into the new sandbox code.

SYSOPS

SYSOPP
02-21-2017, 12:20 PM
Yes.

The new features are in 99949 , and the sandbox is currently on 99970

SYSOPA
02-21-2017, 05:01 PM
That's strange. It looks like sandbox had new code at the time when you wrote your message.

I just walked through "open existing demo" and it works as I expected

- Open https://sandbox.my.shiprush.com/static.shiprush.com/ship.app/demos/javascript-api-openexisting-demo.html
- Make sure "Use sandbox" is checked
- Click "Open Web Shipping"
- Note that "new shipment" form is displayed. "Ship" button is enabled. "Void" is disabled.
- Ship
- Close shipping form
- Note that "shipment_completed" was called and "ShipmentId" text field has a value now
- Click "Open Web Shipping" again
- Note that "shipped" form is displayed. "Void" button available on the right.
- Click "Void"
- Note that "void" event was called with the same "ShipmentId"
- Go to the "Shipped" folder, click "reprint" on any of the shipment
- Note that "reprint" event was called

Could you post your steps, what you expect and what you get (preferably with screenshots?)

Idea: I am wondering if this is related to Chrome/FireFox javascript caching of the "webshipping.integration.client.js" (meaning that your browser still using old version of the JS file, even though new one is available on our servers). Could try Chrome Incognito mode to make sure caching is not involved?

To fully bypass cache in "normal" mode - after opening demo right-click and select "Inspect Element" (in Chrome), then go to "Network" tab and click "disable cache", then (without closing developer's tools) come back to the demo page and hit F5 (chrome would do full refresh in this case).

RogerH
02-21-2017, 10:25 PM
Hi and thanks for the detailed reply. Your idea was correct and turns out the JS file was cached in the browser and was not picking up the latest changes. I'm doing some quick tests now but it is definitely loading up the shipment by shipmentid as expected.

Thanks!

Pat Gibson
12-19-2017, 11:07 AM
This all sounds reasonable.

We added all these features in 99949 (will be on sandbox tomorrow, will be on production in ~10 days)

- You have to save somewhere on your system our internal "ShipmentId". You get it inside "OnShipmentCompleted(data)" event via "data.Shipment.ShipmentId".
- When you you want to open this shipment again - set "Shipment.ShipmentId" property to the saved value when calling "shipRushClient.Open()". In this case all other shipment properties will be ignored (and we will not create a new shipment on our side). We will just open a form with a saved shipment.
- We added a new event "OnAction" that has 2 parameters (event_name, data), where "event_name" could be any system event (currently "shipment_completed", "void", "reprint" and "close". Most likely that we will add more events in the future).
- Note that after printing shipping label BOTH "OnShipmentCompleted" and "OnAction" will be called ("OnShipmentCompleted" first).

Here is a demo
https://sandbox.my.shiprush.com/static.shiprush.com/ship.app/demos/javascript-api-openexisting-demo.html

2143

Are there any plans to add drafts to OnAction?

SYSOPA
12-19-2017, 01:11 PM
Are there any plans to add drafts to OnAction?

Could you explain it in more details? Do you want OnAction called when new shipment is saved/closed?

Pat Gibson
12-19-2017, 01:34 PM
Could you explain it in more details? Do you want OnAction called when new shipment is saved/closed?

1. ShipRush is sent data I from another system which includes Address info.
2. ShipRush creates a draft behind the scenes.
3. The draft address is changed in ShipRush and the user exits.

A) Do drafts have a ShipmentId yet?
B) If so, how do I get the changed data?

You mentioned saved? Are there other ways to exit the ShipRush other than Ship button and closing?

thanks

SYSOPA
12-19-2017, 02:49 PM
>>> 1. ShipRush is sent data I from another system which includes Address info.

I assume that this is done via Javascript API (not via REST API and not via custom webstore connection)?

>>> A) Do drafts have a ShipmentId yet?

It depends on where draft was created. If on the server - then yes, it would have a ShipmentId. If draft created on the client (inside browser by javascript) - it would not. I am still not sure what is your workflow (we have many ways of pushing data to ShipRush). To quickly check if you have ShipmentId in your case - check the URL of the shiprush application (if you embed shiprush as IFrame - you may need to pop browser developer tool). The URL ends with shipmentId.

If it has bunch of zeros like this, then you DO NOT have ShipmentId
https://sandbox.my.shiprush.com/Ship/Ship?shipSessionId=vtZqEhvGfkWbLrL2rof1zQ#shipment/00000000-0000-0000-0000-000000000000

If it has a valid GUID at the end, then you DO have a ShipmentId
https://sandbox.my.shiprush.com/Ship/Ship?shipSessionId=vtZqEhvGfkWbLrL2rof1zQ#shipment/187a6006-dec3-4f6e-8a6d-a848013f27b6

>>> B) If so, how do I get the changed data?

There is no "OnSave" event at the moment. But we can add it if it helps your case. Although if the shipment has no ShipmentId at the time of "save" - would it still be useful?

Pat Gibson
02-07-2018, 04:58 AM
>>> 1. ShipRush is sent data I from another system which includes Address info.

I assume that this is done via Javascript API (not via REST API and not via custom webstore connection)?

>>> A) Do drafts have a ShipmentId yet?

It depends on where draft was created. If on the server - then yes, it would have a ShipmentId. If draft created on the client (inside browser by javascript) - it would not. I am still not sure what is your workflow (we have many ways of pushing data to ShipRush). To quickly check if you have ShipmentId in your case - check the URL of the shiprush application (if you embed shiprush as IFrame - you may need to pop browser developer tool). The URL ends with shipmentId.

If it has bunch of zeros like this, then you DO NOT have ShipmentId
https://sandbox.my.shiprush.com/Ship/Ship?shipSessionId=vtZqEhvGfkWbLrL2rof1zQ#shipment/00000000-0000-0000-0000-000000000000

If it has a valid GUID at the end, then you DO have a ShipmentId
https://sandbox.my.shiprush.com/Ship/Ship?shipSessionId=vtZqEhvGfkWbLrL2rof1zQ#shipment/187a6006-dec3-4f6e-8a6d-a848013f27b6

>>> B) If so, how do I get the changed data?

There is no "OnSave" event at the moment. But we can add it if it helps your case. Although if the shipment has no ShipmentId at the time of "save" - would it still be useful?


For the ERP integration we have the OnShipmentCompleted handling the ship button actions. It would be ideal to have an OnSave and a better implementation that handles drafts so customers can get proper quotes.
The ERP has a robust Order Management and if we had the OnSave then our integration with ShipRush would compete better with one of your competitors integration.

SYSOPA
02-07-2018, 01:39 PM
"OnSave" event has been added to builds 111251+. Currently live on sandbox, should be on production by next week.

You can use the same demo to check it's functionality on sandbox
https://sandbox.my.shiprush.com/static.shiprush.com/ship.app/demos/javascript-api-openexisting-demo.html

Let us know if you need anything else to solve "drafts" workflow for you...

2306

Pat Gibson
02-08-2018, 04:49 AM
"OnSave" event has been added to builds 111251+. Currently live on sandbox, should be on production by next week.

You can use the same demo to check it's functionality on sandbox
https://sandbox.my.shiprush.com/static.shiprush.com/ship.app/demos/javascript-api-openexisting-demo.html

Let us know if you need anything else to solve "drafts" workflow for you...

2306

outstanding! I'll look at this soon.
thanks