Skip to content

Commit 30b9f10

Browse files
feat: Add create/update card request fields; SFTPSettings (#19)
Co-authored-by: ProcessOut Fountain <internal@processout.com>
1 parent 1392018 commit 30b9f10

8 files changed

Lines changed: 213 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The package's installation is done using composer. Simply add these lines to you
2020
```json
2121
{
2222
"require": {
23-
"processout/processout-php": "^6.31.0"
23+
"processout/processout-php": "^6.32.0"
2424
}
2525
}
2626
```

init.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
include_once(dirname(__FILE__) . "/src/Product.php");
5252
include_once(dirname(__FILE__) . "/src/Project.php");
5353
include_once(dirname(__FILE__) . "/src/ProjectSFTPSettings.php");
54+
include_once(dirname(__FILE__) . "/src/ProjectSFTPSettingsPublic.php");
5455
include_once(dirname(__FILE__) . "/src/Refund.php");
5556
include_once(dirname(__FILE__) . "/src/Subscription.php");
5657
include_once(dirname(__FILE__) . "/src/Transaction.php");

src/CardCreateRequest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,23 @@ public function create($options = array())
628628
$path = "/cards";
629629

630630
$data = array(
631-
631+
"device" => $this->getDevice(),
632+
"name" => $this->getName(),
633+
"number" => $this->getNumber(),
634+
"exp_day" => $this->getExpDay(),
635+
"exp_month" => $this->getExpMonth(),
636+
"exp_year" => $this->getExpYear(),
637+
"cvc2" => $this->getCvc2(),
638+
"preferred_scheme" => $this->getPreferredScheme(),
639+
"metadata" => $this->getMetadata(),
640+
"token_type" => $this->getTokenType(),
641+
"eci" => $this->getEci(),
642+
"cryptogram" => $this->getCryptogram(),
643+
"applepay_response" => $this->getApplepayResponse(),
644+
"applepay_mid" => $this->getApplepayMid(),
645+
"payment_token" => $this->getPaymentToken(),
646+
"contact" => $this->getContact(),
647+
"shipping" => $this->getShipping()
632648
);
633649

634650
$response = $request->post($path, $data, $options);

src/CardUpdateRequest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ public function update($cardId, $options = array())
160160
$path = "/cards/" . urlencode($cardId) . "";
161161

162162
$data = array(
163-
163+
"update_type" => $this->getUpdateType(),
164+
"update_reason" => $this->getUpdateReason(),
165+
"preferred_scheme" => $this->getPreferredScheme()
164166
);
165167

166168
$response = $request->put($path, $data, $options);

src/Networking/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function prepare($options, $len = null)
3131
$headers = array(
3232
'API-Version: 1.4.0.0',
3333
'Content-Type: application/json',
34-
'User-Agent: ProcessOut PHP-Bindings/6.31.0'
34+
'User-Agent: ProcessOut PHP-Bindings/6.32.0'
3535
);
3636
if (! empty($options['idempotencyKey']))
3737
$headers[] = 'Idempotency-Key: ' . $options['idempotencyKey'];

src/ProcessOut.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,15 @@ public function newProjectSFTPSettings($prefill = array()) {
424424
return new ProjectSFTPSettings($this, $prefill);
425425
}
426426

427+
/**
428+
* Create a new ProjectSFTPSettingsPublic instance
429+
* @param array|null $prefill array used to prefill the object
430+
* @return ProjectSFTPSettingsPublic
431+
*/
432+
public function newProjectSFTPSettingsPublic($prefill = array()) {
433+
return new ProjectSFTPSettingsPublic($this, $prefill);
434+
}
435+
427436
/**
428437
* Create a new Refund instance
429438
* @param array|null $prefill array used to prefill the object

src/ProjectSFTPSettings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ProjectSFTPSettings implements \JsonSerializable
1717
protected $client;
1818

1919
/**
20-
* SFTP server endpoint, port is required.
20+
* SFTP server endpoint, port is required
2121
* @var string
2222
*/
2323
protected $endpoint;
@@ -55,7 +55,7 @@ public function __construct(ProcessOut $client, $prefill = array())
5555

5656
/**
5757
* Get Endpoint
58-
* SFTP server endpoint, port is required.
58+
* SFTP server endpoint, port is required
5959
* @return string
6060
*/
6161
public function getEndpoint()
@@ -65,7 +65,7 @@ public function getEndpoint()
6565

6666
/**
6767
* Set Endpoint
68-
* SFTP server endpoint, port is required.
68+
* SFTP server endpoint, port is required
6969
* @param string $value
7070
* @return $this
7171
*/

src/ProjectSFTPSettingsPublic.php

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<?php
2+
3+
// The content of this file was automatically generated
4+
5+
namespace ProcessOut;
6+
7+
use ProcessOut\ProcessOut;
8+
use ProcessOut\Networking\Request;
9+
10+
class ProjectSFTPSettingsPublic implements \JsonSerializable
11+
{
12+
13+
/**
14+
* ProcessOut's client
15+
* @var ProcessOut\ProcessOut
16+
*/
17+
protected $client;
18+
19+
/**
20+
* Whether the SFTP settings are enabled
21+
* @var boolean
22+
*/
23+
protected $enabled;
24+
25+
/**
26+
* SFTP server endpoint with port
27+
* @var string
28+
*/
29+
protected $endpoint;
30+
31+
/**
32+
* SFTP server username
33+
* @var string
34+
*/
35+
protected $username;
36+
37+
/**
38+
* ProjectSFTPSettingsPublic constructor
39+
* @param ProcessOut\ProcessOut $client
40+
* @param array|null $prefill
41+
*/
42+
public function __construct(ProcessOut $client, $prefill = array())
43+
{
44+
$this->client = $client;
45+
46+
$this->fillWithData($prefill);
47+
}
48+
49+
50+
/**
51+
* Get Enabled
52+
* Whether the SFTP settings are enabled
53+
* @return bool
54+
*/
55+
public function getEnabled()
56+
{
57+
return $this->enabled;
58+
}
59+
60+
/**
61+
* Set Enabled
62+
* Whether the SFTP settings are enabled
63+
* @param bool $value
64+
* @return $this
65+
*/
66+
public function setEnabled($value)
67+
{
68+
$this->enabled = $value;
69+
return $this;
70+
}
71+
72+
/**
73+
* Get Endpoint
74+
* SFTP server endpoint with port
75+
* @return string
76+
*/
77+
public function getEndpoint()
78+
{
79+
return $this->endpoint;
80+
}
81+
82+
/**
83+
* Set Endpoint
84+
* SFTP server endpoint with port
85+
* @param string $value
86+
* @return $this
87+
*/
88+
public function setEndpoint($value)
89+
{
90+
$this->endpoint = $value;
91+
return $this;
92+
}
93+
94+
/**
95+
* Get Username
96+
* SFTP server username
97+
* @return string
98+
*/
99+
public function getUsername()
100+
{
101+
return $this->username;
102+
}
103+
104+
/**
105+
* Set Username
106+
* SFTP server username
107+
* @param string $value
108+
* @return $this
109+
*/
110+
public function setUsername($value)
111+
{
112+
$this->username = $value;
113+
return $this;
114+
}
115+
116+
117+
/**
118+
* Fills the current object with the new values pulled from the data
119+
* @param array $data
120+
* @return ProjectSFTPSettingsPublic
121+
*/
122+
public function fillWithData($data)
123+
{
124+
if(! empty($data['enabled']))
125+
$this->setEnabled($data['enabled']);
126+
127+
if(! empty($data['endpoint']))
128+
$this->setEndpoint($data['endpoint']);
129+
130+
if(! empty($data['username']))
131+
$this->setUsername($data['username']);
132+
133+
return $this;
134+
}
135+
136+
/**
137+
* Implements the JsonSerializable interface
138+
* @return object
139+
*/
140+
public function jsonSerialize() {
141+
return array(
142+
"enabled" => $this->getEnabled(),
143+
"endpoint" => $this->getEndpoint(),
144+
"username" => $this->getUsername(),
145+
);
146+
}
147+
148+
149+
/**
150+
* Fetch the SFTP settings for the project.
151+
* @param string $id
152+
* @param array $options
153+
* @return $this
154+
*/
155+
public function fetchSftpSettings($id, $options = array())
156+
{
157+
$this->fillWithData($options);
158+
159+
$request = new Request($this->client);
160+
$path = "/projects/" . urlencode($id) . "/sftp-settings";
161+
162+
$data = array(
163+
164+
);
165+
166+
$response = $request->get($path, $data, $options);
167+
$returnValues = array();
168+
169+
170+
// Handling for field sftp_settings
171+
$body = $response->getBody();
172+
$body = $body['sftp_settings'];
173+
$returnValues['fetchSftpSettings'] = $this->fillWithData($body);
174+
175+
return array_values($returnValues)[0];
176+
}
177+
178+
}

0 commit comments

Comments
 (0)