Skip to content

Commit 8df17d7

Browse files
feat: add-new-operation-error-message-field (#25)
Co-authored-by: ProcessOut Fountain <internal@processout.com>
1 parent 93d61ed commit 8df17d7

8 files changed

Lines changed: 177 additions & 18 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": "^7.1.0"
23+
"processout/processout-php": "^7.2.0"
2424
}
2525
}
2626
```

init.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
include_once(dirname(__FILE__) . "/src/ErrorCodes.php");
8282
include_once(dirname(__FILE__) . "/src/CategoryErrorCodes.php");
8383
include_once(dirname(__FILE__) . "/src/ExternalThreeDS.php");
84-
include_once(dirname(__FILE__) . "/src/NativeAPMTransactionDetails.php");
8584
include_once(dirname(__FILE__) . "/src/NativeAPMTransactionDetailsGateway.php");
8685
include_once(dirname(__FILE__) . "/src/NativeAPMTransactionDetailsInvoice.php");
86+
include_once(dirname(__FILE__) . "/src/NativeAPMTransactionDetails.php");
8787

8888
include_once(dirname(__FILE__) . "/src/GatewayRequest.php");

src/Customer.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ class Customer implements \JsonSerializable
9494
*/
9595
protected $lastName;
9696

97+
/**
98+
* Company name of the customer (for business customers only)
99+
* @var string
100+
*/
101+
protected $companyName;
102+
97103
/**
98104
* Address of the customer
99105
* @var string
@@ -545,6 +551,28 @@ public function setLastName($value)
545551
return $this;
546552
}
547553

554+
/**
555+
* Get CompanyName
556+
* Company name of the customer (for business customers only)
557+
* @return string
558+
*/
559+
public function getCompanyName()
560+
{
561+
return $this->companyName;
562+
}
563+
564+
/**
565+
* Set CompanyName
566+
* Company name of the customer (for business customers only)
567+
* @param string $value
568+
* @return $this
569+
*/
570+
public function setCompanyName($value)
571+
{
572+
$this->companyName = $value;
573+
return $this;
574+
}
575+
548576
/**
549577
* Get Address1
550578
* Address of the customer
@@ -973,6 +1001,9 @@ public function fillWithData($data)
9731001
if(! empty($data['last_name']))
9741002
$this->setLastName($data['last_name']);
9751003

1004+
if(! empty($data['company_name']))
1005+
$this->setCompanyName($data['company_name']);
1006+
9761007
if(! empty($data['address1']))
9771008
$this->setAddress1($data['address1']);
9781009

@@ -1046,6 +1077,7 @@ public function jsonSerialize() {
10461077
"email" => $this->getEmail(),
10471078
"first_name" => $this->getFirstName(),
10481079
"last_name" => $this->getLastName(),
1080+
"company_name" => $this->getCompanyName(),
10491081
"address1" => $this->getAddress1(),
10501082
"address2" => $this->getAddress2(),
10511083
"city" => $this->getCity(),
@@ -1277,6 +1309,7 @@ public function create($options = array())
12771309
"email" => $this->getEmail(),
12781310
"first_name" => $this->getFirstName(),
12791311
"last_name" => $this->getLastName(),
1312+
"company_name" => $this->getCompanyName(),
12801313
"address1" => $this->getAddress1(),
12811314
"address2" => $this->getAddress2(),
12821315
"city" => $this->getCity(),
@@ -1354,6 +1387,7 @@ public function save($options = array())
13541387
"email" => $this->getEmail(),
13551388
"first_name" => $this->getFirstName(),
13561389
"last_name" => $this->getLastName(),
1390+
"company_name" => $this->getCompanyName(),
13571391
"address1" => $this->getAddress1(),
13581392
"address2" => $this->getAddress2(),
13591393
"city" => $this->getCity(),

src/Invoice.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,4 +2291,65 @@ public function delete($invoiceId, $options = array())
22912291
return array_values($returnValues)[0];
22922292
}
22932293

2294+
/**
2295+
* Refresh invoice by its ID with PSP.
2296+
* @param string $invoiceId
2297+
* @param array $options
2298+
* @return $this
2299+
*/
2300+
public function syncWithPsp($invoiceId, $options = array())
2301+
{
2302+
$this->fillWithData($options);
2303+
2304+
$request = new Request($this->client);
2305+
$path = "/invoices/" . urlencode($invoiceId) . "/sync-with-psp";
2306+
2307+
$data = array(
2308+
2309+
);
2310+
2311+
$response = $request->put($path, $data, $options);
2312+
$returnValues = array();
2313+
2314+
2315+
// Handling for field invoice
2316+
$body = $response->getBody();
2317+
$body = $body['invoice'];
2318+
$returnValues['syncWithPsp'] = $this->fillWithData($body);
2319+
2320+
return array_values($returnValues)[0];
2321+
}
2322+
2323+
/**
2324+
* Update invoice by its ID.
2325+
* @param string $invoiceId
2326+
* @param array $options
2327+
* @return $this
2328+
*/
2329+
public function update($invoiceId, $options = array())
2330+
{
2331+
$this->fillWithData($options);
2332+
2333+
$request = new Request($this->client);
2334+
$path = "/invoices/" . urlencode($invoiceId) . "";
2335+
2336+
$data = array(
2337+
"amount" => $this->getAmount(),
2338+
"tax" => $this->getTax(),
2339+
"details" => $this->getDetails(),
2340+
"shipping" => $this->getShipping()
2341+
);
2342+
2343+
$response = $request->put($path, $data, $options);
2344+
$returnValues = array();
2345+
2346+
2347+
// Handling for field invoice
2348+
$body = $response->getBody();
2349+
$body = $body['invoice'];
2350+
$returnValues['update'] = $this->fillWithData($body);
2351+
2352+
return array_values($returnValues)[0];
2353+
}
2354+
22942355
}

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/7.1.0'
34+
'User-Agent: ProcessOut PHP-Bindings/7.2.0'
3535
);
3636
if (! empty($options['idempotencyKey']))
3737
$headers[] = 'Idempotency-Key: ' . $options['idempotencyKey'];

src/ProcessOut.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -694,15 +694,6 @@ public function newExternalThreeDS($prefill = array()) {
694694
return new ExternalThreeDS($this, $prefill);
695695
}
696696

697-
/**
698-
* Create a new NativeAPMTransactionDetails instance
699-
* @param array|null $prefill array used to prefill the object
700-
* @return NativeAPMTransactionDetails
701-
*/
702-
public function newNativeAPMTransactionDetails($prefill = array()) {
703-
return new NativeAPMTransactionDetails($this, $prefill);
704-
}
705-
706697
/**
707698
* Create a new NativeAPMTransactionDetailsGateway instance
708699
* @param array|null $prefill array used to prefill the object
@@ -721,4 +712,13 @@ public function newNativeAPMTransactionDetailsInvoice($prefill = array()) {
721712
return new NativeAPMTransactionDetailsInvoice($this, $prefill);
722713
}
723714

715+
/**
716+
* Create a new NativeAPMTransactionDetails instance
717+
* @param array|null $prefill array used to prefill the object
718+
* @return NativeAPMTransactionDetails
719+
*/
720+
public function newNativeAPMTransactionDetails($prefill = array()) {
721+
return new NativeAPMTransactionDetails($this, $prefill);
722+
}
723+
724724
}

src/Token.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Token implements \JsonSerializable
5959
protected $cardId;
6060

6161
/**
62-
* Type of the token. Can be card or gateway_token
62+
* Type of the token. Can be card, bank_account or gateway_token
6363
* @var string
6464
*/
6565
protected $type;
@@ -95,7 +95,7 @@ class Token implements \JsonSerializable
9595
protected $cancelUrl;
9696

9797
/**
98-
* Summary of the customer token, such as a description of the card used or the email of a PayPal account
98+
* Summary of the customer token, such as a description of the card used or bank account or the email of a PayPal account
9999
* @var string
100100
*/
101101
protected $summary;
@@ -338,7 +338,7 @@ public function setCardId($value)
338338

339339
/**
340340
* Get Type
341-
* Type of the token. Can be card or gateway_token
341+
* Type of the token. Can be card, bank_account or gateway_token
342342
* @return string
343343
*/
344344
public function getType()
@@ -348,7 +348,7 @@ public function getType()
348348

349349
/**
350350
* Set Type
351-
* Type of the token. Can be card or gateway_token
351+
* Type of the token. Can be card, bank_account or gateway_token
352352
* @param string $value
353353
* @return $this
354354
*/
@@ -470,7 +470,7 @@ public function setCancelUrl($value)
470470

471471
/**
472472
* Get Summary
473-
* Summary of the customer token, such as a description of the card used or the email of a PayPal account
473+
* Summary of the customer token, such as a description of the card used or bank account or the email of a PayPal account
474474
* @return string
475475
*/
476476
public function getSummary()
@@ -480,7 +480,7 @@ public function getSummary()
480480

481481
/**
482482
* Set Summary
483-
* Summary of the customer token, such as a description of the card used or the email of a PayPal account
483+
* Summary of the customer token, such as a description of the card used or bank account or the email of a PayPal account
484484
* @param string $value
485485
* @return $this
486486
*/

src/TransactionOperation.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ class TransactionOperation implements \JsonSerializable
124124
*/
125125
protected $errorCode;
126126

127+
/**
128+
* Error message returned when attempting the operation, if any
129+
* @var string
130+
*/
131+
protected $errorMessage;
132+
127133
/**
128134
* Additionnal context saved when processing the transaction on the specific PSP
129135
* @var dictionary
@@ -160,6 +166,12 @@ class TransactionOperation implements \JsonSerializable
160166
*/
161167
protected $schemeId;
162168

169+
/**
170+
* Indicates whether the transaction was processed with a network token instead of raw card details
171+
* @var boolean
172+
*/
173+
protected $processedWithNetworkToken;
174+
163175
/**
164176
* Payment type of the transaction
165177
* @var string
@@ -621,6 +633,28 @@ public function setErrorCode($value)
621633
return $this;
622634
}
623635

636+
/**
637+
* Get ErrorMessage
638+
* Error message returned when attempting the operation, if any
639+
* @return string
640+
*/
641+
public function getErrorMessage()
642+
{
643+
return $this->errorMessage;
644+
}
645+
646+
/**
647+
* Set ErrorMessage
648+
* Error message returned when attempting the operation, if any
649+
* @param string $value
650+
* @return $this
651+
*/
652+
public function setErrorMessage($value)
653+
{
654+
$this->errorMessage = $value;
655+
return $this;
656+
}
657+
624658
/**
625659
* Get GatewayData
626660
* Additionnal context saved when processing the transaction on the specific PSP
@@ -774,6 +808,28 @@ public function setSchemeId($value)
774808
return $this;
775809
}
776810

811+
/**
812+
* Get ProcessedWithNetworkToken
813+
* Indicates whether the transaction was processed with a network token instead of raw card details
814+
* @return bool
815+
*/
816+
public function getProcessedWithNetworkToken()
817+
{
818+
return $this->processedWithNetworkToken;
819+
}
820+
821+
/**
822+
* Set ProcessedWithNetworkToken
823+
* Indicates whether the transaction was processed with a network token instead of raw card details
824+
* @param bool $value
825+
* @return $this
826+
*/
827+
public function setProcessedWithNetworkToken($value)
828+
{
829+
$this->processedWithNetworkToken = $value;
830+
return $this;
831+
}
832+
777833
/**
778834
* Get PaymentType
779835
* Payment type of the transaction
@@ -924,6 +980,9 @@ public function fillWithData($data)
924980
if(! empty($data['error_code']))
925981
$this->setErrorCode($data['error_code']);
926982

983+
if(! empty($data['error_message']))
984+
$this->setErrorMessage($data['error_message']);
985+
927986
if(! empty($data['gateway_data']))
928987
$this->setGatewayData($data['gateway_data']);
929988

@@ -942,6 +1001,9 @@ public function fillWithData($data)
9421001
if(! empty($data['scheme_id']))
9431002
$this->setSchemeId($data['scheme_id']);
9441003

1004+
if(! empty($data['processed_with_network_token']))
1005+
$this->setProcessedWithNetworkToken($data['processed_with_network_token']);
1006+
9451007
if(! empty($data['payment_type']))
9461008
$this->setPaymentType($data['payment_type']);
9471009

@@ -981,12 +1043,14 @@ public function jsonSerialize() {
9811043
"gateway_operation_id" => $this->getGatewayOperationId(),
9821044
"arn" => $this->getArn(),
9831045
"error_code" => $this->getErrorCode(),
1046+
"error_message" => $this->getErrorMessage(),
9841047
"gateway_data" => $this->getGatewayData(),
9851048
"payment_data_three_d_s_request" => $this->getPaymentDataThreeDSRequest(),
9861049
"payment_data_three_d_s_authentication" => $this->getPaymentDataThreeDSAuthentication(),
9871050
"payment_data_network_authentication" => $this->getPaymentDataNetworkAuthentication(),
9881051
"initial_scheme_transaction_id" => $this->getInitialSchemeTransactionId(),
9891052
"scheme_id" => $this->getSchemeId(),
1053+
"processed_with_network_token" => $this->getProcessedWithNetworkToken(),
9901054
"payment_type" => $this->getPaymentType(),
9911055
"metadata" => $this->getMetadata(),
9921056
"gateway_fee" => $this->getGatewayFee(),

0 commit comments

Comments
 (0)