コード例 #1
0
ファイル: stripe.php プロジェクト: grlf/eyedock
 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_Stripe($this, $invoice, $doFirst);
         $tr->run($result);
     }
 }
コード例 #2
0
ファイル: authorize-cim.php プロジェクト: grlf/eyedock
 public function _doTheBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     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 {
         //fix for previously not saved payment profile
         if (!$invoice->getUser()->data()->get(Am_Paysystem_AuthorizeCim::PAYMENT_PROFILE_KEY)) {
             $this->loadLastProfile($invoice);
         }
         $tr = new Am_Paysystem_Transaction_AuthorizeCim_CreateCustomerProfileTransaction($this, $invoice, $doFirst);
         $tr->run($result);
     }
 }
コード例 #3
0
ファイル: direct-one.php プロジェクト: alexanderTsig/arabic
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     if ($doFirst && !(double) $invoice->first_total) {
         // free trial
         $tr = new Am_Paysystem_Transaction_Free($this);
         $tr->setInvoice($invoice);
         $tr->process();
         $result->setSuccess($tr);
     } else {
         $request = $this->createHttpRequest();
         $request->addPostParameter(array('vendor_name' => $this->getConfig('account_name'), 'vendor_password' => $this->getConfig('account_pass'), 'card_number' => $cc->cc_number, 'card_type' => 'AUTO', 'card_expiry' => $cc->getExpire(), 'card_holder' => sprintf('%s %s', $cc->cc_name_f, $cc->cc_name_l), 'payment_amount' => ($doFirst ? $invoice->first_total : $invoice->second_total) * 100, 'payment_reference' => $invoice->public_id));
         $request->setMethod(Am_HttpRequest::METHOD_POST);
         $request->setUrl($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL);
         $transaction = new Am_Paysystem_Transaction_DirectOne($this, $invoice, $request, $doFirst);
         $transaction->run($result);
     }
 }
コード例 #4
0
ファイル: authorize-echeck.php プロジェクト: grlf/eyedock
 public function _doBill(Invoice $invoice, $doFirst, EcheckRecord $echeck, Am_Paysystem_Result $result)
 {
     if ($doFirst && !(double) $invoice->first_total) {
         // free trial
         $tr = new Am_Paysystem_Transaction_Free($this);
         $tr->setInvoice($invoice);
         $tr->process();
         $result->setSuccess($tr);
     } else {
         $user = $invoice->getUser();
         $ps = new stdclass();
         $ps->x_Invoice_Num = $invoice->public_id;
         $ps->x_Cust_ID = $invoice->user_id;
         $ps->x_Description = $invoice->getLineDescription();
         $ps->x_First_Name = $echeck->cc_name_f;
         $ps->x_Last_Name = $echeck->cc_name_l;
         $ps->x_Address = $echeck->cc_street;
         $ps->x_City = $echeck->cc_city;
         $ps->x_State = $echeck->cc_state;
         $ps->x_Country = $echeck->cc_country;
         $ps->x_Zip = $echeck->cc_zip;
         $ps->x_Tax = $doFirst ? $invoice->first_tax : $invoice->second_tax;
         $ps->x_Email = $user->email;
         $ps->x_Phone = $echeck->cc_phone;
         $ps->x_Amount = $doFirst ? $invoice->first_total : $invoice->second_total;
         $ps->x_Currency_Code = $invoice->currency;
         $ps->x_Type = 'AUTH_CAPTURE';
         $ps->x_Customer_IP = $user->remote_addr ? $user->remote_addr : $_SERVER['REMOTE_ADDR'];
         $ps->x_Relay_Response = 'FALSE';
         $ps->x_Delim_Data = 'TRUE';
         $ps->x_bank_acct_num = $echeck->echeck_ban;
         $ps->x_bank_aba_code = $echeck->echeck_aba;
         $ps->x_bank_acct_type = $echeck->echeck_type;
         $ps->x_bank_name = $echeck->check_bank_name;
         $ps->x_bank_acct_name = $echeck->echeck_account_name;
         $ps->x_echeck_type = 'WEB';
         $ps->x_recurring_billing = $invoice->rebill_times ? 'TRUE' : 'FALSE';
         $request = $this->_sendRequest($this->createHttpRequest());
         $request->addPostParameter((array) $ps);
         $transaction = new Am_Paysystem_Transaction_AuthorizeEcheck_Payment($this, $invoice, $request, $doFirst);
         $transaction->run($result);
     }
 }
