Skip to content

Commit

Permalink
June release
Browse files Browse the repository at this point in the history
  • Loading branch information
maukoese committed Jun 4, 2020
1 parent 182a003 commit 86692c0
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 56 deletions.
2 changes: 1 addition & 1 deletion inc/wc_mpesa_gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function init_form_fields()
'title' => __('Manual Payments', 'woocommerce'),
'label' => __('Enable C2B API(Offline Payments)', 'woocommerce'),
'type' => 'checkbox',
'description' => '<small>' . (($this->get_option('idtype') == 4) ? 'This requires C2B Validation, which is an optional feature that needs to be activated on M-Pesa. <br>Request for activation by sending an email to <a href="mailto:[email protected]">[email protected]</a>, or through a chat on the <a href="https://developer.safaricom.co.ke/">developer portal.</a><br>' : '') . '<a class="button button-secondary" href="' . home_url('wcpesa/register/') . '">Once enabled, click here to register confirmation & validation URLs</a><p>Kindly note that if this is disabled, the user can still resend an STK push if the first one fails.</p></small>',
'description' => '<small>' . (($this->get_option('idtype') == 4) ? 'This requires C2B Validation, which is an optional feature that needs to be activated on M-Pesa. <br>Request for activation by sending an email to <a href="mailto:[email protected]">[email protected]</a>, or through a chat on the <a href="https://developer.safaricom.co.ke/">developer portal.</a><br>' : '') . '<a class="button button-secondary" href="' . home_url('lipwa/register/') . '">Once enabled, click here to register confirmation & validation URLs</a><p>Kindly note that if this is disabled, the user can still resend an STK push if the first one fails.</p></small>',
'default' => 'no',
),
// 'enable_b2c' => array(
Expand Down
82 changes: 43 additions & 39 deletions inc/woocommerce.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @package MPesa For WooCommerce
* @subpackage WooCommerce Functions
Expand All @@ -10,7 +11,7 @@
* Add Kenyan counties to list of woocommerce states
*/
add_filter('woocommerce_states', 'mpesa_ke_woocommerce_counties');
function mpesa_ke_woocommerce_counties($counties)
function mpesa_ke_woocommerce_counties($counties)
{
$counties['KE'] = array(
'BAR' => __('Baringo', 'woocommerce'),
Expand Down Expand Up @@ -66,10 +67,10 @@ function mpesa_ke_woocommerce_counties($counties)
}

//add_filter('manage_edit-shop_order_columns', 'wcmpesa_new_order_column');
function wcmpesa_new_order_column($columns)
function wcmpesa_new_order_column($columns)
{
$columns['mpesa'] = 'Reinitiate Mpesa';
return $columns;
$columns['mpesa'] = 'Reinitiate Mpesa';
return $columns;
}

/**
Expand All @@ -79,46 +80,49 @@ function wcmpesa_new_order_column($columns)
* @param string $column The name of the column being acted upon
* @return void
*/
add_action('manage_shop_order_custom_column','shop_order_payments_table_column_content', 10);
add_action('manage_shop_order_custom_column', 'shop_order_payments_table_column_content', 10);
function shop_order_payments_table_column_content($column_id, $post_id)
{
$order_id = get_post_meta($post_id, '_order_id', true);
switch ($column_id) {
$order_id = get_post_meta($post_id, '_order_id', true);
switch ($column_id) {

case 'mpesa':
$statuses = array(
"processing" => "This Order Is Processing",
"on-hold" => "This Order Is On Hold",
"complete" => "This Order Is Complete",
"cancelled" => "This Order Is Cancelled",
"refunded" => "This Order Is Refunded",
"failed" => "This Order Failed"
);
case 'mpesa':
$statuses = array(
"processing" => "This Order Is Processing",
"on-hold" => "This Order Is On Hold",
"complete" => "This Order Is Complete",
"cancelled" => "This Order Is Cancelled",
"refunded" => "This Order Is Refunded",
"failed" => "This Order Failed"
);

echo ($value = get_post_meta($post_id, '_order_status', true)) ? '<a href="'.admin_url('post.php?post='.esc_attr(trim($order_id)).'&action=edit">'.esc_attr($statuses[$value]).'</a>') : '<a href="'.admin_url('post.php?post='.esc_attr(trim($order_id)).'&action=edit"').'>Set Status</a>';
break;
}
echo ($value = get_post_meta($post_id, '_order_status', true)) ? '<a href="' . admin_url('post.php?post=' . esc_attr(trim($order_id)) . '&action=edit">' . esc_attr($statuses[$value]) . '</a>') : '<a href="' . admin_url('post.php?post=' . esc_attr(trim($order_id)) . '&action=edit"') . '>Set Status</a>';
break;
}
}

add_filter('woocommerce_email_attachments', 'woocommerce_emails_attach_downloadables', 10, 3);
function woocommerce_emails_attach_downloadables($attachments, $status, $order)
function woocommerce_emails_attach_downloadables($attachments, $status, $order)
{
if (! is_object($order) || ! isset($status)) {
return $attachments;
}
if (empty($order)) {
return $attachments;
}
if (! $order->has_downloadable_item()) {
return $attachments;
}
$allowed_statuses = array('customer_invoice', 'customer_completed_order');
if (isset($status) && in_array($status, $allowed_statuses)) {
foreach ($order->get_items() as $item_id => $item) {
foreach ($order->get_item_downloads($item) as $download) {
$attachments[] = str_replace(content_url(), WP_CONTENT_DIR, $download['file']);
}
}
}
return $attachments;
}
if (!is_object($order) || !isset($status)) {
return $attachments;
}
if (empty($order)) {
return $attachments;
}
if (method_exists($order, 'has_downloadable_item')) {
if (!$order->has_downloadable_item()) {
return $attachments;
}
$allowed_statuses = array('customer_invoice', 'customer_completed_order');
if (isset($status) && in_array($status, $allowed_statuses)) {
foreach ($order->get_items() as $item_id => $item) {
foreach ($order->get_item_downloads($item) as $download) {
$attachments[] = str_replace(content_url(), WP_CONTENT_DIR, $download['file']);
}
}
}
}

return $attachments;
}
24 changes: 12 additions & 12 deletions osen-wc-mpesa.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ function mpesa_row_meta($links, $file)
'shortcode' => isset($c2b['shortcode']) ? $c2b['shortcode'] : '174379',
'type' => isset($c2b['idtype']) ? $c2b['idtype'] : 4,
'passkey' => isset($c2b['passkey']) ? $c2b['passkey'] : 'bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919',
'validate' => home_url('wcpesa/validate/'),
'confirm' => home_url('wcpesa/confirm/'),
'reconcile' => home_url('wcpesa/reconcile/'),
'timeout' => home_url('wcpesa/timeout/')
'validate' => home_url('lipwa/validate/'),
'confirm' => home_url('lipwa/confirm/'),
'reconcile' => home_url('lipwa/reconcile/'),
'timeout' => home_url('lipwa/timeout/')
)
);

