Skip to content

Commit

Permalink
feat: add zip script
Browse files Browse the repository at this point in the history
  • Loading branch information
epoundor committed Mar 5, 2024
1 parent f2855ed commit 5518701
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ vendor/
.idea/
.DS_Store
._.DS_Store
node_modules
node_modules
builds
11 changes: 7 additions & 4 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
PLUGIN_BUILDS_PATH="$PROJECT_ROOT/builds"
PLUGIN_BUILD_CONFIG_PATH="$PROJECT_ROOT/build-cfg"
VERSION=$(awk 'NR==7' readme.txt | cut -d ' ' -f 3)
ZIP_FILE="$PLUGIN_BUILDS_PATH/$PLUGIN-$VERSION.zip"
ZIP_FILE=$PROJECT_ROOT/$PLUGIN\_v$VERSION.zip

mkdir -p $PLUGIN_BUILDS_PATH
zip -r $ZIP_FILE . -x "deploy/*" "build-cfg/*" "builds/*" ".*" "wp-assets/*"
# Ensure the zip file for the current version has been built
if [ ! -f "$ZIP_FILE" ]; then
echo "Built zip file $ZIP_FILE does not exist" 1>&2
exit 1
fi
mkdir -p $PLUGIN_BUILDS_PATH

# Check if the tag exists for the version we are building
TAG=$(svn ls "https://plugins.svn.wordpress.org/$PLUGIN/tags/$VERSION")
Expand All @@ -32,9 +31,13 @@ if [ $error == 0 ]; then
exit 1
fi

cp -R $ZIP_FILE $PLUGIN_BUILDS_PATH

cd "$PLUGIN_BUILDS_PATH"
# Remove any unzipped dir so we start from scratch

rm -fR "$PLUGIN"

# Unzip the built plugin
unzip -q -o "$ZIP_FILE" -d $PLUGIN

Expand Down Expand Up @@ -87,7 +90,7 @@ svn stat svn | grep '^!' | awk '{print $2}' | xargs -I x svn rm --force x@
svn stat svn

# Commit to SVN
svn ci --no-auth-cache --username $SVN_USERNAME --password $SVN_PASSWORD svn -m "Deploy version $VERSION"
svn ci --no-auth-cache --username $WP_ORG_USERNAME --password $SVN_PASSWORD svn -m "Deploy version $VERSION"

# Remove SVN temp dir
rm -fR svn
51 changes: 49 additions & 2 deletions includes/class-wc-kkiapay-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct()
);

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

$this->init_form_fields();

$this->init_settings();
Expand Down Expand Up @@ -176,6 +176,11 @@ public function is_valid_for_use()

public function admin_options()
{
?>
<h4>
<strong><?php printf(__('Optional: To avoid situations where bad network makes it impossible to verify transactions, set your webhook URL <a href="%1$s" target="_blank" rel="noopener noreferrer">here</a> to the URL below<span style="color: red"><pre><code>%2$s</code></pre></span>', 'woo-paystack'), 'https://app.kkiapay.me/dashboard/developers/keys', WC()->api_request_url('Wc_Kkiapay_Gateway_Webhook')); ?></strong>
</h4>
<?php
if (!$this->is_valid_for_use()) {
echo '<div class="inline error"><p><strong>' . __('Kkiapay Payment Gateway Disabled', 'kkiapay-woocommerce') . '</strong>: ' . $this->msg . '</p></div>';
} else {
Expand All @@ -202,7 +207,6 @@ public function process_payment($order_id)
*/
public function receipt_page($order_id)
{

$this->kkiapay_config['callback'] = $this->get_callback_url($order_id);

//TODO: add transaction reason
Expand Down Expand Up @@ -256,6 +260,8 @@ private function setKkiapayConfig(WC_Order $order)
$products = rtrim($products, ' | ');

$this->kkiapay_config['data'] = [
"sdk" => "woocommerce",
"woocommerce_version" => WOOCOMMERCE_VERSION,
"order_id" => $order->get_id(),
"orderer_name" => $order->get_formatted_billing_full_name(),
"orderer_email" => $order->get_billing_email(),
Expand Down Expand Up @@ -360,6 +366,47 @@ function_exists('wc_reduce_stock_levels') ? wc_reduce_stock_levels($order_id) :
*/
function on_kkiapay_webhook()
{

if (!array_key_exists('HTTP_X_KKIAPAY_SECRET', $_SERVER) || (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST')) {
exit;
}
$json = file_get_contents('php://input');
$payload = json_decode($json);

if (!$payload->stateData || !$payload->stateData->order_id || $payload->stateData->sdk !== "woocommerce") {
return;
}
$order_id = $payload->stateData->order_id;
$order = wc_get_order($order_id);
if (!$order) {
return;
}

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


require_once __DIR__ . '/class-kkiapay-gateway.php';

if ($status == STATUS::SUCCESS && $payload->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);
$order->add_meta_data('_transaction_id', $payload->transactionId, true);

$customer_note = __('Thank you for your order.<br>', 'kkiapay-woocommerce');
$customer_note .= __('Your payment was successful, we are now <strong>processing</strong> your order.', 'kkiapay-woocommerce');
$order->add_order_note($customer_note, 1);
function_exists('wc_reduce_stock_levels') ? wc_reduce_stock_levels($order_id) : $order->reduce_order_stock();

wc_add_notice($customer_note, 'notice');
$order->save();

WC()->cart->empty_cart();
} elseif ($status == STATUS::FAILED) {
$this->handlePaymentFailed($order);
}
exit;
}

/**
Expand Down
Binary file modified kkiapay-woocomerce_v2.4.0.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions kkiapay-woocommerce-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
define('WC_KKIAPAY_MAIN_FILE', __FILE__);
define('WC_KKIAPAY_VERSION', '2.3.16');

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 1);
// define('WP_DEBUG', true);
// define('WP_DEBUG_DISPLAY', false);
// @ini_set('display_errors', 1);

// Make sure WooCommerce is active
if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))))
Expand Down

0 comments on commit 5518701

Please sign in to comment.