コード例 #5
0
ファイル: comenpay.php プロジェクト: alexanderTsig/arabic
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     $client = new SoapClient(self::WSDL);
     $user = $invoice->getUser();
     if ($cc) {
         $data = array('customer_firstname' => $user->name_f ? $user->name_f : $cc->cc_name_f, 'customer_lastname' => $user->name_l ? $user->name_l : $cc->cc_name_l, 'customer_email' => $user->email, 'holder_firstname' => $cc->cc_name_f, 'holder_lastname' => $cc->cc_name_l, 'pan' => $cc->cc_number, 'digit' => $cc->getCvv(), 'exp' => $cc->getExpire('%02d-20%02d'));
         $data = base64_encode(serialize($data));
         $param = array($this->getConfig('apiKey'), $data);
         $request = new SoapRequestWrapperComenpay($client, 'AddCustomerData', $param);
         $t = new Am_Paysystem_Transaction_CreditCard_Comenpay_AddCustomerData($this, $invoice, $request, $user);
         $r = new Am_Paysystem_Result();
         $t->run($r);
         if ($r->isFailure()) {
             $result->setFailed($r->getErrorMessages());
             return;
         }
     }
     if (!$user->data()->get(self::COMENPAY_CARD_TOKEN)) {
         $result->setFailed('Can not process payment: customer has not associated CC');
         return;
     }
     if ($doFirst && !(double) $invoice->first_total) {
         //free trial
         $t = new Am_Paysystem_Transaction_Free($this);
         $t->setInvoice($invoice);
         $t->process();
         $result->setSuccess();
     } else {
         $payment = null;
         @(list($payment) = $invoice->getPaymentRecords());
         $data = array('paccount_id' => $this->getConfig('paccount_id'), 'type' => $payment ? 'REBILL' : 'BILL', 'transaction_ip' => $user->last_ip, 'amount_cnts' => 100 * ($doFirst ? $invoice->first_total : $invoice->second_total), 'client_reference' => $invoice->public_id, 'client_customer_id' => $user->pk(), 'affiliate_id' => 0, 'site_url' => $this->getDi()->config->get('site_url'), 'member_login' => $user->login, 'support_url' => $this->getDi()->config->get('site_url'), 'support_tel' => 'N/A', 'support_email' => $this->getDi()->config->get('admin_email'), 'customer_lang' => 'en', 'customer_useragent' => $user->last_user_agent, 'billing_invoicing_id' => 0, 'billing_description' => $invoice->getLineDescription(), 'billing_preauth_duration' => 0, 'billing_rebill_period' => 0, 'billing_rebill_duration' => 0, 'billing_rebill_price_cnts' => 100 * $invoice->second_total);
         if ($payment) {
             $data['billing_initial_transaction_id'] = $payment->receipt_id;
         }
         $param = array($this->getConfig('apiKey'), $user->data()->get(self::COMENPAY_CARD_TOKEN), $user->data()->get(self::COMENPAY_CARD_KEY), $data);
         $request = new SoapRequestWrapperComenpay($client, 'Transaction', $param);
         $t = new Am_Paysystem_Transaction_CreditCard_Comenpay_Transaction($this, $invoice, $request, $doFirst);
         $t->run($result);
     }
 }
