Skip to content
This repository was archived by the owner on Jan 10, 2022. It is now read-only.

Commit c905762

Browse files
committed
Merge branch 'release/2.0.4'
2 parents 1d2ef83 + 0aed222 commit c905762

6 files changed

Lines changed: 33 additions & 22 deletions

File tree

.scrutinizer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
build:
22
environment:
3+
php: 7.3.0
34
variables:
45
WP_TESTS_DB_NAME: 'wp_phpunit_tests'
56
WP_TESTS_DB_USER: 'root'

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
77
## [Unreleased][unreleased]
88
-
99

10+
## [2.0.4] - 2019-12-22
11+
- Improved error handling with exceptions.
12+
- Updated payment status class name.
13+
1014
## [2.0.3] - 2019-08-26
1115
- Updated packages.
1216

@@ -43,7 +47,8 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C
4347
### Added
4448
- First release.
4549

46-
[unreleased]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.3...HEAD
50+
[unreleased]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.4...HEAD
51+
[2.0.4]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.2...2.0.4
4752
[2.0.3]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.2...2.0.3
4853
[2.0.2]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.1...2.0.2
4954
[2.0.1]: https://github.com/wp-pay-extensions/wp-e-commerce/compare/2.0.0...2.0.1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wp-e-commerce",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"description": "WP eCommerce driver for the WordPress payment processing library.",
55
"repository": {
66
"type": "git",

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ruleset name="WordPress Pay WP eCommerce rules">
44
<config name="minimum_supported_wp_version" value="4.7" />
55

6-
<config name="testVersion" value="5.3-" />
6+
<config name="testVersion" value="5.6-" />
77

88
<file>.</file>
99

src/Extension.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Pronamic\WordPress\Pay\Extensions\WPeCommerce;
1212

13-
use Pronamic\WordPress\Pay\Core\Statuses;
13+
use Pronamic\WordPress\Pay\Payments\PaymentStatus;
1414
use Pronamic\WordPress\Pay\Extensions\WPeCommerce\Gateways\Gateway;
1515
use Pronamic\WordPress\Pay\Payments\Payment;
1616
use Pronamic\WordPress\Pay\Plugin;
@@ -22,7 +22,7 @@
2222
* Company: Pronamic
2323
*
2424
* @author Remco Tolsma
25-
* @version 2.0.2
25+
* @version 2.0.4
2626
* @since 1.0.0
2727
*/
2828
class Extension {
@@ -187,16 +187,16 @@ public static function status_update( Payment $payment, $can_redirect = false )
187187
$merchant = new Gateway( $payment->get_source_id() );
188188

189189
switch ( $payment->status ) {
190-
case Statuses::CANCELLED:
190+
case PaymentStatus::CANCELLED:
191191
$merchant->set_purchase_processed_by_purchid( WPeCommerce::PURCHASE_STATUS_INCOMPLETE_SALE );
192192

193193
break;
194194

195-
case Statuses::EXPIRED:
196-
case Statuses::FAILURE:
195+
case PaymentStatus::EXPIRED:
196+
case PaymentStatus::FAILURE:
197197
break;
198198

199-
case Statuses::SUCCESS:
199+
case PaymentStatus::SUCCESS:
200200
/*
201201
* Transactions results
202202
*
@@ -210,7 +210,7 @@ public static function status_update( Payment $payment, $can_redirect = false )
210210

211211
break;
212212

213-
case Statuses::OPEN:
213+
case PaymentStatus::OPEN:
214214
default:
215215
break;
216216
}
@@ -232,7 +232,7 @@ public static function redirect_url( $url, Payment $payment ) {
232232
);
233233

234234
switch ( $payment->status ) {
235-
case Statuses::CANCELLED:
235+
case PaymentStatus::CANCELLED:
236236
/*
237237
* Remove 'sessionid' paramater from the transaction URL, so customers
238238
* will get a message 'Sorry your transaction was not accepted.'.
@@ -244,8 +244,8 @@ public static function redirect_url( $url, Payment $payment ) {
244244
$args['return'] = 'cancel';
245245

246246
break;
247-
case Statuses::EXPIRED:
248-
case Statuses::FAILURE:
247+
case PaymentStatus::EXPIRED:
248+
case PaymentStatus::FAILURE:
249249
/*
250250
* Remove 'sessionid' paramater from the transaction URL, so customers
251251
* will get a message 'Sorry your transaction was not accepted.'.
@@ -257,8 +257,8 @@ public static function redirect_url( $url, Payment $payment ) {
257257
$args['return'] = 'error';
258258

259259
break;
260-
case Statuses::SUCCESS:
261-
case Statuses::OPEN:
260+
case PaymentStatus::SUCCESS:
261+
case PaymentStatus::OPEN:
262262
default:
263263
break;
264264
}

src/Gateways/Gateway.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* Company: Pronamic
2727
*
2828
* @author Remco Tolsma
29-
* @version 2.0.2
29+
* @version 2.0.4
3030
* @since 1.0.0
3131
*/
3232
class Gateway extends wpsc_merchant {
@@ -209,7 +209,15 @@ public function submit() {
209209
);
210210

211211
// Start payment.
212-
$payment = Plugin::start_payment( $payment );
212+
$error = null;
213+
214+
try {
215+
// @todo Build payment inside try/catch block.
216+
217+
$payment = Plugin::start_payment( $payment );
218+
} catch ( \Exception $e ) {
219+
$error = $e;
220+
}
213221

214222
// Meta.
215223
if ( isset( $this->purchase_id ) ) {
@@ -220,11 +228,8 @@ public function submit() {
220228
$payment->set_meta( 'wpsc_session_id', $this->cart_data['session_id'] );
221229
}
222230

223-
// Handle errors.
224-
$error = $gateway->get_error();
225-
226-
if ( is_wp_error( $error ) ) {
227-
Plugin::render_errors( $error );
231+
if ( $error instanceof \Exception ) {
232+
Plugin::render_exception( $error );
228233

229234
return;
230235
}

0 commit comments

Comments
 (0)