Expand All @@ -187,10 +187,10 @@ function mpesa_row_meta($links, $file)
'shortcode' => isset($c2b['shortcode']) ? $c2b['shortcode'] : '174379',
'type' => isset($c2b['idtype']) ? $c2b['idtype'] : 4,
'passkey' => isset($c2b['passkey']) ? $c2b['passkey'] : 'bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919',
'validate' => home_url('wcpesa/validate/'),
'confirm' => home_url('wcpesa/confirm/'),
'reconcile' => home_url('wcpesa/reconcile/'),
'timeout' => home_url('wcpesa/timeout/')
'validate' => home_url('lipwa/validate/'),
'confirm' => home_url('lipwa/confirm/'),
'reconcile' => home_url('lipwa/reconcile/'),
'timeout' => home_url('lipwa/timeout/')
)
);

Expand All @@ -207,10 +207,10 @@ function mpesa_row_meta($links, $file)
// 'passkey' => isset($b2c['passkey']) ? $b2c['passkey'] : '',
// 'username' => isset($b2c['username']) ? $b2c['username'] : '',
// 'password' => isset($b2c['password']) ? $b2c['password'] : '',
// 'validate' => home_url('wcpesa/validate/'),
// 'confirm' => home_url('wcpesa/confirm/'),
// 'reconcile' => home_url('wcpesa/reconcile/'),
// 'timeout' => home_url('wcpesa/timeout/')
// 'validate' => home_url('lipwa/validate/'),
// 'confirm' => home_url('lipwa/confirm/'),
// 'reconcile' => home_url('lipwa/reconcile/'),
// 'timeout' => home_url('lipwa/timeout/')
// )
// );

Expand Down
8 changes: 4 additions & 4 deletions updates.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Mpesa for Woocommerce",
"version": "1.20.57",
"download_url": "https://github.com/osenco/osen-wc-mpesa/archive/v1.20.57.zip",
"version": "1.20.6",
"download_url": "https://github.com/osenco/osen-wc-mpesa/archive/v1.20.6.zip",

"homepage": "https://wc-mpesa.osen.co.ke/",
"requires": "4.5",
"tested": "5.4",
"last_updated": "2020-05-27 14:17:00",
"last_updated": "2020-06-03 14:17:00",
"upgrade_notice": "Autoupdates from here on",

"author": "Osen Concepts",
Expand All @@ -15,7 +15,7 @@
"sections": {
"description": "<p>This plugin seeks to provide a simple plug-n-play implementation for integrating M-Pesa Payments into online stores built with WooCommerce and WordPress.</p>",
"installation": "Download the latest release from Github, and extract the zip file in your plugins directory of your WordPress instalation",
"changelog": "<ul><li>Auto updates enabled</li><li>Reorder account number and paybill in C2B instructions</li><li>Mark order as cancelled if STK push times out or is cancelled</li></ul>",
"changelog": "<ul><li>Changed paths from /wcpesa to /lipwa to avoid blacklisted names</li><li>Auto updates enabled</li><li>Reorder account number and paybill in C2B instructions</li><li>Mark order as cancelled if STK push times out or is cancelled</li></ul>",
"going_live": "<p>While we have made all efforts to ensure this plugin works out of the box - with minimum configuration required - the service provider requires that the user go through a certain ardous process to migrate from sandbox(test) environment to production.</p><p>We have made a <a href='https://wc-mpesa.osen.co.ke/going-live'>tutorial here</a> to walk you through the process. We however have a team ready on call to assist you in this are, at a fiat fee of KSh 4000 one-off, should you find it difficult.</p>"
},

Expand Down

0 comments on commit 86692c0

Please sign in to comment.