コード例 #6
0
ファイル: clickbank.php プロジェクト: alexanderTsig/arabic
 public function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     $request = $this->createHttpRequest();
     $ps = new stdclass();
     $ps->type = 'rfnd';
     $ps->reason = 'ticket.type.refund.8';
     $ps->comment = 'refund request for aMember user (' . $payment->getUser()->login . ')';
     if (doubleval($amount) == doubleval($payment->amount)) {
         $ps->refundType = 'FULL';
     } else {
         $ps->refundType = 'PARTIAL_AMOUNT';
         $ps->refundAmount = $amount;
     }
     $get_params = http_build_query((array) $ps, '', '&');
     $request->setUrl($s = 'https://api.clickbank.com/rest/1.3/tickets/' . $payment->receipt_id . "?{$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() != 'Refund ticket already open') {
         throw new Am_Exception_InputError("An error occurred during refund request");
     }
     $trans = new Am_Paysystem_Transaction_Manual($this);
     $trans->setAmount($amount);
     $trans->setReceiptId($payment->receipt_id . '-clickbank-refund');
     $result->setSuccess($trans);
 }
コード例 #7
0
ファイル: payonlinesystem.php プロジェクト: grlf/eyedock
 public function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     $request = new Am_HttpRequest(self::REFUND_URL, Am_HttpRequest::METHOD_POST);
     $vars = array('MerchantId' => $this->getConfig('merchant_id'), 'TransactionId' => $payment->receipt_id, 'Amount' => $amount, 'ContentType' => 'text');
     $vars['SecurityKey'] = $this->getRefundSecurityKey($vars);
     foreach ($vars as $k => $v) {
         $request->addPostParameter($k, $v);
     }
     $this->logRequest($request);
     $response = $request->send();
     $this->logResponse($response);
     if ($response->getStatus() != 200) {
         throw new Am_Exception_InputError("An error occurred during refund request");
     }
     parse_str($response->getBody(), $parsed);
     if ($parsed['Result'] != 'Ok') {
         throw new Am_Exception_InputError("An error occurred during refund request: " . $parsed['Message']);
     }
     $trans = new Am_Paysystem_Transaction_Manual($this);
     $trans->setAmount($amount);
     $trans->setReceiptId($parsed['TransactionId'] . '-refund');
     $result->setSuccess($trans);
 }
コード例 #8
0
ファイル: paymentwall.php プロジェクト: grlf/eyedock
 public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     $this->invoice = $invoice;
     list($payment) = $invoice->getPaymentRecords();
     $params = array('key' => $this->getConfig('key'), 'ref' => $payment->receipt_id, 'uid' => $payment->user_id, 'type' => 2);
     $params['sign'] = $this->calculateSignature($params, $this->getConfig('secret'));
     $requst = new Am_HttpRequest(self::URL_TICKET, Am_HttpRequest::METHOD_POST);
     $requst->addPostParameter($params);
     $log = $this->logRequest($requst);
     $responce = $requst->send();
     $log->add($responce);
     if ($responce->getStatus() != 200) {
         $result->setFailed('Incorrect HTTP response status: ' . $responce->getStatus());
         return;
     }
     $res = Am_Controller::decodeJson($responce->getBody());
     if ($res['result'] == 1) {
         $invoice->setCancelled();
         $result->setSuccess();
         return;
     }
     $result->setFailed($res['errors']);
 }
コード例 #9
0
ファイル: Echeck.php プロジェクト: grlf/eyedock
 /**
  * Function can be overrided to change behaviour
  */
 public function storeEcheck(EcheckRecord $echeck, Am_Paysystem_Result $result)
 {
     if ($this->storesCcInfo()) {
         $echeck->replace();
         $result->setSuccess();
     }
     return $this;
 }
コード例 #10
0
ファイル: omise.php プロジェクト: alexanderTsig/arabic
 public function validate(Am_Paysystem_Result $result)
 {
     if ($this->params['failure_code']) {
         $result->setFailed($this->params['failure_message']);
     } else {
         $result->setSuccess();
     }
 }
