Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Refund/Request/Response/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public function parse(TransactionResponse $response, array $body, int $orderId)
{
$order = new \Order($orderId);
$this->createRefundRequest($response, $body, $orderId);
$this->statusService->setRefunded($order);

if (!$response->isSuccess()) {
$message = '';
Expand All @@ -72,6 +71,8 @@ public function parse(TransactionResponse $response, array $body, int $orderId)
}
throw new OrderException($message);
}

$this->statusService->setRefunded($order);
$this->createNegativePayment($order, $response);
}

Expand Down
38 changes: 32 additions & 6 deletions views/js/buckaroo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,32 @@ class BuckarooFeeManager {
init() {
this.$cartSubtotalBuckarooFee = $('#cart-subtotal-buckarooFee');
this.$cartSubtotalBuckarooFeeTax = $('#cart-subtotal-buckarooFeeTax');
this.$cartSummarySubtotalsContainer = $('.cart-summary-subtotals-container');
this.$cartSummarySubtotalsContainer = this._findSubtotalsContainer();
}

_findTotalsContainer() {
if ($('.card-block.cart-summary-totals').length) {
return $('.card-block.cart-summary-totals').first();
}
if ($('.card-body.cart-summary-totals').length) {
return $('.card-body.cart-summary-totals').first();
}
return $('.cart-summary-totals').first();
}

_findSubtotalsContainer() {
const $existing = $('.cart-summary-subtotals-container');
if ($existing.length) {
return $existing;
}
const $totalsBlock = this._findTotalsContainer();
if ($totalsBlock.length) {
if (!$('#bk-fee-wrapper').length) {
$totalsBlock.before('<div id="bk-fee-wrapper" class="cart-summary-subtotals-container"></div>');
}
return $('#bk-fee-wrapper');
}
return $();
}

handlePaymentOptionChange($paymentOption) {
Expand Down Expand Up @@ -158,7 +183,7 @@ class BuckarooFeeManager {
}

const { cart_summary_totals, paymentFee, paymentFeeTax, includedTaxes } = response;
const $cartSummaryTotals = $('.card-block.cart-summary-totals');
const $cartSummaryTotals = this._findTotalsContainer();

if (!$cartSummaryTotals.length) {
console.warn('Cart summary totals container not found');
Expand All @@ -174,8 +199,8 @@ class BuckarooFeeManager {
}

// Re-initialize container reference after cart summary replacement
this.$cartSummarySubtotalsContainer = $('.cart-summary-subtotals-container');
this.$cartSummarySubtotalsContainer = this._findSubtotalsContainer();

// Re-initialize fee element references (they should not exist after removePaymentFee)
this.$cartSubtotalBuckarooFee = $('#cart-subtotal-buckarooFee');
this.$cartSubtotalBuckarooFeeTax = $('#cart-subtotal-buckarooFeeTax');
Expand All @@ -195,9 +220,9 @@ class BuckarooFeeManager {
this.$cartSubtotalBuckarooFee = $('#cart-subtotal-buckarooFee');
this.$cartSubtotalBuckarooFeeTax = $('#cart-subtotal-buckarooFeeTax');

// Ensure container reference is up to date
// Ensure container reference is up to date, with PS9 fallback
if (!this.$cartSummarySubtotalsContainer || this.$cartSummarySubtotalsContainer.length === 0) {
this.$cartSummarySubtotalsContainer = $('.cart-summary-subtotals-container');
this.$cartSummarySubtotalsContainer = this._findSubtotalsContainer();
}

const paymentFeeHtml = `<div class="cart-summary-line cart-summary-subtotals" id="cart-subtotal-buckarooFee">
Expand Down Expand Up @@ -249,6 +274,7 @@ class BuckarooFeeManager {
removePaymentFee() {
$('#cart-subtotal-buckarooFee').remove();
$('#cart-subtotal-buckarooFeeTax').remove();
$('#bk-fee-wrapper').remove();
}
}

Expand Down
Loading
Loading