Skip to content

Commit 66759d8

Browse files
committed
MAG-832: Migrate v2 Guarantee cancel to v3 Return
1 parent 0520e74 commit 66759d8

File tree

7 files changed

+915
-0
lines changed

7 files changed

+915
-0
lines changed

lib/Core/Api/ApiModel.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,29 @@ public function addFulfillment($fulfillmentsData)
210210

211211
return $response;
212212
}
213+
214+
/**
215+
* Record a return, exchanges, and/or refund for the order.
216+
*
217+
* @param $returnData
218+
* @return bool|mixed|object|\Signifyd\Core\Response
219+
* @throws InvalidClassException
220+
*/
221+
public function recordReturn($returnData)
222+
{
223+
$return = new \Signifyd\Models\RecordReturn($returnData);
224+
225+
$this->logger->info(
226+
'Connection call record a return with: ' . $return->toJson()
227+
);
228+
229+
$response = $this->connection->callApi(
230+
'orders/events/returns/records',
231+
$return->toJson(),
232+
'post',
233+
'return'
234+
);
235+
236+
return $response;
237+
}
213238
}

lib/Core/Response/ReturnResponse.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Signifyd\Core\Response;
4+
5+
class ReturnResponse extends SaleResponse
6+
{
7+
/**
8+
* Unique identifier for the Attempt Return.
9+
*
10+
* @var string
11+
*/
12+
public $returnId;
13+
14+
/**
15+
* The class attributes
16+
*
17+
* @var array $fields The list of class fields
18+
*/
19+
protected $fields = [
20+
'signifydId',
21+
'orderId',
22+
'decision',
23+
'coverage',
24+
'messages',
25+
'traceId',
26+
'returnId',
27+
];
28+
}

lib/Models/Initiator.php

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
namespace Signifyd\Models;
4+
5+
use Signifyd\Core\Model;
6+
use Signifyd\Models\Fingerprint;
7+
8+
class Initiator extends Model
9+
{
10+
/**
11+
* Unique email address associated with who initiated the return.
12+
* Either employeeEmail or employeeId must be present.
13+
*
14+
* @var string
15+
*/
16+
public $employeeEmail;
17+
18+
/**
19+
* Unique identifier associated with who initiated the return.
20+
* Either employeeEmail or employeeId must be present.
21+
*
22+
* @var float
23+
*/
24+
public $employeeId;
25+
26+
/**
27+
* The class attributes
28+
*
29+
* @var array $fields The list of class fields
30+
*/
31+
protected $fields = [
32+
'employeeEmail',
33+
'employeeId'
34+
];
35+
36+
/**
37+
* The validation rules
38+
*
39+
* @var array $fieldsValidation List of rules
40+
*/
41+
protected $fieldsValidation = [
42+
'employeeEmail' => [],
43+
'employeeId' => []
44+
];
45+
46+
/**
47+
* UserAccount constructor.
48+
*
49+
* @param array $data The user account data
50+
*/
51+
public function __construct($data = [])
52+
{
53+
if (!empty($data) && is_array($data)) {
54+
foreach ($data as $field => $value) {
55+
if (!in_array($field, $this->fields)) {
56+
continue;
57+
}
58+
59+
$this->{'set' . ucfirst($field)}($value);
60+
}
61+
}
62+
}
63+
64+
/**
65+
* Validate the user account
66+
*
67+
* @return bool
68+
*/
69+
public function validate()
70+
{
71+
$valid = [];
72+
73+
//TODO add code to validate the user account
74+
return (!isset($valid[0]))? true : false;
75+
}
76+
77+
/**
78+
* @return string
79+
*/
80+
public function getEmployeeEmail()
81+
{
82+
return $this->employeeEmail;
83+
}
84+
85+
/**
86+
* @param $employeeEmail
87+
* @return void
88+
*/
89+
public function setEmployeeEmail($employeeEmail)
90+
{
91+
$this->employeeEmail = $employeeEmail;
92+
}
93+
94+
/**
95+
* @return float
96+
*/
97+
public function getEmployeeId()
98+
{
99+
return $this->employeeId;
100+
}
101+
102+
/**
103+
* @param $employeeId
104+
* @return void
105+
*/
106+
public function setEmployeeId($employeeId)
107+
{
108+
$this->employeeId = $employeeId;
109+
}
110+
}

0 commit comments

Comments
 (0)