コード例 #11
0
ファイル: dibs-recurring.php プロジェクト: irovast/eyedock
 function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     $request = new Am_HttpRequest("https://" . $this->getConfig('login') . ":" . $this->getConfig('password') . "@payment.architrade.com/cgi-adm/refund.cgi");
     $invoice = $payment->getInvoice();
     $currency = $this->getCurrencyCode($invoice);
     $post_params = new stdclass();
     $post_params->merchant = $this->getConfig('merchant');
     $post_params->amount = $amount * 100;
     $count = $this->getDi()->db->selectCol("SELECT COUNT(*) FROM ?_invoice_payment\n                WHERE invoice_id=?d AND dattm < ?\n                ", $payment->invoice_id, $payment->dattm);
     $post_params->orderId = $invoice->public_id . "-" . sprintf("%03d", array_shift($count));
     $post_params->transact = $invoice->data()->get(self::TICKET);
     $post_params->textreply = 'true';
     $post_params->currency = $currency;
     $post_params->md5key = md5($s2 = $this->getConfig('key2') . md5($s1 = $this->getConfig('key1') . "merchant=" . $this->getConfig('merchant') . "&orderid=" . $invoice->public_id . "&transact=" . $invoice->data()->get(self::TICKET) . "&amount=" . $amount));
     $request->addPostParameter((array) $post_params);
     $response = $request->send();
     $response = $this->parseResponse($response->getBody());
     if ($response['result'] === 0) {
         $trans = new Am_Paysystem_Transaction_Manual($this);
         $trans->setAmount($amount);
         $trans->setReceiptId($payment->receipt_id . '-dibs-refund');
         $result->setSuccess($trans);
     } else {
         $result->setFailed(array('Error Processing Refund!'));
     }
 }
コード例 #12
0
ファイル: ccbill.php プロジェクト: alexanderTsig/arabic
 function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     if (!$this->getConfig('datalink_user') || !$this->getConfig('datalink_pass')) {
         $this->getDi()->errorLogTable->log("ccBill plugin error: Datalink is not configured!");
         return;
     }
     //https://datalink.ccbill.com/utils/subscriptionManagement.cgi?clientSubacc=&usingSubacc=0005&subscriptionId=1071776966&username=ccbill12&password=test123&returnXML=1&action=cancelSubscription&clientAccnum=923590
     $payments = $invoice->getPaymentRecords();
     $subscriptionId = $payments[0]->transaction_id;
     $vars = array('clientAccnum' => $this->getConfig('account'), 'clientSubacc' => $this->getConfig('subaccount_id'), 'usingSubacc' => $this->getConfig('subaccount_id'), 'returnXML' => 1, 'action' => 'cancelSubscription', 'subscriptionId' => $subscriptionId, 'username' => $this->getConfig('datalink_user'), 'password' => $this->getConfig('datalink_pass'));
     $r = new Am_HttpRequest($requestString = self::DATALINK_SUBSCR_MANAGEMENT . '?' . http_build_query($vars, '', '&'));
     $response = $r->send();
     if (!$response) {
         $this->getDi()->errorLogTable->log('ccBill Subscription Management error: Unable to contact datalink server');
         throw new Am_Exception_InternalError('ccBill Subscription Management error: Unable to contact datalink server');
     }
     $resp = $response->getBody();
     // Log datalink requests;
     $this->getDi()->errorLogTable->log(sprintf("ccBill SMS debug:\n%s\n%s", $requestString, $resp));
     $xml = simplexml_load_string($resp);
     if ((string) $xml != "1") {
         throw new Am_Exception_InternalError('ccBill Subscription Management error: Incorrect response received while attempting to cancel subscription!');
     }
     $result->setSuccess();
 }
コード例 #13
0
 /**
  * Function can be overrided to change behaviour
  */
 public function storeCreditCard(CcRecord $cc, Am_Paysystem_Result $result)
 {
     if ($this->storesCcInfo()) {
         $cc->replace();
         $result->setSuccess();
     }
     return $this;
 }
コード例 #14
0
ファイル: zombaio.php プロジェクト: alexanderTsig/arabic
 function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     list(, $trans_id) = split("-", $payment->receipt_id);
     try {
         $r = new Am_HttpRequest($this->getAPIURL(self::API_REFUND, array('TRANSACTION_ID' => $trans_id, 'MERCHANT_ID' => $this->getConfig("merchant_id"), 'ZombaioGWPass' => $this->getConfig("password"), 'Refund_Type' => 1)));
         $response = $r->send();
     } catch (Exception $e) {
         $this->getDi()->errorLogTable->logException($e);
     }
     if ($response && $response->getBody() == 1) {
         $trans = new Am_Paysystem_Transaction_Manual($this);
         $trans->setAmount($amount);
         $trans->setReceiptId($payment->receipt_id . '-zombaio-refund');
         $result->setSuccess($trans);
     } else {
         $result->setFailed(array('Error Processing Refund!'));
     }
 }
