Jump to content

custom payment module won't create invoice


Recommended Posts

I'm using the Bitpay Prestashop payment module and testing it- right now, it's missing something that orderReturn.php is expecting to create an invoice, and I can't tell what.


I looked at the field requirements in OrderReturn.php and noted that id_customer is required, and the Bitpay module seems not to provide it; you can see the code here:




I attempted to add this field in as follows from some notes I found on stackOverflow from someone who'd needed id_customer for a different reason- following is my edited hookInvoice function:

function hookInvoice($params)
   global $smarty;
   global $cookie;

   $id_order = $params['id_order'];

   $cookie = new Cookie('ps');

   $id_cust = $cookie->id_customer;

   $bitcoinpaymentdetails = $this->readBitcoinpaymentdetails($id_order);

      'invoice_id' => $bitcoinpaymentdetails['invoice_id'],
      'status' => $bitcoinpaymentdetails['status'],
      'id_order' => $id_order,
      'id_customer' => $id_cust,
      'this_page' => $_SERVER['REQUEST_URI'],
      'this_path' => $this->_path,
      'this_path_ssl' => Configuration::get('PS_FO_PROTOCOL').$_SERVER['HTTP_HOST'].__PS_BASE_URI__."modules/{$this->name}/"

I'm pretty sure I've done this right, but the module is still not creating invoices.


Can anyone either point out where I've made a mistake, or tell me what is missing from this that OrderReturn.php is expecting to recieve?

Link to comment
Share on other sites

what version of Prestashop are you using?


What is OrderReturn.php?  The github does not have a file with this name.


You are also not being clear, is an order being created in prestashop?  Is the invoice from Prestashop getting created?  Or are you referring to an invoice from bitpay?

Link to comment
Share on other sites

Apologies- wrote this in a rush yesterday.


Prestashop version of my client is


OrderReturn.php in that version is located in [web_root]/classes/ - here is the code that recieves the array from the payment module-

	/** @var string Object last modification date */
	public 		$date_upd;

	protected $tables = array ('order_return');

	protected	$fieldsRequired = array ('id_customer', 'id_order');
	protected	$fieldsValidate = array('id_customer' => 'isUnsignedId', 'id_order' => 'isUnsignedId', 'question' => 'isMessage');

	protected 	$table = 'order_return';
	protected 	$identifier = 'id_order_return';
	public function getFields()

		$fields['id_customer'] = pSQL($this->id_customer);
		$fields['id_order'] = pSQL($this->id_order);
		$fields['state'] = pSQL($this->state);
		$fields['date_add'] = pSQL($this->date_add);
		$fields['date_upd'] = pSQL($this->date_upd);
		$fields['question'] = pSQL(nl2br2($this->question), true);
		return $fields;

An order is not being created in Prestashop- that's the issue. Bitpay invoice is paid and processed successfully, but on handoff back to Prestashop, an invoice is not created.


The way I'm reading the above code, what I needed to do was include id_customer in the array, since the bitpay code currently on github doesn't do that. Having implemented that change, a Prestashop invoice still is not created- so either I have made a mistake with the code in my first post, or there is another requirement for invoice creation that I don't know about- I have not been able to locate any relevant documentation, which is why I'm asking for help here.

Link to comment
Share on other sites

  • 3 weeks later...

Invoice will be created automatically after an order is considered as validated, or order status = "Payment accepted" which configured by default to "Allow a customer to download and view PDF versions of their invoice"

Therefore you should check the "Order status" which assigned to your payment module.


Back Office > Order > Statuses

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...