/** * (non-PHPdoc) * @see ComSubscriptionsDomainPaymentGatewayAbstract::process() */ public function process(ComSubscriptionsDomainPaymentPayload $payload) { $options = new KConfig(); $options->append(array('description' => $payload->description)); $args = array($payload->getTotalAmount()); if ($payload->payment_method instanceof ComSubscriptionsDomainPaymentMethodToken) { $gateway = new Merchant_Billing_PaypalExpress($this->_gateway_config); $options->append($payload->payment_method->options); } else { $gateway = new Merchant_Billing_Paypal($this->_gateway_config); $ip = KRequest::get('server.REMOTE_ADDR', 'raw'); if (!$this->getService('koowa:filter.ip')->validate($ip) || strlen($ip) <= 7) { $ip = '127.0.0.1'; } $contact = $payload->payment_method->address; $options->append(array('order_id' => $payload->order_id, 'ip' => $ip, 'address' => array('address1' => $contact->address, 'zip' => $contact->zip, 'state' => $contact->state, 'city' => $contact->city, 'country' => $contact->country))); $args[] = $payload->payment_method->creditcard; } $method = 'purchase'; if ($payload->getRecurring()) { $method = 'recurring'; $options['occurrences'] = $payload->getRecurring()->frequency; $options['unit'] = $payload->getRecurring()->unit; $options['start_date'] = $payload->getRecurring()->start_date; } $args[] = KConfig::unbox($options); $gateway->post(array('TAXAMT' => $payload->tax_amount, 'ITEMAMT' => $payload->amount)); $response = call_object_method($gateway, $method, $args); $result = $response->success(); if (!$result) { $this->_logError($response); } return $result; }