Jump to content

Storing additional information/variables in an order


Recommended Posts

I am on PrestaShop 1.6.1.9.

 

I am developing a payment module to integrate to a 3rd party payment gateway. In /controllers/front/validation.php I am authorizing the payment with the payment gateway - similar to card authorization.

 

As per the rules of the payment gateway, I can only actually invoice the customer via the payment gateway when the goods are shipped/delivered. Therefore I have registered to the hook 'actionOrderStatusPostUpdate'. The action listener triggers as expected but I am now facing the following issue:

 

The first API call made before the order creation - i.e. the authorization call - returns the customer's account number (for the payment gateway) and I must use this account number later on when actionOrderStatusPostUpdate triggers to invoice the purchase. However, I cannot figure out where I could store the account number and quite possible some other information such as whether the customer opted for a deferred payment or not. As far as I can see, there are no 'unused' variables in the Order or OrderPayment objects that I could use. Is there any way I could store this information in the order without overriding the Order class and modifying the database? The account number and payment type (deferred or not) must be available for two purposes:

 

1) To be able to call the payment gateway API to invoice the authorized purchase

2) To be able to call the payment gateway API to cancel and refund the purchase

 

The only thing that came to my mind is the "Private Note" section in the order details, but from what I could gather that data is relate to the customer and not the order itself.

Link to comment
Share on other sites

Use a database table or store the information in the session cookie. The latter option has the risk of loosing this data when the users closes the browser before finalization of the payment. I would opt for the first version. add a field to ps_orders and let your payment module manage this new field.

Link to comment
Share on other sites

Since modifying the database seems to be the way to go, which of the following two approaches would you suggest:

 

1) Modifying the ps_orders table to accommodate the new field(s), or

2) Creating a new table with the new field(s) and the id_order as the foreign key?

 

Would the modification of ps_orders affect future PrestaShop upgrades in any way?

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...