コード例 #15
0
ファイル: epay.php プロジェクト: irovast/eyedock
 public function run(Am_Paysystem_Result $result)
 {
     $subscriptionid = $this->invoice->data()->get(Am_Paysystem_Epay::SUBSCRIPTIONID);
     $req = $this->plugin->APIRequest('subscription', 'authorize', $vars = array('merchantnumber' => $this->plugin->getConfig('id'), 'subscriptionid' => $subscriptionid, 'orderid' => $this->invoice->public_id . "-" . $this->invoice->getPaymentsCount(), 'amount' => $this->invoice->second_total * 100, 'currency' => Am_Currency::getNumericCode($this->invoice->currency), 'instantcapture' => 1, 'description' => 'Recurring payment for invoice ' . $this->invoice->public_id, 'email' => $this->invoice->getEmail(), 'ipaddress' => $this->invoice->getUser()->remote_addr));
     $log = $this->getInvoiceLog();
     $log->add(print_r($vars, true));
     $this->ret = $this->plugin->getResponseXML($req);
     $log->add(print_r($this->ret, true));
     if ($this->ret->authorizeResponse->authorizeResult != 'true') {
         $result->setFailed(___("Payment failed") . ":" . $this->plugin->getEpayError($this->ret->authorizeResponse->epayresponse));
     } else {
         $result->setSuccess($this);
         $this->processValidated();
     }
 }
コード例 #16
0
 function stopRecurringAction()
 {
     $this->getDi()->authAdmin->getUser()->checkPermission('grid_invoice', 'edit');
     // todo: rewrote stopRecurring
     $invoiceId = $this->_request->getInt('invoice_id');
     if (!$invoiceId) {
         throw new Am_Exception_InputError('No invoice# provided');
     }
     $invoice = $this->getDi()->invoiceTable->load($invoiceId);
     $plugin = $this->getDi()->plugins_payment->loadGet($invoice->paysys_id, true);
     $result = new Am_Paysystem_Result();
     $result->setSuccess();
     try {
         $plugin->cancelAction($invoice, 'cancel-admin', $result);
     } catch (Exception $e) {
         Am_Controller::ajaxResponse(array('ok' => false, 'msg' => $e->getMessage()));
         return;
     }
     if ($result->isSuccess()) {
         $invoice->setCancelled(true);
         $this->getDi()->adminLogTable->log("Invoice Cancelled", 'invoice', $invoice->pk());
         Am_Controller::ajaxResponse(array('ok' => true));
     } elseif ($result->isAction()) {
         $action = $result->getAction();
         if ($action instanceof Am_Paysystem_Action_Redirect) {
             Am_Controller::ajaxResponse(array('ok' => false, 'redirect' => $action->getUrl()));
         } else {
             $action->process();
         }
         // this .. simply will not work hopefully we never get to this point
     } else {
         Am_Controller::ajaxResponse(array('ok' => false, 'msg' => $result->getLastError()));
     }
 }
コード例 #17
0
ファイル: free.php プロジェクト: alexanderTsig/arabic
 function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $result->setSuccess(new Am_Paysystem_Transaction_Free($this));
 }
