public function createPackageTransaction(Ynmember_Model_Order $order, array $params = array()) { // Check that gateways match if ($order->gateway_id != $this->_gatewayInfo->gateway_id) { throw new Engine_Payment_Plugin_Exception('Gateways do not match'); } //Get unique orders if (!$order->isOrderPending()) { throw new Engine_Payment_Plugin_Exception('CREDIT_No orders found'); } $gatewayPlugin = $this->_gatewayInfo->getGateway(); if ($this->_gatewayInfo->enabled && method_exists($gatewayPlugin, 'createProduct') && method_exists($gatewayPlugin, 'editProduct') && method_exists($gatewayPlugin, 'detailVendorProduct')) { // If it throws an exception, or returns empty, assume it doesn't exist? try { $info = $gatewayPlugin->detailVendorProduct($order->getGatewayIdentity($order->user_id, $order->price)); } catch (Exception $e) { $info = false; } // Create if (!$info) { $arr['user_id'] = $order->user_id; $arr['price'] = $order->price; $gatewayPlugin->createProduct($order->getPackageParams($arr)); } } // Do stuff to params $params['fixed'] = true; $params['skip_landing'] = true; // Lookup product id for this subscription $productInfo = $this->getService()->detailVendorProduct($order->getGatewayIdentity($order->user_id, $order->price)); $params['product_id'] = $productInfo['product_id']; $params['quantity'] = 1; // Create transaction $transaction = $this->createTransaction($params); return $transaction; }