Skip to content

Commit

Permalink
Resend prompt button
Browse files Browse the repository at this point in the history
  • Loading branch information
maukoese committed Jul 18, 2020
1 parent 2e3942b commit 59c701d
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 102 deletions.
183 changes: 91 additions & 92 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,96 +42,96 @@ function wc_mpesa_process_order($order)
$reference = $order_id;
}

$type = ($idtype == 4) ? 'Pay Bill' : 'Buy Goods and Services';?>
<style>
@keyframes wave {

0%,
60%,
100% {
transform: initial;
}

30% {
transform: translateY(-15px);
}
}

@keyframes blink {
0% {
opacity: .2;
}

20% {
opacity: 1;
}

100% {
opacity: .2;
}
}

.saving span {
animation: blink 1.4s linear infinite;
animation-fill-mode: both;
}

.saving span:nth-child(2) {
animation-delay: .2s;
}

.saving span:nth-child(3) {
animation-delay: .4s;
}
</style>
<section class="woocommerce-order-details">
<input type="hidden" id="current_order" value="<?php echo $order_id; ?>">
<input type="hidden" id="payment_method" value="<?php echo $order->get_payment_method(); ?>">
<p class="saving" id="mpesa_receipt">Confirming receipt, please wait</p>
</section>

<?php if (isset($mpesa['enable_c2b']) && $mpesa['enable_c2b'] == 'yes'): ?>
<section class="woocommerce-order-details" id="missed_stk">
<table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
<thead>
<tr>
<th class="woocommerce-table__product-name product-name">
<?php _e("STK Push didn't work? Pay Manually Via M-PESA");?>
</th>
</tr>
</thead>

<tbody>
<tr class="woocommerce-table__line-item order_item">
<td class="woocommerce-table__product-name product-name">
<ol>
<li>Select <b>Lipa na M-PESA</b>.</li>
<li>Select <b><?php echo $type; ?></b>.</li>
<?php if ($idtype == 4): ?>
<li>Enter <b><?php echo $mpesa['shortcode']; ?></b> as business no.</li>
<li>Enter <b><?php echo $reference; ?></b> as Account no.</li>
<?php else: ?>
<li>Enter <b><?php echo $mpesa['shortcode']; ?></b> as till no.</li>
<?php endif;?>
<li>Enter Amount <b><?php echo round($total); ?></b>.</li>
<li>Enter your M-PESA PIN</li>
<li>Confirm your details and press OK.</li>
<li>Wait for a confirmation message from M-PESA.</li>
</ol>

</td>
</tr>
<tr class="woocommerce-table__line-item order_item">
<td class="woocommerce-table__product-name product-name">
<form action="<?php echo home_url("lipwa/request"); ?>" mhod="POST" id="renitiate-form">
<input type="hidden" name="order" value="<?php echo $order_id; ?>">
<button id="renitiate-button" class="button alt" type="submit">Resend STK Push</button>
</form>
</td>
</tr>
</tbody>
</table>
</section>
$type = ($idtype == 4) ? 'Pay Bill' : 'Buy Goods and Services'; ?>
<style>
@keyframes wave {

0%,
60%,
100% {
transform: initial;
}

30% {
transform: translateY(-15px);
}
}

@keyframes blink {
0% {
opacity: .2;
}

20% {
opacity: 1;
}

100% {
opacity: .2;
}
}

.saving span {
animation: blink 1.4s linear infinite;
animation-fill-mode: both;
}

.saving span:nth-child(2) {
animation-delay: .2s;
}

.saving span:nth-child(3) {
animation-delay: .4s;
}
</style>
<section class="woocommerce-order-details">
<input type="hidden" id="current_order" value="<?php echo $order_id; ?>">
<input type="hidden" id="payment_method" value="<?php echo $order->get_payment_method(); ?>">
<p class="saving" id="mpesa_receipt">Confirming receipt, please wait</p>
</section>

<?php if (isset($mpesa['enable_c2b']) && $mpesa['enable_c2b'] == 'yes') : ?>
<section class="woocommerce-order-details" id="missed_stk">
<table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
<thead>
<tr>
<th class="woocommerce-table__product-name product-name">
<?php _e("STK Push didn't work? Pay Manually Via M-PESA"); ?>
</th>
</tr>
</thead>

<tbody>
<tr class="woocommerce-table__line-item order_item">
<td class="woocommerce-table__product-name product-name">
<ol>
<li>Select <b>Lipa na M-PESA</b>.</li>
<li>Select <b><?php echo $type; ?></b>.</li>
<?php if ($idtype == 4) : ?>
<li>Enter <b><?php echo $mpesa['shortcode']; ?></b> as business no.</li>
<li>Enter <b><?php echo $reference; ?></b> as Account no.</li>
<?php else : ?>
<li>Enter <b><?php echo $mpesa['shortcode']; ?></b> as till no.</li>
<?php endif; ?>
<li>Enter Amount <b><?php echo round($total); ?></b>.</li>
<li>Enter your M-PESA PIN</li>
<li>Confirm your details and press OK.</li>
<li>Wait for a confirmation message from M-PESA.</li>
</ol>

