Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Calling callback method to change transaction status.

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 08-24-2015, 03:47 AM
 
kambengkarbonat kambengkarbonat is offline
 

Newbie
  
Join Date: Aug 2015
Posts: 7
 

Default Calling callback method to change transaction status.

Hi,

I'm manage to call a callback method using this URL, <MYSITE>/callback.php

This is the content of the callback.php

Code:
require_once 'top.inc.php'; $result = \XLite\Core\Request::getInstance()->status; if($result=='00') { $status='S'; } elseif ($result=='11') { $status='F'; } elseif ($result=='22') { $status='W'; }

Within this method, I have $_POST['order_id'], so how do i query the transaction that having this ID and update it status?

I use this method
Code:
$this->transaction->setStatus($status);
, but seems it only works on non-callback.

Thanks.
__________________
Core version: 5.2.6
Reply With Quote
  #2  
Old 08-25-2015, 09:49 PM
 
kambengkarbonat kambengkarbonat is offline
 

Newbie
  
Join Date: Aug 2015
Posts: 7
 

Default Re: Calling callback method to change transaction status.

Hi, any help?
__________________
Core version: 5.2.6
Reply With Quote
  #3  
Old 08-28-2015, 01:23 AM
 
kambengkarbonat kambengkarbonat is offline
 

Newbie
  
Join Date: Aug 2015
Posts: 7
 

Default Re: Calling callback method to change transaction status.

How do i query the database and update the fields. Eg.

Code:
\XLite\Core\Database::getRepo('XLite\Model\Order')->update([where to update],[what to update])
.

How can I achieve this?
__________________
Core version: 5.2.6
Reply With Quote
  #4  
Old 09-01-2015, 11:18 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Calling callback method to change transaction status.

Quote:
Originally Posted by kambengkarbonat
I'm manage to call a callback method using this URL, <MYSITE>/callback.php

The way you do it looks a bit hacky. Why don't you add a custom controller class?


Quote:
Originally Posted by kambengkarbonat
I use this method
Code:
$this->transaction->setStatus($status);
, but seems it only works on non-callback.

What is $this->transaction? Where did this variable go from?

Quote:
Originally Posted by kambengkarbonat
How do i query the database and update the fields

X-Cart 5 uses Doctrine ORM 2 library to work with the database.

Did you check the documentation for developers? It has a number of tutorials and examples on working with database entities: http://kb.x-cart.com/
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #5  
Old 09-06-2015, 05:30 PM
 
kambengkarbonat kambengkarbonat is offline
 

Newbie
  
Join Date: Aug 2015
Posts: 7
 

Default Re: Calling callback method to change transaction status.

Quote:
Originally Posted by qualiteam
The way you do it looks a bit hacky. Why don't you add a custom controller class?




What is $this->transaction? Where did this variable go from?



X-Cart 5 uses Doctrine ORM 2 library to work with the database.

Did you check the documentation for developers? It has a number of tutorials and examples on working with database entities: http://kb.x-cart.com/

Yes, I already read through all the documentation but nothing seems to help. If you have any ideas or ways on how do i modified the Orders table after callback method being called will be helpful. Even searching for item using query builders or search method does not works, it returns all the things, instead of the only item that being searched.

Thanks in advanced.
__________________
Core version: 5.2.6
Reply With Quote
  #6  
Old 09-07-2015, 01:36 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Calling callback method to change transaction status.

If you want to update an order field, you should:
1. Retrieve the order model (entity) into a variable
2. Update the model's properties by using "setter" methods
3. Flush the changes into the database if the page controller doesn't do it after finishing executing the action method

These articles may help you to do the above:
- http://kb.x-cart.com/display/XDD/Understanding+Models
- http://kb.x-cart.com/display/XDD/Searching+entities+in+repositories

Or do you want to add new fields to the order model? If so you should "decorate" the order model from your custom module and add the necessary fields.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #7  
Old 09-08-2015, 12:46 AM
 
kambengkarbonat kambengkarbonat is offline
 

Newbie
  
Join Date: Aug 2015
Posts: 7
 

Default Re: Calling callback method to change transaction status.

Hi,

Thanks! I manage to set the payment status field, following the guide that you gives me, by using this method setPaymentStatus as "setter"

But I cant see any "setter" for is_order field, can you point me to which function can i use to update is_order?

Thanks is advance.
__________________
Core version: 5.2.6
Reply With Quote
  #8  
Old 09-08-2015, 02:38 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Calling callback method to change transaction status.

X-Cart 5 generates missing getter and setter methods for fields automatically.

However, is_order is not a regular field, but a "discriminator" column that allows X-Cart to determine if a database record is an entity of \XLite\Model\Cart class, or \XLite\Model\Order class (records for both the classes reside in the same database table).

You can ask X-Cart to turn \XLite\Model\Cart into \XLite\Model\Order by using $cart->markAsOrder(). And use $order->markAsCart() to do the opposite.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #9  
Old 09-08-2015, 06:24 PM
 
kambengkarbonat kambengkarbonat is offline
 

Newbie
  
Join Date: Aug 2015
Posts: 7
 

Default Re: Calling callback method to change transaction status.

Hi qualiteam!

Thanks again and again! Manage to get what I want to do now. Finally my callback is working.

Im searching for markAsOrder as you mention, but what i found something better which is processSucceed, instead of updating status and update is_order manually, this processSucceed method do all this stuff for me automagically.

Thanks again.
__________________
Core version: 5.2.6
Reply With Quote

The following user thanks kambengkarbonat for this useful post:
qualiteam (09-08-2015)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:31 PM.

   

 
X-Cart forums © 2001-2020