Skip to content

Commit 8049c0e

Browse files
Release 3.0.6
1 parent 6370e33 commit 8049c0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+635
-631
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This repository contains the PostFinance Checkout plugin that enables WooCommerc
1616

1717
## Documentation
1818

19-
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.0.5/docs/en/documentation.html)
19+
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.0.6/docs/en/documentation.html)
2020

2121
## Support
2222

@@ -33,4 +33,4 @@ ____________________________________________________________________________
3333

3434
## License
3535

36-
Please see the [license file](https://github.com/pfpayments/woocommerce/blob/3.0.5/LICENSE) for more information.
36+
Please see the [license file](https://github.com/pfpayments/woocommerce/blob/3.0.6/LICENSE) for more information.

changelog.txt

+7
Original file line numberDiff line numberDiff line change
@@ -763,3 +763,10 @@ Tested against:
763763
- [Tested Against] Woocommerce 8.7.0
764764
- [Tested Against] PHP SDK 4.0.2
765765

766+
= 3.0.6 - May 30 2024 =
767+
- [Feature] Upgraded PHP-SDK to 4.2.0
768+
- [Tested Against] PHP 8.2
769+
- [Tested Against] Wordpress 6.5.3
770+
- [Tested Against] Woocommerce 8.9.1
771+
- [Tested Against] PHP SDK 4.2.0
772+

docs/en/documentation.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2>Documentation</h2> </div>
2323
</a>
2424
</li>
2525
<li>
26-
<a href="https://github.com/pfpayments/woocommerce/releases/tag/3.0.5/">
26+
<a href="https://github.com/pfpayments/woocommerce/releases/tag/3.0.6/">
2727
Source
2828
</a>
2929
</li>

includes/admin/class-wc-postfinancecheckout-admin-settings-page.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function get_settings() {
187187
$settings = array(
188188
array(
189189
'links' => array(
190-
'https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.0.5/docs/en/documentation.html' => __( 'Documentation', 'woo-postfinancecheckout' ),
190+
'https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.0.6/docs/en/documentation.html' => __( 'Documentation', 'woo-postfinancecheckout' ),
191191
'https://checkout.postfinance.ch/en-ch/user/signup' => __( 'Sign Up', 'woo-postfinancecheckout' ),
192192
),
193193
'type' => 'postfinancecheckout_links',

includes/class-wc-postfinancecheckout-migration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public static function check_version() {
249249
public static function plugin_row_meta( $links, $file ) {
250250
if ( WC_POSTFINANCECHECKOUT_PLUGIN_BASENAME === $file ) {
251251
$row_meta = array(
252-
'docs' => '<a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.0.5/docs/en/documentation.html" aria-label="' . esc_attr__( 'View Documentation', 'woo-postfinancecheckout' ) . '">' . esc_html__( 'Documentation', 'woo-postfinancecheckout' ) . '</a>',
252+
'docs' => '<a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.0.6/docs/en/documentation.html" aria-label="' . esc_attr__( 'View Documentation', 'woo-postfinancecheckout' ) . '">' . esc_html__( 'Documentation', 'woo-postfinancecheckout' ) . '</a>',
253253
);
254254

255255
return array_merge( $links, $row_meta );

postfinancecheckout-sdk/LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2023 wallee AG
189+
Copyright 2024 wallee AG
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

postfinancecheckout-sdk/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,44 @@ putenv('PFC_HTTP_CLIENT=curl');
127127
?>
128128
```
129129

130+
### Integrating Webhook Payload Signing Mechanism into webhook callback handler
131+
132+
The HTTP request which is sent for a state change of an entity now includes an additional field `state`, which provides information about the update of the monitored entity's state. This enhancement is a result of the implementation of our webhook encryption mechanism.
133+
134+
Payload field `state` provides direct information about the state update of the entity, making additional API calls to retrieve the entity state redundant.
135+
136+
#### ⚠️ Warning: Generic Pseudocode
137+
138+
> **The provided pseudocode is intentionally generic and serves to illustrate the process of enhancing your API to leverage webhook payload signing. It is not a complete implementation.**
139+
>
140+
> Please ensure that you adapt and extend this code to meet the specific needs of your application, including appropriate security measures and error handling.
141+
For a detailed webhook payload signing mechanism understanding we highly recommend referring to our comprehensive
142+
[Webhook Payload Signing Documentation](https://checkout.postfinance.ch/doc/webhooks#_webhook_payload_signing_mechanism).
143+
144+
```php
145+
public function handleWebhook() {
146+
$requestPayload = file_get_contents('php://input');
147+
$signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';
148+
149+
if (empty($signature)) {
150+
// Make additional API call to retrieve the entity state
151+
// ...
152+
} else {
153+
if ($client->getWebhookEncryptionService()->isContentValid($signature, $requestPayload)) {
154+
// Parse requestPayload to extract 'state' value
155+
// $state = ...
156+
// Process entity's state change
157+
// $this->processEntityStateChange($state);
158+
// ...
159+
}
160+
}
161+
162+
// Process the received webhook data
163+
// ...
164+
165+
}
166+
```
167+
130168
## License
131169

132170
Please see the [license file](https://github.com/pfpayments/php-sdk/blob/master/LICENSE) for more information.

postfinancecheckout-sdk/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postfinancecheckout/sdk",
3-
"version": "4.0.2",
3+
"version": "4.2.0",
44
"description": "PostFinance Checkout SDK for PHP",
55
"keywords": [
66
"postfinancecheckout",

postfinancecheckout-sdk/lib/ApiClient.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class ApiClient {
4848
* @var array
4949
*/
5050
private $defaultHeaders = [
51-
'x-meta-sdk-version' => "4.0.2",
51+
'x-meta-sdk-version' => "4.2.0",
5252
'x-meta-sdk-language' => 'php',
5353
'x-meta-sdk-provider' => "PostFinance Checkout",
5454
];
@@ -58,7 +58,7 @@ final class ApiClient {
5858
*
5959
* @var string
6060
*/
61-
private $userAgent = 'PHP-Client/4.0.2/php';
61+
private $userAgent = 'PHP-Client/4.2.0/php';
6262

6363
/**
6464
* The path to the certificate authority file.

postfinancecheckout-sdk/lib/Configuration.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Configuration
8080
*
8181
* @var string
8282
*/
83-
protected $userAgent = 'PostFinanceCheckout\Sdk/4.0.2/php';
83+
protected $userAgent = 'PostFinanceCheckout\Sdk/4.2.0/php';
8484

8585
/**
8686
* Debug switch (default set to false)
@@ -388,8 +388,8 @@ public static function toDebugReport()
388388
$report = 'PHP SDK (PostFinanceCheckout\Sdk) Debug Report:' . PHP_EOL;
389389
$report .= ' OS: ' . php_uname() . PHP_EOL;
390390
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
391-
$report .= ' OpenAPI Spec Version: 4.0.2' . PHP_EOL;
392-
$report .= ' SDK Package Version: 4.0.2' . PHP_EOL;
391+
$report .= ' OpenAPI Spec Version: 4.2.0' . PHP_EOL;
392+
$report .= ' SDK Package Version: 4.2.0' . PHP_EOL;
393393
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
394394

395395
return $report;

postfinancecheckout-sdk/lib/Http/CurlHttpClient.php

+24-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public function isSupported() {
3939

4040
public function send(ApiClient $apiClient, HttpRequest $request) {
4141
$curl = curl_init();
42+
43+
$tempCAFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "PostFinance Checkout-ca-bundle.crt";
44+
4245
// set timeout, if needed
4346
if ($request->getTimeOut() !== 0) {
4447
curl_setopt($curl, CURLOPT_TIMEOUT, $request->getTimeOut());
@@ -58,7 +61,11 @@ public function send(ApiClient $apiClient, HttpRequest $request) {
5861
} else {
5962
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
6063
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
61-
curl_setopt($curl, CURLOPT_CAINFO, $apiClient->getCertificateAuthority());
64+
if (file_exists($tempCAFile)) {
65+
// use the temporal CA Bundle if it was set, which indicates a previous error.
66+
$apiClient->setCertificateAuthority($tempCAFile);
67+
curl_setopt($curl, CURLOPT_CAINFO, $apiClient->getCertificateAuthority());
68+
}
6269
}
6370

6471
if ($request->getMethod() === HttpRequest::POST) {
@@ -102,7 +109,22 @@ public function send(ApiClient $apiClient, HttpRequest $request) {
102109

103110
// Make the request
104111
$response = curl_exec($curl);
105-
$response = $this->handleResponse($apiClient, $request, $curl, $response, $request->getUrl());
112+
if ($response) {
113+
$response = $this->handleResponse($apiClient, $request, $curl, $response, $request->getUrl());
114+
} else {
115+
// if there was an error, try again with the CA bundle provided by this SDK.
116+
if (!file_exists($tempCAFile)) {
117+
$caContent = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "ca-bundle.crt");
118+
file_put_contents($tempCAFile, $caContent);
119+
120+
// Try again the request, this time with the CA bundle provided by this SDK.
121+
$apiClient->setCertificateAuthority($tempCAFile);
122+
curl_setopt($curl, CURLOPT_CAINFO, $apiClient->getCertificateAuthority());
123+
$response = curl_exec($curl);
124+
$response = $this->handleResponse($apiClient, $request, $curl, $response, $request->getUrl());
125+
}
126+
}
127+
106128
curl_close($curl);
107129
fclose($debugFilePointer);
108130

postfinancecheckout-sdk/lib/Model/AbstractTokenUpdate.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function getCustomerEmailAddress()
255255
/**
256256
* Sets customer_email_address
257257
*
258-
* @param string $customer_email_address The customer email address is the email address of the customer.
258+
* @param string $customer_email_address The customer's email address.
259259
*
260260
* @return $this
261261
*/
@@ -284,7 +284,7 @@ public function getCustomerId()
284284
/**
285285
* Sets customer_id
286286
*
287-
* @param string $customer_id The customer ID identifies the customer in the merchant system. In case the customer ID has been provided it has to correspond with the customer ID provided on the transaction. The customer ID will not be changed automatically. The merchant system has to provide it.
287+
* @param string $customer_id The unique identifier of the customer in the external system.
288288
*
289289
* @return $this
290290
*/
@@ -309,7 +309,7 @@ public function getEnabledForOneClickPayment()
309309
/**
310310
* Sets enabled_for_one_click_payment
311311
*
312-
* @param bool $enabled_for_one_click_payment When a token is enabled for one-click payments the buyer will be able to select the token within the iFrame or on the payment page to pay with the token. The usage of the token will reduce the number of steps the buyer has to go through. The buyer is linked via the customer ID on the transaction with the token. Means the token will be visible for buyers with the same customer ID. Additionally the payment method has to be configured to allow the one-click payments.
312+
* @param bool $enabled_for_one_click_payment Whether the token is enabled for one-click payments, which simplify the payment process for the customer. One-click tokens are linked to customers via the customer ID.
313313
*
314314
* @return $this
315315
*/
@@ -359,7 +359,7 @@ public function getTimeZone()
359359
/**
360360
* Sets time_zone
361361
*
362-
* @param string $time_zone The time zone defines in which time zone the customer is located in. The time zone may affects how dates are formatted when interacting with the customer.
362+
* @param string $time_zone The customer's time zone, which affects how dates and times are formatted when communicating with the customer.
363363
*
364364
* @return $this
365365
*/
@@ -384,7 +384,7 @@ public function getTokenReference()
384384
/**
385385
* Sets token_reference
386386
*
387-
* @param string $token_reference Use something that it is easy to identify and may help you find the token (e.g. customer id, email address).
387+
* @param string $token_reference The reference used to identify the payment token (e.g. the customer's ID or email address).
388388
*
389389
* @return $this
390390
*/

postfinancecheckout-sdk/lib/Model/AbstractTransactionPending.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function getAllowedPaymentMethodBrands()
370370
/**
371371
* Sets allowed_payment_method_brands
372372
*
373-
* @param int[] $allowed_payment_method_brands
373+
* @param int[] $allowed_payment_method_brands The payment method brands that can be used to authorize the transaction.
374374
*
375375
* @return $this
376376
*/
@@ -395,7 +395,7 @@ public function getAllowedPaymentMethodConfigurations()
395395
/**
396396
* Sets allowed_payment_method_configurations
397397
*
398-
* @param int[] $allowed_payment_method_configurations
398+
* @param int[] $allowed_payment_method_configurations The payment method configurations that can be used to authorize the transaction.
399399
*
400400
* @return $this
401401
*/
@@ -420,7 +420,7 @@ public function getBillingAddress()
420420
/**
421421
* Sets billing_address
422422
*
423-
* @param \PostFinanceCheckout\Sdk\Model\AddressCreate $billing_address
423+
* @param \PostFinanceCheckout\Sdk\Model\AddressCreate $billing_address The address associated with the payment method for invoicing and transaction processing purposes.
424424
*
425425
* @return $this
426426
*/
@@ -445,7 +445,7 @@ public function getCompletionBehavior()
445445
/**
446446
* Sets completion_behavior
447447
*
448-
* @param \PostFinanceCheckout\Sdk\Model\TransactionCompletionBehavior $completion_behavior The completion behavior controls when the transaction is completed.
448+
* @param \PostFinanceCheckout\Sdk\Model\TransactionCompletionBehavior $completion_behavior The behavior that controls when the transaction is completed.
449449
*
450450
* @return $this
451451
*/
@@ -470,7 +470,7 @@ public function getCurrency()
470470
/**
471471
* Sets currency
472472
*
473-
* @param string $currency
473+
* @param string $currency The three-letter code (ISO 4217 format) of the transaction's currency.
474474
*
475475
* @return $this
476476
*/
@@ -495,7 +495,7 @@ public function getCustomerEmailAddress()
495495
/**
496496
* Sets customer_email_address
497497
*
498-
* @param string $customer_email_address The customer email address is the email address of the customer. If no email address is provided on the shipping or billing address this address is used.
498+
* @param string $customer_email_address The customer's email address.
499499
*
500500
* @return $this
501501
*/
@@ -524,7 +524,7 @@ public function getCustomerId()
524524
/**
525525
* Sets customer_id
526526
*
527-
* @param string $customer_id
527+
* @param string $customer_id The unique identifier of the customer in the external system.
528528
*
529529
* @return $this
530530
*/
@@ -549,7 +549,7 @@ public function getFailedUrl()
549549
/**
550550
* Sets failed_url
551551
*
552-
* @param string $failed_url The user will be redirected to failed URL when the transaction could not be authorized or completed. In case no failed URL is specified a default failed page will be displayed.
552+
* @param string $failed_url The URL to redirect the customer back to after they canceled or failed to authenticated their payment.
553553
*
554554
* @return $this
555555
*/
@@ -581,7 +581,7 @@ public function getInvoiceMerchantReference()
581581
/**
582582
* Sets invoice_merchant_reference
583583
*
584-
* @param string $invoice_merchant_reference
584+
* @param string $invoice_merchant_reference The merchant's reference used to identify the invoice.
585585
*
586586
* @return $this
587587
*/
@@ -635,7 +635,7 @@ public function getLineItems()
635635
/**
636636
* Sets line_items
637637
*
638-
* @param \PostFinanceCheckout\Sdk\Model\LineItemCreate[] $line_items
638+
* @param \PostFinanceCheckout\Sdk\Model\LineItemCreate[] $line_items The line items purchased by the customer.
639639
*
640640
* @return $this
641641
*/
@@ -660,7 +660,7 @@ public function getMerchantReference()
660660
/**
661661
* Sets merchant_reference
662662
*
663-
* @param string $merchant_reference
663+
* @param string $merchant_reference The merchant's reference used to identify the transaction.
664664
*
665665
* @return $this
666666
*/
@@ -714,7 +714,7 @@ public function getShippingAddress()
714714
/**
715715
* Sets shipping_address
716716
*
717-
* @param \PostFinanceCheckout\Sdk\Model\AddressCreate $shipping_address
717+
* @param \PostFinanceCheckout\Sdk\Model\AddressCreate $shipping_address The address to where the order will be shipped.
718718
*
719719
* @return $this
720720
*/
@@ -739,7 +739,7 @@ public function getShippingMethod()
739739
/**
740740
* Sets shipping_method
741741
*
742-
* @param string $shipping_method
742+
* @param string $shipping_method The name of the shipping method used to ship the products.
743743
*
744744
* @return $this
745745
*/
@@ -768,7 +768,7 @@ public function getSuccessUrl()
768768
/**
769769
* Sets success_url
770770
*
771-
* @param string $success_url The user will be redirected to success URL when the transaction could be authorized or completed. In case no success URL is specified a default success page will be displayed.
771+
* @param string $success_url The URL to redirect the customer back to after they successfully authenticated their payment.
772772
*
773773
* @return $this
774774
*/
@@ -800,7 +800,7 @@ public function getTimeZone()
800800
/**
801801
* Sets time_zone
802802
*
803-
* @param string $time_zone The time zone defines in which time zone the customer is located in. The time zone may affects how dates are formatted when interacting with the customer.
803+
* @param string $time_zone The customer's time zone, which affects how dates and times are formatted when communicating with the customer.
804804
*
805805
* @return $this
806806
*/
@@ -825,7 +825,7 @@ public function getToken()
825825
/**
826826
* Sets token
827827
*
828-
* @param int $token
828+
* @param int $token The payment token that should be used to charge the customer.
829829
*
830830
* @return $this
831831
*/
@@ -850,7 +850,7 @@ public function getTokenizationMode()
850850
/**
851851
* Sets tokenization_mode
852852
*
853-
* @param \PostFinanceCheckout\Sdk\Model\TokenizationMode $tokenization_mode The tokenization mode controls if and how the tokenization of payment information is applied to the transaction.
853+
* @param \PostFinanceCheckout\Sdk\Model\TokenizationMode $tokenization_mode The tokenization mode specifies whether and how the tokenization of payment information is applied to the transaction.
854854
*
855855
* @return $this
856856
*/

0 commit comments

Comments
 (0)