Results 1 to 3 of 3

Thread: How Payment Methods Work?

  1. #1
    New user
    Join Date
    01-02-12.
    Posts
    4

    Default How Payment Methods Work?

    I'm trying to develop new payment method and I'm having some issues.
    First for some reason the postsale.php script is not creating the PaymentMethod object, I'm talking about this part of code inside postsale.php:
    Code:
    try
    		{
    			$objModule = new $strClass($objModule->row());
    			return $objModule->processPostSale();
    		}
    		catch (Exception $e)
    		{
    			$this->log('Exception in post-sale request: '.$e->getMessage(), __METHOD__, TL_ERROR);
    		}
    Now I could be wrong but this part is supposed to create an object based on the data sent by the payment gateway, so if the gateway being used is paypal the script is supposed to create:
    Code:
    $objModule = new PaymentPaypal($objModule->row());
    and then return
    Code:
    PaymentPaypal->processPostSale()
    Now I've put inside the processPostSale() this line of code:
    Code:
    $this->log('Received post data: ' . print_r($_POST, true), __METHOD__, TL_GENERAL);
    but nothing is loged, when I put the same line of code in postsale.php before the part that tries to create an object I can see the log entry with the post data.
    Now can someone please explain what is going on, and what am I doing wrong.

    Also I've seen that if I set the processPayment() as follows:
    Code:
    public function processPayment()
    	{
    		return true;
    	}
    My payment is working and I get an order placed in Isotope orders. Of course public function processPayment() shoudn't return true by default, there should be some kind of security check. But only postsale.php can receive post data from outside Contao, thus only processPostSale can handle it. So could someone please explain how do processPayment() and processPostsale() work, what do I need them for, and what do they handle in Contao?

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: How Payment Methods Work?

    This is the code from one of my payment gateways. But that gateway returns GET variables...
    Code:
    	public function processPayment() {
    		$status = 'error';
    
    		$objOrder = $this->Database->prepare("SELECT * FROM `tl_iso_orders` WHERE `id`=?")->limit(1)->execute($this->Input->get('purchaseID'));
    
    		if (!$objOrder->numRows) {
    			$this->log('Order ID "' . $this->Input->get('purchaseID') . '" not found', 'PaymentIdealBasic processPostSale()', TL_ERROR);
    			return;
    		}
    
    		// Load / initialize data
    		$arrPayment = deserialize($objOrder->payment_data, true);
    
    		// Store request data in order for future references
    		$arrPayment['POSTSALE'][] = $_GET;
    
    		$arrData = $objOrder->row();
    		$arrPayment['status'] = $this->Input->get('response');
    
    		// array('success', 'cancel', 'error'),
    		switch( $arrPayment['status'] ) {
    			case 'success':
    ...
    Your session shouldn't have expired, can you not also request a status update from the gateway for the current cart (that's how my other gateway functions)

  3. #3
    New user
    Join Date
    01-02-12.
    Posts
    4

    Default Re: How Payment Methods Work?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •