Skip to content

Commit ea0967c

Browse files
feat: add customer and invoice reference_id; add balances customer action (#27)
Co-authored-by: ProcessOut Fountain <internal@processout.com>
1 parent 9070f43 commit ea0967c

31 files changed

Lines changed: 598 additions & 181 deletions

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": "^7.3.0"
23+
"processout/processout-php": "^7.4.0"
2424
}
2525
}
2626
```

init.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
include_once(dirname(__FILE__) . "/src/AlternativeMerchantCertificate.php");
2020
include_once(dirname(__FILE__) . "/src/Balances.php");
2121
include_once(dirname(__FILE__) . "/src/Balance.php");
22+
include_once(dirname(__FILE__) . "/src/BalancesCustomerAction.php");
2223
include_once(dirname(__FILE__) . "/src/Card.php");
2324
include_once(dirname(__FILE__) . "/src/CardInformation.php");
2425
include_once(dirname(__FILE__) . "/src/Phone.php");
@@ -76,11 +77,11 @@
7677
include_once(dirname(__FILE__) . "/src/TransactionOperation.php");
7778
include_once(dirname(__FILE__) . "/src/Webhook.php");
7879
include_once(dirname(__FILE__) . "/src/WebhookEndpoint.php");
79-
include_once(dirname(__FILE__) . "/src/CardCreateRequest.php");
8080
include_once(dirname(__FILE__) . "/src/Device.php");
8181
include_once(dirname(__FILE__) . "/src/CardContact.php");
8282
include_once(dirname(__FILE__) . "/src/CardShipping.php");
8383
include_once(dirname(__FILE__) . "/src/CardUpdateRequest.php");
84+
include_once(dirname(__FILE__) . "/src/CardCreateRequest.php");
8485
include_once(dirname(__FILE__) . "/src/ErrorCodes.php");
8586
include_once(dirname(__FILE__) . "/src/CategoryErrorCodes.php");
8687
include_once(dirname(__FILE__) . "/src/ExternalThreeDS.php");

src/Activity.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,10 @@ public function find($activityId, $options = array())
338338

339339
// Handling for field activity
340340
$body = $response->getBody();
341-
$body = $body['activity'];
342-
$returnValues['find'] = $this->fillWithData($body);
341+
if (isset($body['activity'])) {
342+
$body = $body['activity'];
343+
$returnValues['find'] = $this->fillWithData($body);
344+
}
343345

344346
return array_values($returnValues)[0];
345347
}

src/Addon.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,10 @@ public function create($options = array())
584584

585585
// Handling for field addon
586586
$body = $response->getBody();
587-
$body = $body['addon'];
588-
$returnValues['create'] = $this->fillWithData($body);
587+
if (isset($body['addon'])) {
588+
$body = $body['addon'];
589+
$returnValues['create'] = $this->fillWithData($body);
590+
}
589591

590592
return array_values($returnValues)[0];
591593
}
@@ -614,8 +616,10 @@ public function find($subscriptionId, $addonId, $options = array())
614616

615617
// Handling for field addon
616618
$body = $response->getBody();
617-
$body = $body['addon'];
618-
$returnValues['find'] = $this->fillWithData($body);
619+
if (isset($body['addon'])) {
620+
$body = $body['addon'];
621+
$returnValues['find'] = $this->fillWithData($body);
622+
}
619623

620624
return array_values($returnValues)[0];
621625
}
@@ -651,8 +655,10 @@ public function save($options = array())
651655

652656
// Handling for field addon
653657
$body = $response->getBody();
654-
$body = $body['addon'];
655-
$returnValues['save'] = $this->fillWithData($body);
658+
if (isset($body['addon'])) {
659+
$body = $body['addon'];
660+
$returnValues['save'] = $this->fillWithData($body);
661+
}
656662

657663
return array_values($returnValues)[0];
658664
}

src/AlternativeMerchantCertificate.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ public function save($options = array())
104104

105105
// Handling for field alternative_merchant_certificate
106106
$body = $response->getBody();
107-
$body = $body['alternative_merchant_certificate'];
108-
$alternativeMerchantCertificate = new AlternativeMerchantCertificate($this->client);
109-
$returnValues['alternativeMerchantCertificate'] = $alternativeMerchantCertificate->fillWithData($body);
107+
if (isset($body['alternative_merchant_certificate'])) {
108+
$body = $body['alternative_merchant_certificate'];
109+
$alternativeMerchantCertificate = new AlternativeMerchantCertificate($this->client);
110+
$returnValues['alternativeMerchantCertificate'] = $alternativeMerchantCertificate->fillWithData($body);
111+
}
110112

111113

112114
return array_values($returnValues)[0];

src/ApplePayAlternativeMerchantCertificates.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ public function fetch($options = array())
148148

149149
// Handling for field applepay_certificates
150150
$body = $response->getBody();
151-
$body = $body['applepay_certificates'];
152-
$applePayAlternativeMerchantCertificates = new ApplePayAlternativeMerchantCertificates($this->client);
153-
$returnValues['applePayAlternativeMerchantCertificates'] = $applePayAlternativeMerchantCertificates->fillWithData($body);
151+
if (isset($body['applepay_certificates'])) {
152+
$body = $body['applepay_certificates'];
153+
$applePayAlternativeMerchantCertificates = new ApplePayAlternativeMerchantCertificates($this->client);
154+
$returnValues['applePayAlternativeMerchantCertificates'] = $applePayAlternativeMerchantCertificates->fillWithData($body);
155+
}
154156

155157

156158
return array_values($returnValues)[0];

src/Balances.php

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ class Balances implements \JsonSerializable
2222
*/
2323
protected $vouchers;
2424

25+
/**
26+
* Available balance of the customer
27+
* @var object
28+
*/
29+
protected $availableBalance;
30+
31+
/**
32+
* Customer action to be performed, such as redirecting to a URL
33+
* @var object
34+
*/
35+
protected $customerAction;
36+
2537
/**
2638
* Balances constructor
2739
* @param ProcessOut\ProcessOut $client
@@ -69,6 +81,64 @@ public function setVouchers($value)
6981
return $this;
7082
}
7183

84+
/**
85+
* Get AvailableBalance
86+
* Available balance of the customer
87+
* @return object
88+
*/
89+
public function getAvailableBalance()
90+
{
91+
return $this->availableBalance;
92+
}
93+
94+
/**
95+
* Set AvailableBalance
96+
* Available balance of the customer
97+
* @param object $value
98+
* @return $this
99+
*/
100+
public function setAvailableBalance($value)
101+
{
102+
if (is_object($value))
103+
$this->availableBalance = $value;
104+
else
105+
{
106+
$obj = new Balance($this->client);
107+
$obj->fillWithData($value);
108+
$this->availableBalance = $obj;
109+
}
110+
return $this;
111+
}
112+
113+
/**
114+
* Get CustomerAction
115+
* Customer action to be performed, such as redirecting to a URL
116+
* @return object
117+
*/
118+
public function getCustomerAction()
119+
{
120+
return $this->customerAction;
121+
}
122+
123+
/**
124+
* Set CustomerAction
125+
* Customer action to be performed, such as redirecting to a URL
126+
* @param object $value
127+
* @return $this
128+
*/
129+
public function setCustomerAction($value)
130+
{
131+
if (is_object($value))
132+
$this->customerAction = $value;
133+
else
134+
{
135+
$obj = new BalancesCustomerAction($this->client);
136+
$obj->fillWithData($value);
137+
$this->customerAction = $obj;
138+
}
139+
return $this;
140+
}
141+
72142

73143
/**
74144
* Fills the current object with the new values pulled from the data
@@ -80,6 +150,12 @@ public function fillWithData($data)
80150
if(! empty($data['vouchers']))
81151
$this->setVouchers($data['vouchers']);
82152

153+
if(! empty($data['available_balance']))
154+
$this->setAvailableBalance($data['available_balance']);
155+
156+
if(! empty($data['customer_action']))
157+
$this->setCustomerAction($data['customer_action']);
158+
83159
return $this;
84160
}
85161

@@ -90,6 +166,8 @@ public function fillWithData($data)
90166
public function jsonSerialize() {
91167
return array(
92168
"vouchers" => $this->getVouchers(),
169+
"available_balance" => $this->getAvailableBalance(),
170+
"customer_action" => $this->getCustomerAction(),
93171
);
94172
}
95173

@@ -117,9 +195,11 @@ public function find($tokenId, $options = array())
117195

118196
// Handling for field balances
119197
$body = $response->getBody();
120-
$body = $body['balances'];
121-
$balances = new Balances($this->client);
122-
$returnValues['balances'] = $balances->fillWithData($body);
198+
if (isset($body['balances'])) {
199+
$body = $body['balances'];
200+
$balances = new Balances($this->client);
201+
$returnValues['balances'] = $balances->fillWithData($body);
202+
}
123203

124204

125205
return array_values($returnValues)[0];

src/BalancesCustomerAction.php

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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 BalancesCustomerAction implements \JsonSerializable
11+
{
12+
13+
/**
14+
* ProcessOut's client
15+
* @var ProcessOut\ProcessOut
16+
*/
17+
protected $client;
18+
19+
/**
20+
* Customer action type (such as url)
21+
* @var string
22+
*/
23+
protected $type;
24+
25+
/**
26+
* Value of the customer action. If type is an URL, URL to which you should redirect your customer
27+
* @var string
28+
*/
29+
protected $value;
30+
31+
/**
32+
* BalancesCustomerAction constructor
33+
* @param ProcessOut\ProcessOut $client
34+
* @param array|null $prefill
35+
*/
36+
public function __construct(ProcessOut $client, $prefill = array())
37+
{
38+
$this->client = $client;
39+
40+
$this->fillWithData($prefill);
41+
}
42+
43+
44+
/**
45+
* Get Type
46+
* Customer action type (such as url)
47+
* @return string
48+
*/
49+
public function getType()
50+
{
51+
return $this->type;
52+
}
53+
54+
/**
55+
* Set Type
56+
* Customer action type (such as url)
57+
* @param string $value
58+
* @return $this
59+
*/
60+
public function setType($value)
61+
{
62+
$this->type = $value;
63+
return $this;
64+
}
65+
66+
/**
67+
* Get Value
68+
* Value of the customer action. If type is an URL, URL to which you should redirect your customer
69+
* @return string
70+
*/
71+
public function getValue()
72+
{
73+
return $this->value;
74+
}
75+
76+
/**
77+
* Set Value
78+
* Value of the customer action. If type is an URL, URL to which you should redirect your customer
79+
* @param string $value
80+
* @return $this
81+
*/
82+
public function setValue($value)
83+
{
84+
$this->value = $value;
85+
return $this;
86+
}
87+
88+
89+
/**
90+
* Fills the current object with the new values pulled from the data
91+
* @param array $data
92+
* @return BalancesCustomerAction
93+
*/
94+
public function fillWithData($data)
95+
{
96+
if(! empty($data['type']))
97+
$this->setType($data['type']);
98+
99+
if(! empty($data['value']))
100+
$this->setValue($data['value']);
101+
102+
return $this;
103+
}
104+
105+
/**
106+
* Implements the JsonSerializable interface
107+
* @return object
108+
*/
109+
public function jsonSerialize() {
110+
return array(
111+
"type" => $this->getType(),
112+
"value" => $this->getValue(),
113+
);
114+
}
115+
116+
117+
}

src/Card.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,8 +1177,10 @@ public function find($cardId, $options = array())
11771177

11781178
// Handling for field card
11791179
$body = $response->getBody();
1180-
$body = $body['card'];
1181-
$returnValues['find'] = $this->fillWithData($body);
1180+
if (isset($body['card'])) {
1181+
$body = $body['card'];
1182+
$returnValues['find'] = $this->fillWithData($body);
1183+
}
11821184

11831185
return array_values($returnValues)[0];
11841186
}

src/CardCreateRequest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,10 @@ public function create($options = array())
653653

654654
// Handling for field card
655655
$body = $response->getBody();
656-
$body = $body['card'];
657-
$returnValues['create'] = $this->fillWithData($body);
656+
if (isset($body['card'])) {
657+
$body = $body['card'];
658+
$returnValues['create'] = $this->fillWithData($body);
659+
}
658660

659661
return array_values($returnValues)[0];
660662
}

0 commit comments

Comments
 (0)