Exemplo n.º 1
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $a = new Am_Paysystem_Action_Redirect($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL);
     $result->setAction($a);
     $a->StoreKey = $this->getConfig('storekey');
     $a->CustomerRefNo = $invoice->public_id;
     $a->PaymentType = '';
     $a->CardAction = '0';
     $a->OrderID = $invoice->invoice_id;
     $a->UserID = $invoice->getLogin();
     $a->Email = $invoice->getEmail();
     $a->CustomerIP = $user->remote_addr ? $user->remote_addr : $_SERVER['REMOTE_ADDR'];
     $a->Bname = $invoice->getFirstName() . ' ' . $invoice->getLastName();
     $a->Baddress1 = $user->street;
     $a->Bcity = $user->city;
     $a->Bpostalcode = $user->zip;
     $a->Bcountry = $user->country;
     $a->Sname = $invoice->getFirstName() . ' ' . $invoice->getLastName();
     $a->Saddress1 = $user->street;
     $a->Scity = $user->city;
     $a->Spostalcode = $user->zip;
     $a->Scountry = $user->country;
     $a->SubTotal = $invoice->first_total - $invoice->first_tax;
     $a->Tax1 = $invoice->first_tax;
     $a->ThanksURL = $this->getPluginUrl("thanks");
     $result->setAction($a);
 }
Exemplo n.º 2
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     if ($this->getConfig('dynamic_pricing')) {
         $a = new Am_Paysystem_Action_Redirect(self::DYNAMIC_URL);
         $a->version = 1;
         $a->shopID = $this->getConfig('site_id');
         $a->priceAmount = $invoice->first_total;
         $a->priceCurrency = $invoice->currency;
         $a->description = $invoice->getLineDescription();
         $a->referenceID = $invoice->public_id;
         $a->signature = sha1($q = $this->getConfig('secret') . ":description=" . $invoice->getLineDescription() . ":priceAmount=" . $invoice->first_total . ":priceCurrency=" . $invoice->currency . ":referenceID=" . $invoice->public_id . ":shopID=" . $this->getConfig('site_id') . ":version=1");
     } else {
         $a = new Am_Paysystem_Action_Redirect(self::URL);
         $a->verotel_id = $this->getConfig('merchant_id');
         $a->verotel_product = $invoice->getItem(0)->getBillingPlanData("verotel_id") ? $invoice->getItem(0)->getBillingPlanData("verotel_id") : $this->getConfig('site_id');
         $a->verotel_website = $invoice->getItem(0)->getBillingPlanData("verotel_id") ? $invoice->getItem(0)->getBillingPlanData("verotel_id") : $this->getConfig('site_id');
         $a->verotel_usercode = $invoice->getLogin();
         $a->verotel_passcode = 'FromSignupForm';
         //$invoice->getUser()->getPlaintextPass();
         $a->verotel_custom1 = $invoice->public_id;
     }
     $a->filterEmpty();
     $result->setAction($a);
 }
Exemplo n.º 3
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $xml = new SimpleXMLElement('<request/>');
     $transactiondetails = $xml->addChild('transactiondetails');
     $transactiondetails->addChild('merchantcode', $this->getConfig('merchantid'));
     $transactiondetails->addChild('merchantpwd', $this->getConfig('merchantpwd'));
     $transactiondetails->addChild('trackid', $invoice->public_id);
     $transactiondetails->addChild('customerip', $request->getClientIp());
     $transactiondetails->addChild('udf1', $invoice->public_id);
     $transactiondetails->addChild('customerid', $invoice->getLogin());
     $paymentdetails = $xml->addChild('paymentdetails');
     $paymentdetails->addChild('paysource', 'enets');
     $paymentdetails->addChild('amount', $invoice->first_total);
     $paymentdetails->addChild('currency', $invoice->currency);
     $paymentdetails->addChild('actioncode', 1);
     $notificationurls = $xml->addChild('notificationurls');
     $notificationurls->addChild('successurl', $this->getReturnUrl());
     $notificationurls->addChild('failurl', $this->getCancelUrl());
     $shippingdetails = $xml->addChild('shippingdetails');
     foreach (array('ship_address' => $invoice->getStreet(), 'ship_email' => $invoice->getEmail(), 'ship_postal' => $invoice->getZip(), 'ship_address2' => $invoice->getStreet1(), 'ship_city' => $invoice->getCity(), 'ship_state' => $invoice->getState(), 'ship_phone' => $invoice->getPhone(), 'ship_country' => $invoice->getCountry()) as $k => $v) {
         $shippingdetails->addChild($k, $v);
     }
     $req = new Am_HttpRequest($this->getConfig('gatewayurl'), Am_HttpRequest::METHOD_POST);
     $req->setHeader('Content-type: text/xml; charset=utf-8')->setHeader('Connection:close')->setBody($xml->asXML());
     $response = $req->send();
     $resxml = @simplexml_load_string($response->getBody());
     if (!$resxml instanceof SimpleXMLElement) {
         throw new Am_Exception_InputError('Incorrect Gateway response received!');
     }
     if ($paymenturl = (string) $resxml->transactionresponse->paymenturl) {
         $a = new Am_Paysystem_Action_Redirect($paymenturl);
         $result->setAction($a);
     } else {
         throw new Am_Exception_InputError('Incorrect Gateway response received! Got: ' . (string) $resxml->responsedesc);
     }
 }
Exemplo n.º 4
0
 function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Form('https://ssl.ditonlinebetalingssystem.dk/popup/default.asp');
     $a->language = $this->getConfig('language', 2);
     // English default for testing.
     $a->merchantnumber = $this->getConfig('id');
     $a->orderid = $invoice->public_id;
     $a->currency = Am_Currency::getNumericCode($invoice->currency);
     $a->amount = $invoice->first_total * 100;
     $a->accepturl = $this->getReturnUrl();
     $a->declineurl = $this->getCancelUrl();
     $a->callbackurl = $this->getPluginUrl('ipn');
     $a->instantcallback = 1;
     // Call callback before user returned to accept_url
     $a->instantcapture = 1;
     $a->ordertext = $invoice->getLineDescription();
     $a->windowstate = 2;
     if ($invoice->rebill_times) {
         $a->subscription = 1;
         $a->subscriptionname = sprintf('Invoice %s, User %s', $invoice->public_id, $invoice->getLogin());
     }
     $a->md5key = $this->getOutgoingMd5($a);
     $result->setAction($a);
 }
Exemplo n.º 5
0
 public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     $request = $this->createHttpRequest();
     $ps = new stdclass();
     $ps->type = 'cncl';
     $ps->reason = 'ticket.type.cancel.7';
     $ps->comment = 'cancellation request from aMember user (' . $invoice->getLogin() . ')';
     $get_params = http_build_query((array) $ps, '', '&');
     $payment = current($invoice->getPaymentRecords());
     $request->setUrl($s = 'https://api.clickbank.com/rest/1.3/tickets/' . Am_Di::getInstance()->invoicePaymentTable->getLastReceiptId($invoice->pk()) . "?{$get_params}");
     $request->setHeader(array('Content-Length' => '0', 'Accept' => 'application/xml', 'Authorization' => $this->getConfig('dev_key') . ':' . $this->getConfig('clerk_key')));
     $request->setMethod(Am_HttpRequest::METHOD_POST);
     $this->logRequest($request);
     $request->setMethod('POST');
     $response = $request->send();
     $this->logResponse($response);
     if ($response->getStatus() != 200 && $response->getBody() != 'Subscription already canceled') {
         throw new Am_Exception_InputError("An error occurred while cancellation request");
     }
 }