コード例 #18
0
ファイル: quickpay.php プロジェクト: alexanderTsig/arabic
 function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     $request = new Am_HttpRequest(self::API_URL, Am_HttpRequest::METHOD_POST);
     $post_params = new stdclass();
     $post_params->protocol = '6';
     $post_params->msgtype = 'refund';
     $post_params->merchant = $this->getConfig('merchant');
     $post_params->amount = intval($amount * 100);
     $post_params->transaction = $payment->receipt_id;
     foreach ((array) $post_params as $k => $v) {
         $cstr .= $v;
     }
     $cstr .= $this->getConfig('secret');
     $post_params->md5check = md5($cstr);
     $request->addPostParameter((array) $post_params);
     $response = $request->send();
     $parsedResponse = simplexml_load_string($response->getBody());
     if ((string) $parsedResponse->qpstat != '000') {
         $result->setFailed("Payment failed: Description - " . $this->getErrorMessage((string) $parsedResponse->qpstat) . " QuickPay message - " . $parsedResponse->qpstatmsg);
     } else {
         $trans = new Am_Paysystem_Transaction_Manual($this);
         $trans->setAmount($amount);
         $trans->setReceiptId($payment->receipt_id . '-quickpay-refund');
         $result->setSuccess($trans);
     }
 }
コード例 #19
0
ファイル: sagepay.php プロジェクト: grlf/eyedock
 public function run(Am_Paysystem_Result $result)
 {
     $request = $this->plugin->createHttpRequest();
     $paymentsCount = $this->invoice->getPaymentsCount() + 1;
     $vars = array('VPSProtocol' => '3.0', 'TxType' => 'REPEAT', 'Vendor' => $this->getPlugin()->getConfig('login'), 'VendorTxCode' => $this->invoice->public_id . '-AMEMBER-' . $paymentsCount, 'Amount' => number_format($this->invoice->second_total, 2, '.', ''), 'Currency' => $this->invoice->currency ? $this->invoice->currency : 'USD', 'Description' => $this->invoice->getLineDescription(), 'RelatedVPSTxId' => $this->invoice->data()->get('sagepay_vpstxid'), 'RelatedVendorTxCode' => $this->invoice->data()->get('sagepay_vendortxcode'), 'RelatedSecurityKey' => $this->invoice->data()->get('sagepay_securitykey'), 'RelatedTxAuthNo' => $this->invoice->data()->get('sagepay_txauthno'));
     $request->addPostParameter($vars);
     $request->setUrl($this->plugin->getConfig('testing') ? Am_Paysystem_Sagepay::REPEAT_TEST_URL : Am_Paysystem_Sagepay::REPEAT_LIVE_URL);
     $request->setMethod(Am_HttpRequest::METHOD_POST);
     $this->plugin->logRequest($request);
     $response = $request->send();
     $this->plugin->logResponse($response);
     if (!$response->getBody()) {
         $result->setFailed(___("Payment failed") . ":" . ___("Empty response from Sagepay server"));
     } else {
         $res = array();
         foreach (split(PHP_EOL, $response->getBody()) as $line) {
             list($l, $r) = explode('=', $line, 2);
             $res[trim($l)] = trim($r);
         }
         if ($res['Status'] == 'OK') {
             $this->ret = $res;
             $result->setSuccess($this);
             $this->processValidated();
         } else {
             $result->setFailed(___("Payment failed") . ":" . $res['StatusDetail']);
         }
     }
 }
コード例 #20
0
ファイル: inet-cash.php プロジェクト: grlf/eyedock
 public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     $params = array();
     $params['shopid'] = $invoice->public_id;
     $params['reason'] = $actionName;
     $url = self::URL_CANCEL;
     $url .= $this->getConfig('siteid') . "?" . http_build_query($params);
     $request = new Am_HttpRequest($url, Am_HttpRequest::METHOD_GET);
     $response = $request->send();
     if ($response->getBody() == 'ok') {
         $result->setSuccess();
     } else {
         $result->setFailed($response->getBody());
     }
 }
コード例 #21
0
ファイル: paymill-dd.php プロジェクト: alexanderTsig/arabic
 protected function validate(Am_Paysystem_Result $result)
 {
     if ($this->params['data']['response_code'] != 20000) {
         $result->setFailed(array(___('Refund Failed')));
         return;
     }
     $result->setSuccess();
 }
コード例 #22
0
ファイル: CreditCard.php プロジェクト: alexanderTsig/arabic
 public function cancelAction(Invoice $invoice, $actionName, Am_Paysystem_Result $result)
 {
     $result->setSuccess();
     $invoice->setCancelled(true);
 }
