public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { $vars = $this->getConfig(); $vars['Amount'] = $invoice->first_total; $vars['Currency'] = $invoice->currency; $vars['ReturnUrl'] = $this->getPluginUrl('thanks'); $vars['CancelUrl'] = $this->getCancelUrl(); $vars['MerchantInvoice'] = $invoice->public_id; $vars['MerchantReference'] = $invoice->public_id; $vars['CustomerFirstName'] = $invoice->getFirstName(); $vars['CustomerLastName'] = $invoice->getLastName(); $vars['CustomerAddress'] = $invoice->getStreet(); $vars['CustomerCity'] = $invoice->getCity(); $vars['CustomerState'] = $invoice->getState(); $vars['InvoiceDescription'] = $invoice->getLineDescription(); $vars['CustomerCountry'] = $invoice->getCountry(); $vars['CustomerPhone'] = $invoice->getPhone(); $vars['CustomerEmail'] = $invoice->getEmail(); $r = new Am_HttpRequest($this->getUrl() . '?' . http_build_query($vars, '', '&')); $response = $r->send()->getBody(); if (!$response) { $this->getDi()->errorLogTable->log('Plugin eWAY: Got empty response from API server'); $result->setErrorMessages(array(___("An error occurred while handling your payment."))); return; } $xml = simplexml_load_string($response); if (!empty($xml->Error)) { $this->getDi()->errorLogTable->log('Plugin eWAY: Got error from API: ' . (string) $xml->Error); $result->setErrorMessages(array(___("An error occurred while handling your payment."))); return; } $action = new Am_Paysystem_Action_Redirect($xml->URI); $result->setAction($action); }
public function validateResponseStatus(Am_Paysystem_Result $result) { if ($this->response->getStatus() != 200) { $result->setErrorMessages(array("Received invalid response from payment server: " . $this->response->getStatus())); return false; } return true; }
public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result) { $token = $invoice->getUser()->data()->get(self::TOKEN); if (!$token) { return $result->setErrorMessages(array(___('Payment failed'))); } if ($doFirst && doubleval($invoice->first_total) <= 0) { // free trial $tr = new Am_Paysystem_Transaction_Free($this); $tr->setInvoice($invoice); $tr->process(); $result->setSuccess($tr); } else { $tr = new Am_Paysystem_Transaction_Paymill($this, $invoice, $doFirst); $tr->run($result); } }
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result) { include_once dirname(__FILE__) . '/SOPGClassicMerchantClient.php'; $client = new SOPGClassicMerchantClient($this->getConfig('testing') ? self::TEST_API_URL : self::LIVE_API_URL); $mtid = $invoice->public_id; //$this->generateMtid(); // SEE par.2 if ($invoice->first_total > 1000) { throw new InvalidArgumentException('The maximum amount value of dispositions is 1000.00'); } // see par.2 $request = array($this->getConfig('login'), $this->getConfig('password'), $mtid, null, sprintf('%.2f', $invoice->first_total), $invoice->currency, urlencode($this->getReturnUrl()), urlencode($this->getPluginUrl('cancelpaysafecart') . "?id=" . $invoice->getSecureId('CANCEL')), $invoice->getUserId(), urlencode($this->getPluginUrl()), null); $this->logRequest($request); $response = call_user_func_array(array($client, 'createDisposition'), $request); $this->logResponse(get_object_vars($response)); if ($response->resultCode != 0 || $response->errorCode != 0) { // SEE par.4 $result->setErrorMessages(array('Transaction could not be initiated due to connection problems.')); //$result->setErrorMessages(array('Error during request to paysafecard server')); // see par.4 return; } $a = new Am_Paysystem_Action_Redirect($this->getConfig('testing') ? self::TEST_REDIRECT_URL : self::LIVE_REDIRECT_URL); $a->mid = $response->mid; $a->mtid = $mtid; $a->amount = sprintf('%.2f', $invoice->first_total); $a->currency = $invoice->currency; $result->setAction($a); }