And this is my code
class MS_Gateway_Mtc
{
const ID = 'mtc';
/**
* Gateway singleton instance.
*
* @since 1.0.0
* @var string $instance
*/
public static $instance;
/**
* Payment information for customer.
*
* The payment procedures like bank account, agency, etc.
*
* @since 1.0.0
* @var string $payment_info
*/
protected $payment_info;
/**
* Hook to show payment info.
* This is called by the MS_Factory
*
* @since 1.0.0
*/
public function after_load()
{
parent::after_load();
$this->id = self::ID;
$this->name = __('Maroc Telecommerce - Paiement sécurisé par Carte', 'membership2');
$this->description = __('(Bank orders, cash, etc)', 'membership2');
$this->group = __('Maroc Telecommerce Payment', 'membership2');
$this->manual_payment = true; // Recurring billed/paid manually
$this->pro_rate = true;
/**
* No sandbox option for mtc payment gateway
* The mode is always set to live
*/
$this->mode = 'live';
if ($this->active) {
$this->add_action(
'ms_controller_gateway_purchase_info_content',
'purchase_info_content'
);
}
}
/**
* Show mtc purchase/payment information.
*
* Returns a default messsage if gateway is not configured.
*
* @hook ms_controller_gateway_purchase_info_content
*
* @since 1.0.0
* @return string The payment info.
*/
public function purchase_info_content()
{
static $Processed = false;
/**
* If some plugin calls <code>the_content()</code> multiple times then this
* function will also run multiple times.
* We want to process the details only once, so we have this condition!
*/
if (!$Processed) {
$Processed = true;
do_action(
'ms_gateway_manual_purchase_info_content_before',
$this
);
if (empty($this->payment_info)) {
$link = MS_Controller_Plugin::get_admin_url('settings');
ob_start();
?>
<?php _e('This is only an example of mtc payment gateway instructions', 'membership2'); ?>
<br/>
<?php
printf(
__('Edit it %shere%s', 'membership2'),
'<a href="' . $link . '">',
'</a>'
);
?>
<br/><br/>
<?php _e('Name: Example name.', 'membership2'); ?>
<br/>
<?php _e('Bank: Example bank.', 'membership2'); ?>
<br/>
<?php _e('Bank account: Example bank account 1234.', 'membership2'); ?>
<br/>
<?php
$this->payment_info = ob_get_clean();
}
$this->payment_info = wpautop($this->payment_info);
if (!empty($_POST['ms_relationship_id'])) {
$subscription = MS_Factory::load(
'MS_Model_Relationship',
$_POST['ms_relationship_id']
);
$invoice = $subscription->get_current_invoice();
$this->payment_info .= sprintf(
'<div class="ms-mtc-price">%s: <span class="ms-price">%s%s</span></div>',
__('Total value', 'membership2'),
$invoice->currency,
$invoice->total
);
// The user did make his intention to pay the invoice. Set status
// to billed.
$invoice->status = MS_Model_Invoice::STATUS_BILLED;
$invoice->save();
}
}
return apply_filters(
'ms_gateway_manual_purchase_info_content',
$this->payment_info
);
}
/**
* Verify required fields.
*
* @since 1.0.0
* @return boolean True if configured.
*/
public function is_configured()
{
$is_configured = true;
$required = array('payment_info');
foreach ($required as $field) {
if (empty($this->$field)) {
$is_configured = false;
break;
}
}
return apply_filters(
'ms_gateway_manual_is_configured',
$is_configured
);
}
/**
* Validate specific property before set.
*
* @since 1.0.0
*
* @access public
* @param string $property The name of a property to associate.
* @param mixed $value The value of a property.
*/
public function __set($property, $value)
{
if (property_exists($this, $property)) {
switch ($property) {
case 'payment_info':
$this->$property = wp_kses_post($value);
break;
default:
parent::__set($property, $value);
break;
}
}
do_action(
'ms_gateway_manual__set_after',
$property,
$value,
$this
);
}
}
function mtc_register($api)
{
$api->register_payment_gateway(MS_Gateway_Mtc::ID, 'MS_Gateway_Mtc');
}
add_action('ms_init', 'mtc_register');
Hello fadinho,
Let me ping our developer on that – I’m not coding expert so I have to consult your code. Our developer is not online at the moment, but as soon I’ll get more info from him I’ll update your thread.
kind regards,
Kasia
thank you for your reactivity,
I am waiting your reponse.
For more explanation :
I try to add a new gateway and I use API membership 2 to create a plugin like documentation.
(MS_Gateway_Mtc)
THanks (^_^)
Hi kasia
Is there a solution to this problem ?
thanks
Hi kasia
Is there a solution to this problem ?
thanks
Hi kasia
Is there a solution to this problem ?
thanks 🙂