Skip to content

Commit

Permalink
fix(api): remove refund support
Browse files Browse the repository at this point in the history
  • Loading branch information
epoundor committed Mar 9, 2024
1 parent 5518701 commit af8c283
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
16 changes: 8 additions & 8 deletions admin/kkiapay-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
'desc_tip' => true,
'description' => __('When Kkiapay payment form is displayed directly on your site, you can choose the widget color (eg: red) according to your website colors. ', 'kkiapay-woocommerce')
),
'refund' => array(
'title' => __('Refund', 'kkiapay-woocommerce'),
'label' => __('Enable/Disable refund', 'kkiapay-woocommerce'),
'default' => 'false',
'type' => 'checkbox',
'desc_tip' => true,
'description' => __('Kkiapay does not support multiple refunds. This means that a refund for one order will refund the full amount to the customer.', 'kkiapay-woocommerce')
)
// 'refund' => array(
// 'title' => __('Refund', 'kkiapay-woocommerce'),
// 'label' => __('Enable/Disable refund', 'kkiapay-woocommerce'),
// 'default' => 'false',
// 'type' => 'checkbox',
// 'desc_tip' => true,
// 'description' => __('Kkiapay does not support multiple refunds. This means that a refund for one order will refund the full amount to the customer.', 'kkiapay-woocommerce')
// )

);
25 changes: 13 additions & 12 deletions includes/class-wc-kkiapay-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class WC_Kkiapay_Gateway extends WC_Payment_Gateway
*/
public $msg;

/**
* Is refund active?
*
* @var bool
*/
public $refund;
// /**
// * Is refund active?
// *
// * @var bool
// */
// public $refund;

/**
* Protected constructor to prevent creating a new instance of the
Expand All @@ -78,7 +78,7 @@ public function __construct()
'products',
);

if ($this->refund === "yes") $this->supports[] = "refunds";
// if ($this->refund === "yes") $this->supports[] = "refunds";

$this->init_form_fields();

Expand Down Expand Up @@ -373,6 +373,7 @@ function on_kkiapay_webhook()
$json = file_get_contents('php://input');
$payload = json_decode($json);


if (!$payload->stateData || !$payload->stateData->order_id || $payload->stateData->sdk !== "woocommerce") {
return;
}
Expand All @@ -382,13 +383,13 @@ function on_kkiapay_webhook()
return;
}

$stateData = $payload->stateData;
$status = strtoupper(explode(".", $payload->event)[1]);


require_once __DIR__ . '/class-kkiapay-gateway.php';
$kkiapay = new KkiapayGateway($this->public_key, $this->private_key, $this->secret, $this->testmode);
$response = $kkiapay->verifyTransaction($payload->transactionId);
$status = $response->status;


if ($status == STATUS::SUCCESS && $payload->amount >= $order->get_total()) {
if ($status == STATUS::SUCCESS && $response->amount >= $order->get_total()) {
$order->update_status('completed');
$order->add_order_note(__('Payment was successful on Kkiapay', 'kkiapay-woocommerce'));
$order->add_order_note('Kkiapay transaction Id: ' . $payload->transactionId);
Expand Down
Binary file modified kkiapay-woocomerce_v2.4.0.zip
Binary file not shown.

0 comments on commit af8c283

Please sign in to comment.