Skip to content

Commit fbd5ebf

Browse files
committed
V3.0.0 release
1 parent b42ef51 commit fbd5ebf

File tree

6 files changed

+83
-64
lines changed

6 files changed

+83
-64
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## [3.0.0] - 2020-07-13
4+
### Added
5+
- Support for refund processing with status 81
6+
- Support for capture in progress status
7+
8+
### Changed
9+
- Billing address name is not sent to Ingenico as the Cardholder name
10+
11+
### Fixed
12+
- Issue with payment return error status
13+
- Issue with e-mail template giving an error
14+
- Refund amount rounding
15+
16+
317
## [2.1.0] - 2020-07-06
418
### Added
519
- Country support for Austria

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ingenico/ogone-client-viveum",
33
"description": "Ingenico ePayments Core Library",
4-
"version": "2.1.0",
4+
"version": "3.0.0",
55
"license": [
66
"OSL-3.0"
77
],
@@ -20,7 +20,7 @@
2020
"ext-curl": "*",
2121
"ext-mbstring": "*",
2222
"ext-bcmath": "*",
23-
"ingenico/ogone-sdk-php-viveum": ">=2.0.0",
23+
"ingenico/ogone-sdk-php-viveum": "^2.0.0",
2424
"monolog/monolog": "*",
2525
"league/iso3166": "~2.1",
2626
"graylog2/gelf-php": "~1.5",

onboarding/emails.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ ES[] = "[email protected]"
99
1010
1111
12-
12+

src/Checkout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ protected function assignOrder(AbstractPaymentRequest $request, Order $order, $p
331331
->setOwnerZip($order->getBillingPostcode())
332332
->setOwnertelno($order->getBillingPhone())
333333
->setCivility($order->getCustomerCivility())
334-
->setCn($order->getBillingFullName())
334+
//->setCn($order->getBillingFullName())
335335
->setEmail($order->getBillingEmail())
336336
->setCuid($order->getBillingEmail())
337337
->setEcomShiptoDob($order->getCustomerDob())

src/IngenicoCoreLibrary.php

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class IngenicoCoreLibrary implements IngenicoCoreLibraryInterface, SessionInterf
1919
const STATUS_PENDING = 'pending';
2020
const STATUS_AUTHORIZED = 'authorized';
2121
const STATUS_CAPTURED = 'captured';
22+
const STATUS_CAPTURE_PROCESSING = 'capture_processing';
2223
const STATUS_CANCELLED = 'cancelled';
24+
const STATUS_REFUND_PROCESSING = 'refund_processing';
2325
const STATUS_REFUNDED = 'refunded';
2426
const STATUS_ERROR = 'error';
2527
const STATUS_UNKNOWN = 'unknown';
@@ -1710,7 +1712,8 @@ public function webhookListener()
17101712
throw new Exception('WebHook: Validation failed');
17111713
}
17121714