コード例 #23
0
ファイル: Abstract.php プロジェクト: grlf/eyedock
 /**
  * By default this method handles request as IPN
  * If actionName=='thanks', it is handled by thanksAction() handler (override createThanksTransaction for that)
  * @param Am_Request $request
  * @param Zend_Controller_Response_Http $response
  * @param array $invokeArgs
  */
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     $actionName = $request->getActionName();
     switch ($actionName) {
         case 'thanks':
             $this->thanksAction($request, $response, $invokeArgs);
             break;
         case 'cancel':
             $invoice = $this->getDi()->invoiceTable->findBySecureId($request->getFiltered('id'), 'STOP' . $this->getId());
             if (!$invoice) {
                 throw new Am_Exception_InputError("No invoice found [{$id}]");
             }
             $result = new Am_Paysystem_Result();
             $result->setSuccess();
             $this->cancelAction($invoice, $request->getActionName(), $result);
             if ($result->isSuccess()) {
                 $invoice->setCancelled(true);
                 Am_Controller::redirectLocation(REL_ROOT_URL . '/member/payment-history');
             } elseif ($result->isAction()) {
                 $action = $result->getAction();
                 $action->process();
                 // I cannot imaginge anything but redirect here... yet? :)
             } else {
                 throw new Am_Exception_InputError(___("Unable to cancel subscription: " . $result->getLastError()));
             }
             break;
         default:
             // standard action handling via transactions
             $invoiceLog = $this->_logDirectAction($request, $response, $invokeArgs);
             $transaction = $this->createTransaction($request, $response, $invokeArgs);
             if (!$transaction) {
                 throw new Am_Exception_InputError("Request not handled - createTransaction() returned null");
             }
             $transaction->setInvoiceLog($invoiceLog);
             try {
                 $transaction->process();
             } catch (Exception $e) {
                 if ($invoiceLog) {
                     $invoiceLog->add($e);
                 }
                 throw $e;
             }
             if ($invoiceLog) {
                 $invoiceLog->setProcessed();
             }
     }
 }
コード例 #24
0
ファイル: twocheckout.php プロジェクト: alexanderTsig/arabic
 public function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     if (!$this->getApi()) {
         throw new Am_Exception_Paysystem_NotConfigured("No 2Checkout API username/password configured - could not do refund");
     }
     $log = $this->getDi()->invoiceLogRecord;
     $log->setInvoice($payment->getInvoice());
     $return = $this->getApi()->refundInvoice($payment->receipt_id, 5, "Customer Request");
     $log->add($return);
     if ($return['response_code'] == 'OK') {
         $result->setSuccess();
     } else {
         $result->setFailed($return['response_message']);
     }
 }
コード例 #25
0
ファイル: braintree.php プロジェクト: alexanderTsig/arabic
 public function run(Am_Paysystem_Result $result)
 {
     $this->result = $result;
     $log = $this->getInvoiceLog();
     $request = $this->getRequest();
     $log->add($request);
     $this->paysystemResponse = $this->submitTransaction($request);
     $log->add($this->paysystemResponse);
     if ($this->paysystemResponse->success) {
         try {
             $result->setSuccess($this);
             $this->processValidated();
         } catch (Exception $e) {
             if ($e instanceof PHPUnit_Framework_Error) {
                 throw $e;
             }
             if ($e instanceof PHPUnit_Framework_Asser) {
                 throw $e;
             }
             if (!$result->isFailure()) {
                 $result->setFailed(___("Payment failed"));
             }
             $log->add($e);
         }
     } else {
         if ($errors = $this->paysystemResponse->errors->deepAll()) {
             if (!is_array($errors)) {
                 $errors = array($errors);
             }
             foreach ($errors as $error) {
                 $error_text .= $error->message;
             }
             $result->setFailed("Error: " . $errors);
         } else {
             if ($this->paysystemResponse->transaction->status == 'processor_declined') {
                 $result->setFailed("Declined: " . $this->paysystemResponse->transaction->processorResponseText);
             } else {
                 $result->setFailed("Gateway Rejected: " . $this->paysystemResponse->transaction->gatewayRejectionReason);
             }
         }
     }
 }
