@@ -255,14 +255,6 @@ response = client.device_activity.create({
255255}, device_mode = " wireless" ) # Required: "wired" or "wireless"
256256```
257257
258- #### Check Activity Status
259-
260- ``` py
261- response = client.device_activity.get_status(
262- " act_12345678" , # Required: Activity ID from create response
263- device_mode = " wired" # Required: "wired" or "wireless"
264- )
265- ```
266258
267259---
268260
@@ -326,48 +318,14 @@ class POSIntegration:
326318 activity_id = activity[' id' ]
327319 print (f " Checkout initiated: { activity_id} " )
328320
329- # Step 3: Monitor Status (polling example)
330- max_attempts = 30 # 5 minutes max
331- for attempt in range (max_attempts):
332- try :
333- status = self .client.device_activity.get_status(activity_id, device_mode = device_mode)
334- current_status = status[' status' ]
335-
336- print (f " Status check { attempt + 1 } : { current_status} " )
337-
338- if current_status == ' completed' :
339- # Step 4: Get final order details with payments
340- order_with_payments = self .client.order.fetch(
341- order[' id' ],
342- data = {" expand[]" : " payments" },
343- device_mode = device_mode
344- )
345-
346- return {
347- " success" : True ,
348- " order" : order_with_payments,
349- " activity" : status
350- }
351-
352- elif current_status == ' failed' :
353- error_details = status.get(' error' , {})
354- return {
355- " success" : False ,
356- " error" : f " Checkout failed: { error_details.get(' code' )} - { error_details.get(' reason' )} " ,
357- " activity" : status
358- }
359-
360- time.sleep(10 ) # Wait 10 seconds before next check
361-
362- except Exception as e:
363- print (f " Status check failed: { e} " )
364- continue
365-
366- # Timeout - close checkout
321+ print (" Checkout initiated successfully" )
322+
367323 self .close_checkout(device_mode = device_mode)
324+
368325 return {
369- " success" : False ,
370- " error" : " Checkout timeout"
326+ " success" : True ,
327+ " order" : order,
328+ " activity" : activity
371329 }
372330
373331 except Exception as e:
414372except BadRequestError as e:
415373 if " Invalid device mode" in str (e):
416374 print (" Use 'wired' or 'wireless' for device_mode" )
417- elif " Activity ID must be provided " in str (e):
418- print (" Provide valid activity_id for get_status " )
375+ elif " Invalid activity data " in str (e):
376+ print (" Provide valid activity data " )
419377 else :
420378 print (f " API Error: { e} " )
421379except Exception as e:
@@ -427,7 +385,6 @@ except Exception as e:
427385| Error | Cause | Solution |
428386| -------| -------| ----------|
429387| ` Invalid device mode ` | Wrong device_mode value | Use ` "wired" ` or ` "wireless" ` |
430- | ` Activity ID must be provided ` | Missing activity_id | Provide valid activity ID |
431388| ` device_id required for wireless mode ` | Missing device_id | Include device_id for wireless mode |
432389
433390** API Response Status Handling:**
@@ -467,16 +424,12 @@ elif response['status'] == 'failed':
467424| Method | Parameters | Returns | Description |
468425| --------| ------------| ---------| -------------|
469426| ` create() ` | ` data ` , ` device_mode ` | Activity object with status | Create checkout activity |
470- | ` get_status() ` | ` activity_id ` , ` device_mode ` | Activity status | Check activity status |
471427
472428** Usage Examples:**
473429``` py
474430# Initiate checkout
475431activity = client.device_activity.create(data, device_mode = " wired" )
476432
477- # Check status
478- status = client.device_activity.get_status(" pda_123" , device_mode = " wired" )
479-
480433# Close checkout
481434client.device_activity.create({" action" : " close_checkout" }, device_mode = " wired" )
482435```
0 commit comments