Я использую API армянского банка с woocommerce в качестве дополнительного способа оплаты.Когда я размещаю заказ, это дает мне ошибку во время выполнения.Я прилагаю изображение или полученную ошибку и код, который я использую.
id = 'ameriabank'; // payment gateway plugin ID
$this->icon = ''; // URL of the icon that will be displayed on checkout page near your gateway name
$this->has_fields = true; // in case you need a custom credit card form
$this->method_title = 'Ameria Bank Gateway';
$this->method_description = 'Description of Ameria payment gateway';
$this->supports = array(
'products',
'subscriptions'
);
// Method with all the options fields
$this->init_form_fields();
// Load the settings.
$this->init_settings();
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->enabled = $this->get_option( 'enabled' );
//$this->testmode = 'yes' === $this->get_option( 'testmode' );
$this->ClientID = $this->get_option( 'ClientID' );
$this->Username = $this->get_option( 'Username' );
$this->Password = $this->get_option( 'Password' );
// This action hook saves the settings
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
// We need custom JavaScript to obtain a token
//add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
// You can also register a webhook here
// add_action( 'woocommerce_api_{webhook name}', array( $this, 'webhook' ) );
}
/**
* Plugin options, we deal with it in Step 3 too
*/
public function init_form_fields(){
$this->form_fields = array(
'enabled' => array(
'title' => 'Enable/Disable',
'label' => 'Enable AmeriaBank Gateway',
'type' => 'checkbox',
'description' => '',
'default' => 'no'
),
'title' => array(
'title' => 'Title',
'type' => 'text',
'description' => 'This controls the title which the user sees during checkout.',
'default' => 'Credit Card',
'desc_tip' => true,
),
'description' => array(
'title' => 'Description',
'type' => 'textarea',
'description' => 'This controls the description which the user sees during checkout.',
'default' => 'Pay with your credit card via our super-cool payment gateway.',
),
'ClientID' => array(
'title' => 'Client ID',
'type' => 'text'
),
'Username' => array(
'title' => 'Username',
'type' => 'text'
),
'Password' => array(
'title' => 'Password',
'type' => 'text'
)
);
}
public function process_payment( $order_id ) {
global $woocommerce;
$order = new WC_Order( $order_id );
// Ameria bank params
$this->description = "[description]";
$this->orderID = $order_id;
$this->paymentAmount = $order->get_total();
$_SESSION['eli_cart_total'] = $this->paymentAmount;
$this->backURL = add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks'))));
$options = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'wdsl_local_copy' => true
);
$client = new SoapClient("https://testpayments.ameriabank.am/webservice/PaymentService.svc?wsdl", $options);
$args['paymentfields'] = array(
'ClientID' => $this->ClientID,
'Username' => $this->Username,
'Password' => $this->Password,
'Description' => $this->description,
'OrderID' => $this->orderID,
'PaymentAmount' => $this->paymentAmount,
'backURL' => $this->backURL
);
$webService = $client->GetPaymentID($args);
$_SESSION['pid'] = $webService->GetPaymentIDResult->PaymentID;
$this->liveurl = 'https://testpayments.ameriabank.am/forms/frm_paymentstype.aspx?clientid='.$this->ClientID.'&clienturl='.$this->backURL.'&lang=am&paymentid='.$webService->GetPaymentIDResult->PaymentID;
// Return thankyou redirect
return array(
'result' => 'success',
'redirect' => $this->liveurl
);
}
/**
* Output for the order received page.
*
* @access public
* @return void
*/
function thankyou_page($order_id) {
global $woocommerce;
$options = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'wdsl_local_copy' => true
);
$client = new SoapClient("https://testpayments.ameriabank.am/webservice/PaymentService.svc?wsdl", $options);
$total = $_SESSION['eli_cart_total'];
$args['paymentfields'] = array(
'ClientID' => $this->ClientID,
'Username' => $this->Username,
'Password' => $this->Password,
'PaymentAmount' => $total,
'OrderID' => $order_id
);
$webService = $client->GetPaymentFields($args);
if($webService->GetPaymentFieldsResult->respcode == "00") {
$order = new WC_Order( $order_id );
$type = $webService->GetPaymentFieldsResult->paymenttype;
if( $type == "1" ) {
$client->Confirmation($args);
}
$order->update_status('on-hold', __( 'Awaiting credit card payment', 'woocommerce' ));
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
$woocommerce->cart->empty_cart();
} else {
//echo '';
}
}
}
}
Снимок экрана ошибки:
Дайте мне знать, если кто-то может помочь мне в этом.