コード例 #26
0
ファイル: micropayment-dbt.php プロジェクト: irovast/eyedock
 public function run(Am_Paysystem_Result $result)
 {
     $this->result = $result;
     $log = $this->getInvoiceLog();
     $log->add($this->request);
     try {
         $this->sessionData = call_user_func_array(array($this->getPlugin()->getDispatcher(), 'sessionCreate'), $this->request);
         $this->response = $this->getPlugin()->getDispatcher()->sessionApprove($this->getPlugin()->getConfig('key'), $this->getPlugin()->getConfig('testing'), $this->sessionData['sessionId']);
         $log->add($this->response);
         if ($this->response['status'] == 'APPROVED') {
             $this->processValidated();
             $result->setSuccess();
         }
     } catch (Exception $e) {
         $result->setFailed($e->getMessage());
     }
 }
コード例 #27
0
ファイル: paypal-express.php プロジェクト: irovast/eyedock
 function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     $log = Am_Di::getInstance()->invoiceLogRecord;
     $log->title = "refundTransaction";
     $log->paysys_id = $this->getId();
     $apireq = new Am_Paysystem_PaypalApiRequest($this);
     $apireq->refundTransaction($payment);
     $res = $apireq->sendRequest($log);
     $log->setInvoice($payment->getInvoice());
     $log->update();
     if ($res['ACK'] != 'Success') {
         $result->setFailed('Transaction was not refunded. Got error from paypal: ' . $res['L_SHORTMESSAGE0']);
         return;
     }
     $result->setSuccess();
     // We will not add refund record here because it will be handeld by IPN script.
 }
コード例 #28
0
ファイル: cc-demo.php プロジェクト: subashemphasize/test_site
 public function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     $transaction = new Am_Paysystem_Transaction_CcDemo_Refund($this, $payment->getInvoice(), new Am_Request(array('receipt_id' => 'rr')), false);
     $transaction->setAmount($amount);
     $result->setSuccess($transaction);
 }
コード例 #29
0
ファイル: paymill.php プロジェクト: grlf/eyedock
 protected function ccFormAndSaveCustomer()
 {
     $vars = $this->form->getValue();
     $result = new Am_Paysystem_Result();
     if (!empty($vars['paymill_token'])) {
         if (!$vars['paymill_token']) {
             throw new Am_Exception_Paysystem("No expected token id received");
         }
         $this->invoice->getUser()->data()->set(Am_Paysystem_Paymill::TOKEN, $vars['paymill_token'])->update();
         $result->setSuccess();
         // setup session to do not reask payment info within 30 minutes
         $s = new Zend_Session_Namespace($this->plugin->getId());
         $s->setExpirationSeconds(60 * 30);
         // after 30 minutes we will reset the session
         $s->ccConfirmed = true;
     }
     return $result;
 }
コード例 #30
0
ファイル: gocardlesspro.php プロジェクト: grlf/eyedock
 public function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     // Request to check state of payment ; must be confirmed / paid_out
     $response = $this->_sendRequest('/payments/' . $payment->transaction_id, null, 'GET');
     if ($response->getStatus() !== 200) {
         $result->setFailed('An error occured, unable to find the payment.');
         return $result;
     }
     $response = json_decode($response->getBody(), true);
     if (!in_array($response['payments']['status'], array('confirmed', 'paid_out'))) {
         $result->setFailed('Payment status must be either "Confirmed" or "Paid out" at GoCardLess. Current state is "' . $response['payments']['status'] . '"');
         return $result;
     }
     $response = $this->_sendRequest('/refunds/', array('refunds' => array('amount' => intval(doubleval($amount) * 100), 'total_amount_confirmation' => intval(doubleval($amount) * 100), 'links' => array('payment' => $payment->transaction_id))));
     if ($response->getStatus() !== 201) {
         throw new Am_Exception_InputError("An error occurred while cancellation request");
     }
     $trans = new Am_Paysystem_Transaction_Manual($this);
     $trans->setAmount($amount);
     $trans->setReceiptId($payment->receipt_id . '-gocardlesspro-refund');
     $result->setSuccess($trans);
 }