1713-
if ($_POST['NCERROR'] !== '0') {
1715+
// if ($_POST['NCERROR'] !== '0') { // replaced by Konstantin on 06.07 as Ingenico now returns empty NCERROR if no errors found
1716+
if (!empty($_POST['NCERROR'])) {
17141717
$details = isset($_POST['NCERRORPLUS']) ? $_POST['NCERRORPLUS'] : '';
17151718
throw new Exception(sprintf('NCERROR: %s. NCERRORPLUS: %s', $_POST['NCERROR'], $details));
17161719
}
@@ -2084,27 +2087,31 @@ public static function getStatusByCode($statusCode)
20842087
// 59 - Authorization to be requested manually
20852088
return self::STATUS_AUTHORIZED;
20862089
case 8:
2087-
case 81:
2088-
case 82:
20892090
case 84:
20902091
case 85:
20912092
case 7:
20922093
// 7 - Payment deleted
20932094
// 8 - Refund
2094-
// 81 - Refund pending
2095-
// 82 - Refund uncertain
20962095
// 84 - Refund
20972096
// 85 - Refund handled by merchant
20982097
return self::STATUS_REFUNDED;
2098+
case 81:
2099+
// 81 - Refund pending
2100+
return self::STATUS_REFUND_PROCESSING;
2101+
case 82:
2102+
// 82 - Refund uncertain
2103+
return self::STATUS_ERROR;
20992104
case 9:
2100-
case 91:
2101-
case 92:
21022105
case 95:
21032106
// 9 - Payment requested
2104-
// 91 - Payment processing
2105-
// 92 - Payment uncertain
21062107
// 95 - Payment handled by merchant (Direct Debit uses this)
21072108
return self::STATUS_CAPTURED;
2109+
case 91:
2110+
// 91 - Capture processing
2111+
return self::STATUS_CAPTURE_PROCESSING;
2112+
case 92:
2113+
// 92 - Payment uncertain
2114+
return self::STATUS_ERROR;
21082115
case 41:
21092116
// Bank transfer only, both modes: SUCCESS
21102117
return self::STATUS_CAPTURED;
@@ -2196,63 +2203,29 @@ public function finaliseOrderPayment($orderId, Payment &$paymentResult)
21962203
// Process order
21972204
switch ($paymentStatus) {
21982205
case self::STATUS_AUTHORIZED:
2199-
// Update order status on Connector
2200-
$this->extension->updateOrderStatus(
2201-
$orderId,
2202-
$paymentStatus,
2203-
$this->__('checkout.payment_info', [
2204-
'%status%' => $paymentStatus,
2205-
'%status_code%' => $paymentResult->getStatus(),
2206-
'%payment_id%' => $paymentResult->getPayId(),
2207-
], 'messages')
2208-
);
2209-
2206+
$this->updateOrderStatus($orderId, $paymentResult);
22102207
if ($this->configuration->getDirectSaleEmailOption()) {
22112208
// Send notifications
22122209
$this->extension->sendNotificationAuthorization($orderId);
22132210
$this->extension->sendNotificationAdminAuthorization($orderId);
22142211
}
22152212
break;
2213+
case self::STATUS_CAPTURE_PROCESSING:
2214+
$this->updateOrderStatus($orderId, $paymentResult);
2215+
break;
22162216
case self::STATUS_CAPTURED:
2217-
// Update order status on Connector
2218-
$this->extension->updateOrderStatus(
2219-
$orderId,
2220-
$paymentStatus,
2221-
$this->__('checkout.payment_info', [
2222-
'%status%' => $paymentStatus,
2223-
'%status_code%' => $paymentResult->getStatus(),
2224-
'%payment_id%' => $paymentResult->getPayId(),
2225-
], 'messages')
2226-
);
2227-
2217+
$this->updateOrderStatus($orderId, $paymentResult);
22282218
$this->extension->addCapturedAmount($orderId, $paymentResult->getAmount());
22292219
break;
2220+
case self::STATUS_REFUND_PROCESSING:
2221+
$this->updateOrderStatus($orderId, $paymentResult);
2222+
break;
22302223
case self::STATUS_REFUNDED:
2231-
// Update order status on Connector
2232-
$this->extension->updateOrderStatus(
2233-
$orderId,
2234-
$paymentStatus,
2235-
$this->__('checkout.payment_info', [
2236-
'%status%' => $paymentStatus,
2237-
'%status_code%' => $paymentResult->getStatus(),
2238-
'%payment_id%' => $paymentResult->getPayId(),
2239-
], 'messages')
2240-
);
2241-
2224+
$this->updateOrderStatus($orderId, $paymentResult);
22422225
$this->extension->addRefundedAmount($orderId, $paymentResult->getAmount());
22432226
break;
22442227
case self::STATUS_CANCELLED:
2245-
// Update order status on Connector
2246-
$this->extension->updateOrderStatus(
2247-
$orderId,
2248-
$paymentStatus,
2249-
$this->__('checkout.payment_info', [
2250-
'%status%' => $paymentStatus,
2251-
'%status_code%' => $paymentResult->getStatus(),
2252-
'%payment_id%' => $paymentResult->getPayId(),
2253-
], 'messages')
2254-
);
2255-
2228+
$this->updateOrderStatus($orderId, $paymentResult);
22562229
$this->extension->addCancelledAmount($orderId, $paymentResult->getAmount());
22572230
break;
22582231
case self::STATUS_ERROR:
@@ -2265,9 +2238,6 @@ public function finaliseOrderPayment($orderId, Payment &$paymentResult)
22652238

22662239
$paymentResult->setMessage($message);
22672240
$this->logger->debug(__CLASS__ . '::' . __METHOD__ . ' Error: ' . $message, $paymentResult->toArray());
2268-
2269-
// Update order status on Connector
2270-
$this->extension->updateOrderStatus($orderId, $paymentStatus, $message);
22712241
break;
22722242
case self::STATUS_UNKNOWN:
22732243
$this->logger->debug(__CLASS__ . '::' . __METHOD__ . ' Unknown status', $paymentResult->toArray());
@@ -2276,6 +2246,30 @@ public function finaliseOrderPayment($orderId, Payment &$paymentResult)
22762246

22772247
return $paymentStatus;
22782248
}
2249+
2250+
/**
2251+
* Update order status
2252+
*
2253+
* @param $type
2254+
* @param $orderId
2255+
* @param $paymentResult
2256+
*
2257+
* @return null
2258+
*/
2259+
public function updateOrderStatus($orderId, $paymentResult)
2260+
{
2261+
$this->extension->updateOrderStatus(
2262+
$orderId,
2263+
$paymentResult,
2264+
$this->__('checkout.payment_info', [
2265+
'%status%' => $paymentResult->getPaymentStatus(),
2266+
'%status_code%' => $paymentResult->getStatus(),
2267+
'%payment_id%' => $paymentResult->getPayId(),
2268+
], 'messages')
2269+
);
2270+
2271+
return null;
2272+
}
22792273

22802274
/**
22812275
* Check void availability
@@ -2293,7 +2287,8 @@ public function canVoid($orderId, $payId, $cancelAmount = null)
22932287
if (!$cancelAmount) {
22942288
$cancelAmount = $order->getAmount();
22952289
}
2296-
2290+
2291+
$cancelAmount = (float) bcdiv($cancelAmount, 1, 2);
22972292
if ($cancelAmount > $order->getAvailableAmountForCancel()) {
22982293
return false;
22992294
}
@@ -2318,7 +2313,8 @@ public function canCapture($orderId, $payId, $captureAmount = null)
23182313
if (!$captureAmount) {
23192314
$captureAmount = $order->getAmount();
23202315
}
2321-
2316+
2317+
$captureAmount = (float) bcdiv($captureAmount, 1, 2);
23222318
if ($captureAmount > $order->getAvailableAmountForCapture()) {
23232319
return false;
23242320
}
@@ -2344,12 +2340,21 @@ public function canRefund($orderId, $payId, $refundAmount = null)
23442340
$refundAmount = $order->getAmount();
23452341
}
23462342

2343+
$this->logger->debug(__CLASS__ . '::' . __METHOD__ . ' $refundAmount before = '. $refundAmount);
2344+
$refundAmount = (float)bcdiv($refundAmount, 1, 2);
2345+
$this->logger->debug(__CLASS__ . '::' . __METHOD__ . ' $refundAmount after = '. $refundAmount);
2346+
$this->logger->debug(__CLASS__ . '::' . __METHOD__ . ' $order->getAvailableAmountForRefund() = '. $order->getAvailableAmountForRefund());
2347+
23472348
if ($refundAmount > $order->getAvailableAmountForRefund()) {
2349+
$this->logger->debug(__CLASS__ . '::' . __METHOD__ . ' false ');
23482350
return false;
23492351
}
23502352

23512353
$statusCode = $this->getPaymentInfo($orderId, $payId)->getStatus();
2352-
return self::STATUS_CAPTURED === $this->getStatusByCode($statusCode);
2354+
$this->logger->debug(__CLASS__ . '::' . __METHOD__ . ' $statusCode = '.$statusCode);
2355+
$this->logger->debug(__CLASS__ . '::' . __METHOD__ . ' $this->getStatusByCode($statusCode) = '.$this->getStatusByCode($statusCode));
2356+
//return self::STATUS_CAPTURED === $this->getStatusByCode($statusCode);
2357+
return true;
23532358
}
23542359

23552360
/**

templates/refund_failed/html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
?>
99
<?php echo $view->__('refund_failed.dear', ['%name%' => '<span style="color: #306ba8">' . $customer_name . '</span>'], 'email'); ?>,
1010
<br/><br />
11-
<?php echo $view->__('refund_failed.text1', ['%order_id%' => '<a href="' . $order_link . '" style="text-decoration: none; color: #306ba8">' . $order_reference . '</a>'], 'email'); ?>
11+
<?php echo $view->__('refund_failed.text1', ['%order_id%' => '<a href="' . $order_url . '" style="text-decoration: none; color: #306ba8">' . $order_reference . '</a>'], 'email'); ?>
1212
<br /><br />
1313
<?php echo $view->__('refund_failed.text2', [], 'email'); ?>
1414
<br /><br />

0 commit comments

Comments
 (0)