solidus_bactracs 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +95 -17
- data/lib/solidus_bactracs/console_harness.rb +2 -2
- data/lib/solidus_bactracs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54959bbe94b9360e9d26b71e5e22e5b3e5acaa71416ffa3db198a0e6c9029905
|
4
|
+
data.tar.gz: e38d854370db42b688dd13ce7ec31fe094333de329559435f2ead8b747991f84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ebef122f00f3c0254251d8e1d0115dd54bad137eb185e7c257b69f06be418eb6a23eb10c1ec70afb7bf9aa4085e6847e42517ba02dca67d289e4b4be6daffa
|
7
|
+
data.tar.gz: 64e323385ba59a13602f41f502ff21686d8b9f30daafa3bcdab11d909d19eb9aab39838c94bcac1a27270aa78ac687c05a243ef34171d1c51cbf962878a75411
|
data/README.md
CHANGED
@@ -31,6 +31,7 @@ used by the extension.
|
|
31
31
|
This extension can integrate with Bactracs via SOAP-based XML API integration. The gem currently makes SOAP 1.1 format calls, though the API support SOAP 1.2
|
32
32
|
|
33
33
|
|
34
|
+
|
34
35
|
### XML integration
|
35
36
|
|
36
37
|
The [XML integration](https://help.bactracs.com/hc/en-us/articles/360025856192-Custom-Store-Development-Guide)
|
@@ -42,29 +43,27 @@ created and updated shipments in your Solidus store.
|
|
42
43
|
⛔️ This section is outdated and inaccurate.
|
43
44
|
|
44
45
|
In order to enable the XML integration, make sure to configure the relevant section of the
|
45
|
-
configuration initializer, and configure your
|
46
|
+
configuration initializer, and configure your Bactracs/Andlor site accordingly:
|
46
47
|
|
47
48
|
- **Username**: the username defined in your configuration.
|
48
49
|
- **Password**: the password defined in your configuration.
|
49
50
|
- **URL to custom page**: `https://yourdomain.com/bactracs.xml`.
|
50
51
|
|
51
|
-
You can also configure your
|
52
|
+
You can also configure your Bactracs/Andlor site to pull the XML feed automatically on a recurring
|
52
53
|
basis, or manually by clicking the "Refresh stores" button.
|
53
54
|
|
54
|
-
There are five shipment states for an order (= shipment) in
|
55
|
-
necessarily align with Solidus, but you can configure
|
55
|
+
There are five shipment states for an order (= shipment) in Bactracs. These states do not
|
56
|
+
necessarily align with Solidus, but you can configure Bactracs to create a mapping for your
|
56
57
|
specific needs. Here's the recommended mapping:
|
57
58
|
|
58
|
-
Bactracs
|
59
|
+
Bactracs RMA Type | Bactracs status | Solidus status
|
59
60
|
------------------------|--------------------|---------------
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
Type 1 | `unpaid` | `pending`
|
62
|
+
Type W | `paid` | `ready`
|
63
|
+
Type 3 | `shipped` | `shipped`
|
64
|
+
Type 4 | `cancelled` | `cancelled`
|
65
|
+
|
65
66
|
|
66
|
-
Once you've configured the XML integration in your app and ShipStation, there's nothing else you
|
67
|
-
need to do. ShipStation will
|
68
67
|
|
69
68
|
#### XML integration: Usage
|
70
69
|
|
@@ -74,23 +73,23 @@ There's nothing you need to do. Once properly configured, the integration just w
|
|
74
73
|
|
75
74
|
There are a few gotchas you need to be aware of:
|
76
75
|
|
77
|
-
- If you change the shipping method of an order in
|
76
|
+
- If you change the shipping method of an order in Bactracs, the change will not be reflected in
|
78
77
|
Solidus and the tracking link might not work properly.
|
79
78
|
- When `bactracs_capture_at_notification` is enabled, any errors during payment capture will
|
80
79
|
prevent the update of the shipment's tracking number.
|
81
80
|
|
82
81
|
### API integration
|
83
82
|
|
84
|
-
The [API integration](https://www.bactracs.com/docs/api/) works by calling the
|
83
|
+
The [API integration](https://www.bactracs.com/docs/api/) works by calling the Bactracs API
|
85
84
|
to sync all of your shipments continuously.
|
86
85
|
|
87
|
-
Because
|
86
|
+
Because Bactracs has very low rate limits (i.e., 40 reqs/minute at the time of writing), the
|
88
87
|
API integration does not send an API request for every single shipment update, as you would expect
|
89
88
|
from a traditional API integration.
|
90
89
|
|
91
90
|
Instead, a background job runs on a recurring basis and batches together all the shipments that need
|
92
|
-
to be created or updated in ShipStation. These shipments are then sent
|
93
|
-
to
|
91
|
+
to be created or updated in ShipStation. These shipments are then sent one at a time
|
92
|
+
to Bactracs [RMA creation endpoint](https://www.bactracs.com/docs/api/orders/create-update-multiple-orders/).
|
94
93
|
|
95
94
|
This allows us to work around Bactracs's rate limit and sync up to 4000 shipments/minute.
|
96
95
|
|
@@ -145,6 +144,85 @@ This is a problem that is faced by all recurring jobs. The solution is two-fold:
|
|
145
144
|
|
146
145
|
## Development
|
147
146
|
|
147
|
+
Because of the object abstractions in this gem, some find it difficult to test API responses vis the console. To ease such console work, a 'console harness' was developed that provides several affordances to exploratory development.
|
148
|
+
|
149
|
+
Create a new harness in the console via
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
h = SolidusBactracs::ConsoleHarness.new
|
153
|
+
```
|
154
|
+
|
155
|
+
#### `.try_one`
|
156
|
+
|
157
|
+
The easiest way to test the API, seeing both the output of the shipment when serialized as a XML SOAP request, and the result from the Bactracs API.
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
h.try_one
|
161
|
+
```
|
162
|
+
|
163
|
+
or try a few
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
h.try_batch(4)
|
167
|
+
```
|
168
|
+
|
169
|
+
maybe you have a shipment with particular issues, e.g. shipment number `H123456789`
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
h.shipment_number('H123456789')
|
173
|
+
|
174
|
+
h.try_one(h.shipment_number('H123456789'))
|
175
|
+
```
|
176
|
+
|
177
|
+
`.shipment_number` retries that shipment from the scope of available `h.shipments`.
|
178
|
+
|
179
|
+
#### `.refresh`
|
180
|
+
|
181
|
+
If that was successful, you may find your list of shipments has one or more shipments that are already synced
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
h.shipments.size # => 7
|
185
|
+
h.refresh
|
186
|
+
h.shipments.size # => 6
|
187
|
+
```
|
188
|
+
|
189
|
+
#### `.cursor`
|
190
|
+
|
191
|
+
You can set where in the recordset you want to continue trying from
|
192
|
+
|
193
|
+
```
|
194
|
+
h.cursor = 5
|
195
|
+
h.try_one
|
196
|
+
```
|
197
|
+
|
198
|
+
#### `.batch`
|
199
|
+
|
200
|
+
You can also change the default batch size
|
201
|
+
|
202
|
+
```
|
203
|
+
h.batch = 10
|
204
|
+
h.try_batch
|
205
|
+
# output from 10 runs, if not errors occur
|
206
|
+
```
|
207
|
+
|
208
|
+
#### deep objects
|
209
|
+
|
210
|
+
Several deeply-nested objects are exposed for convenience
|
211
|
+
|
212
|
+
* runner
|
213
|
+
* syncer
|
214
|
+
* sync (job)
|
215
|
+
|
216
|
+
```
|
217
|
+
h.serialize(shipment)
|
218
|
+
# see the output of serialization
|
219
|
+
|
220
|
+
h.runner.authenticated_call(shipment: h.shipments[0], serializer: h.syncer.client.shipment_serializer)
|
221
|
+
```
|
222
|
+
|
223
|
+
Remember that you can monkey patch code in the console, to test the improvement the harness or the gem itself.
|
224
|
+
|
225
|
+
|
148
226
|
### Testing the extension
|
149
227
|
|
150
228
|
|
@@ -31,8 +31,8 @@ module SolidusBactracs
|
|
31
31
|
@syncer.client.shipment_serializer.call(shipment, @runner.authenticate!)
|
32
32
|
end
|
33
33
|
|
34
|
-
def try_one
|
35
|
-
puts "trying shipment #{(shipment = @shipments[@cursor]).id}"
|
34
|
+
def try_one(a_shipment = nil)
|
35
|
+
puts "trying shipment #{(shipment = a_shipment || @shipments[@cursor]).id}"
|
36
36
|
# resp = @runner.call(:post, '/orders/createorders', [serialize(shipment)])
|
37
37
|
resp = @runner.authenticated_call(shipment: shipment, serializer: @syncer.client.shipment_serializer)
|
38
38
|
if resp
|