</td>
</tr>
<tr class="woocommerce-table__line-item order_item">
<td class="woocommerce-table__product-name product-name">
<form action="<?php echo home_url("lipwa/request"); ?>" mhod="POST" id="renitiate-form">
<input type="hidden" name="order" value="<?php echo $order_id; ?>">
<button id="renitiate-button" class="button alt" type="submit"><?php echo $mpesa['resend'] ?? 'Resend STK Push'; ?></button>
</form>
</td>
</tr>
</tbody>
</table>
</section>
<?php endif;

echo <<<JS
Expand Down Expand Up @@ -386,7 +386,6 @@ function wc_mpesa_process_ipn()
$balance = $response['Body']['stkCallback']['CallbackMetadata']['Item'][2]['Value'];
$transactionDate = $response['Body']['stkCallback']['CallbackMetadata']['Item'][3]['Value'];
$phone = $response['Body']['stkCallback']['CallbackMetadata']['Item'][4]['Value'];

$after_ipn_paid = round($before_ipn_paid) + round($amount);
$ipn_balance = $after_ipn_paid - $amount_due;

Expand Down Expand Up @@ -417,7 +416,7 @@ function wc_mpesa_process_ipn()
update_post_meta($post, '_order_id', $order_id);
update_post_meta($post, '_receipt', $mpesaReceiptNumber);
} else {
$order->update_status('cancelled');
$order->update_status('on-hold');
$order->add_order_note(__("MPesa Error {$resultCode}: {$resultDesc}"));
}

Expand Down
9 changes: 8 additions & 1 deletion inc/wc_mpesa_gateway.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* @package MPesa For WooCommerce
* @package MPesa For WooCommerce
* @subpackage WooCommerce Functions
* @author Osen Concepts < [email protected] >
* @since 0.18.01
Expand Down Expand Up @@ -169,6 +169,13 @@ public function init_form_fields()
'default' => __('bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919', 'woocommerce'),
'desc_tip' => true,
),
'resend' => array(
'title' => __('Resend STK Button Text', 'woocommerce'),
'type' => 'text',
'description' => __('Text description for resend STK prompt button', 'woocommerce'),
'default' => __('Resend STK Push', 'woocommerce'),
'desc_tip' => true,
),
'description' => array(
'title' => __('Method Description', 'woocommerce'),
'type' => 'textarea',
Expand Down
6 changes: 3 additions & 3 deletions osen-wc-mpesa.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
/**
* @package Mpesa For WooCommerce
* @author Osen Concepts < [email protected] >
* @version 1.20.77
* @version 1.20.78
*
* Plugin Name: MPesa For WooCommerce
* Plugin URI: https://wc-mpesa.osen.co.ke/
* Description: This plugin extends WordPress and WooCommerce functionality to integrate <cite>Mpesa</cite> for making and receiving online payments.
* Author: Osen Concepts Kenya < [email protected] >
* Version: 1.20.77
* Version: 1.20.78
* Author URI: https://osen.co.ke/
*
* Requires at least: 4.6
Expand Down Expand Up @@ -42,7 +42,7 @@
exit;
}

define('WCM_VER', '1.20.5');
define('WCM_VER', '1.20.7');
if (!defined('WCM_PLUGIN_FILE')) {
define('WCM_PLUGIN_FILE', __FILE__);
}
Expand Down
12 changes: 6 additions & 6 deletions updates.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Mpesa for Woocommerce",
"version": "1.20.77",
"download_url": "https://github.com/osenco/osen-wc-mpesa/archive/v1.20.77.zip",
"version": "1.20.78",
"download_url": "https://github.com/osenco/osen-wc-mpesa/archive/v1.20.78.zip",

"homepage": "https://wc-mpesa.osen.co.ke/",
"requires": "4.5",
"tested": "5.4",
"last_updated": "2020-07-17 12:00:00",
"last_updated": "2020-07-18 12:00: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>Removed .ke counties - now natively supported by WooCommerce</li><li>Added resend STK Push button on thank you page.</li><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>",
"changelog": "<ul><li>Customizable resend button text</li><li>Fixed cancelled orders incase STK times out to allow for offline/delayed payments</li><li>Removed .ke counties - now natively supported by WooCommerce</li><li>Added resend STK Push button on thank you page.</li><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 All @@ -32,6 +32,6 @@
"rating": 90,
"num_ratings": 1070,

"downloaded": 929,
"active_installs": 845
"downloaded": 1009,
"active_installs": 1005
}

0 comments on commit 59c701d

Please sign in to comment.