Example #1
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     $xml = new SimpleXMLElement('<ewaygateway></ewaygateway>');
     $xml->ewayCustomerID = $this->getConfig('customer_id');
     $xml->ewayTotalAmount = $doFirst ? $invoice->first_total * 100 : $invoice->second_total * 100;
     $xml->ewayCustomerFirstName = $cc->cc_name_f;
     $xml->ewayCustomerLastName = $cc->cc_name_l;
     $xml->ewayCustomerEmail = $invoice->getUser()->email;
     $xml->ewayCustomerAddress = $cc->cc_street;
     $xml->ewayCustomerPostcode = $cc->cc_zip;
     $xml->ewayCustomerInvoiceDescription = $invoice->getLineDescription();
     $xml->ewayCustomerInvoiceRef = $invoice->public_id;
     $xml->ewayCardHoldersName = sprintf('%s %s', $cc->cc_name_f, $cc->cc_name_l);
     $xml->ewayCardNumber = $cc->cc_number;
     $xml->ewayCardExpiryMonth = $cc->getExpire('%1$02d');
     $xml->ewayCardExpiryYear = $cc->getExpire('%2$02d');
     $xml->ewayTrxnNumber = $invoice->public_id;
     $xml->ewayOption1 = '';
     $xml->ewayOption2 = '';
     $xml->ewayOption3 = '';
     $xml->ewayCVN = $cc->getCvv();
     $request = new Am_HttpRequest($this->getGateway(), Am_HttpRequest::METHOD_POST);
     $request->setBody($xml->asXML());
     $request->setHeader('Content-type', 'text/xml');
     $tr = new Am_Paysystem_Transaction_CreditCard_Eway($this, $invoice, $request, $doFirst);
     $tr->run($result);
 }
Example #2
0
 function processSubscribe(Invoice $invoice, CcRecord $cc = null)
 {
     $request = new Am_HttpRequest(self::API_URL, Am_HttpRequest::METHOD_POST);
     $post_params = new stdclass();
     $post_params->protocol = '6';
     $post_params->msgtype = 'subscribe';
     $post_params->merchant = $this->getConfig('merchant');
     $post_params->ordernumber = $invoice->public_id . "-" . sprintf("%03d", $invoice->getPaymentsCount());
     $post_params->cardnumber = $cc->cc_number;
     $post_params->expirationdate = $cc->cc_expire;
     $post_params->cvd = $cc->getCvv();
     $post_params->description = "Subscribe from aMember";
     if ($this->getConfig('testing')) {
         $post_params->testmode = $this->getConfig('testing');
     }
     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());
     return $parsedResponse;
 }
Example #3
0
 public function run(Am_Paysystem_Result $result)
 {
     require_once dirname(__FILE__) . "/lphp.php";
     $mylphp = new lphp();
     $myorder["host"] = $this->getPlugin()->getConfig('testing') ? "staging.linkpt.net" : "secure.linkpt.net";
     $myorder["port"] = "1129";
     $myorder["keyfile"] = dirname(APPLICATION_CONFIG) . '/' . $this->getPlugin()->getConfig('keyfile');
     $myorder["configfile"] = $this->getPlugin()->getConfig('id');
     $myorder["ordertype"] = "SALE";
     $myorder["result"] = $this->getPlugin()->getConfig('testing') ? "GOOD" : "LIVE";
     # For a test, set result to GOOD, DECLINE, or DUPLICATE
     $myorder["cardnumber"] = $this->cc->cc_number;
     $myorder["cardexpmonth"] = $this->cc->getExpire('%1$02d');
     $myorder["cardexpyear"] = $this->cc->getExpire('%2$02d');
     $myorder["chargetotal"] = $this->doFirst ? $this->invoice->first_total : $this->invoice->second_total;
     $myorder["addrnum"] = preg_replace('/^D/', '', $this->cc->cc_street);
     $myorder["zip"] = $this->cc->cc_zip;
     if ($this->cc->getCvv()) {
         $myorder["cvmindicator"] = "provided";
         $myorder["cvmvalue"] = $this->cc->getCvv();
     }
     //if ($this->getPlugin()->getConfig('testing'))
     //    $myorder["debugging"] = "true";  # for development only - not intended for production use
     // uncomment it to get debug info to screen!
     $log = $this->getInvoiceLog();
     $log->add($mylphp->buildXML($myorder));
     $this->ret = $mylphp->curl_process($myorder);
     $log->add(print_r($this->ret, true));
     if ($this->ret['r_approved'] == 'APPROVED') {
         $result->setSuccess($this);
         $this->processValidated();
     } else {
         $result->setFailed(___("Payment failed") . ":" . $this->ret['r_error']);
     }
 }
Example #4
0
 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);
     }
 }
Example #5
0
 function setCc(Invoice $invoice, CcRecord $cc)
 {
     $this->addPostParameter('IPADDRESS', $_SERVER['REMOTE_ADDR']);
     $this->addPostParameter('CREDITCARDTYPE', $cc->cc_type);
     $this->addPostParameter('ACCT', $cc->cc_number);
     $this->addPostParameter('CURRENCYCODE', $invoice->currency);
     // @todo
     $this->addPostParameter('EXPDATE', $cc->getExpire("%02d20%02d"));
     $this->addPostParameter('CVV2', $cc->getCvv());
     $this->addPostParameter('FIRSTNAME', $cc->cc_name_f);
     $this->addPostParameter('LASTNAME', $cc->cc_name_l);
     $this->addPostParameter('STREET', $cc->cc_street);
     $this->addPostParameter('CITY', $cc->cc_city);
     $this->addPostParameter('STATE', $cc->cc_state);
     $this->addPostParameter('ZIP', $cc->cc_zip);
     $this->addPostParameter('PHONENUM', $cc->cc_phone);
     $this->addPostParameter('COUNTRYCODE', strtoupper($cc->cc_country));
     $this->addPostParameter('EMAIL', $invoice->getEmail());
     return $this;
 }
Example #6
0
 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();
         $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 = $cc->cc_name_f;
         $ps->x_Last_Name = $cc->cc_name_l;
         $ps->x_Address = $cc->cc_street;
         $ps->x_City = $cc->cc_city;
         $ps->x_State = $cc->cc_state;
         $ps->x_Country = $cc->cc_country;
         $ps->x_Zip = $cc->cc_zip;
         $ps->x_Tax = $doFirst ? $invoice->first_tax : $invoice->second_tax;
         $ps->x_Email = $user->email;
         $ps->x_Phone = $cc->cc_phone;
         $ps->x_Auth_Code = $cc->getCvv();
         $ps->x_Card_Code = $cc->getCvv();
         $ps->x_Amount = $doFirst ? $invoice->first_total : $invoice->second_total;
         $ps->x_Currency_Code = $invoice->currency;
         $ps->x_Card_Num = $cc->cc_number;
         $ps->x_Exp_Date = $cc->cc_expire;
         $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';
         $request->addPostParameter((array) $ps);
         $request = $this->_sendRequest($request);
         $transaction = new Am_Paysystem_Transaction_AuthorizeAim_Payment($this, $invoice, $request, $doFirst);
         $transaction->run($result);
     }
 }
Example #7
0
 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);
     }
 }
Example #8
0
 public function storeCreditCard(CcRecord $cc, Am_Paysystem_Result $result)
 {
     $user = $this->getDi()->userTable->load($cc->user_id);
     $clientId = $user->data()->get(self::CLIENT_ID);
     if ($this->invoice) {
         // to link log records with current invoice
         $invoice = $this->invoice;
     } else {
         // updating credit card info?
         $invoice = $this->getDi()->invoiceRecord;
         $invoice->invoice_id = 0;
         $invoice->user_id = $user->pk();
     }
     // compare stored cc for that user may be we don't need to refresh?
     if ($clientId && $cc->cc_number != '0000000000000000') {
         $storedCc = $this->getDi()->ccRecordTable->findFirstByUserId($user->pk());
         if ($storedCc && ($storedCc->cc != $cc->maskCc($cc->cc_number) || $storedCc->cc_expire != $cc->cc_expire)) {
             $user->data()->set(self::CLIENT_ID, null)->update();
             $clientId = null;
         }
     }
     if (!$clientId) {
         try {
             $tr = new Am_Paysystem_Transaction_Securepaycomau_CreateCustomerProfile($this, $invoice, $cc);
             $tr->run($result);
             if (!$result->isSuccess()) {
                 return;
             }
             $user->data()->set(self::CLIENT_ID, $tr->getClientId())->update();
         } catch (Am_Exception_Paysystem $e) {
             $result->setFailed($e->getPublicError());
             return false;
         }
     }
     ///
     $cc->cc = $cc->maskCc(@$cc->cc_number);
     $cc->cc_number = '0000000000000000';
     if ($cc->pk()) {
         $cc->update();
     } else {
         $cc->replace();
     }
     $result->setSuccess();
 }
Example #9
0
 function setCcRecord(CcRecord $cc)
 {
     $this->request->addPostParameter(array('ACCT' => $cc->cc_number, 'EXPDATE' => $cc->cc_expire, 'BILLTOFIRSTNAME' => $cc->cc_name_f, 'BILLTOLASTNAME' => $cc->cc_name_l, 'BILLTOSTREET' => $cc->cc_street, 'BILLTOCITY' => $cc->cc_city, 'BILLTOSTATE' => $cc->cc_state, 'BILLTOZIP' => $cc->cc_zip, 'BILLTOCOUNTRY' => $cc->cc_country, 'CVV2' => $cc->getCvv()));
 }
Example #10
0
 public function toCcRecord(CcRecord $cc)
 {
     $values = $this->getValue();
     foreach ($values as $k => $v) {
         if (is_array($v) && !empty($v['m'])) {
             $values[$k] = sprintf('%02d%02d', $v['m'], substr($v['y'], -2));
         }
     }
     unset($values['_cc_bin_name']);
     unset($values['_cc_bin_phone']);
     unset($values['a']);
     unset($values['id']);
     if (!empty($values['cc_code'])) {
         $cc->setCvv($values['cc_code']);
     }
     unset($values['cc_code']);
     unset($values['action']);
     $cc->setForInsert($values);
 }
 protected function setCcRecord(CcRecord $cc)
 {
     $this->request->addPostParameter('ccnumber', $cc->cc_number);
     $this->request->addPostParameter('ccexp', $cc->cc_expire);
     $this->request->addPostParameter('cvv', $cc->getCvv());
     $this->request->addPostParameter('firstname', $cc->cc_name_f);
     $this->request->addPostParameter('lastname', $cc->cc_name_l);
     $this->request->addPostParameter('address1', $cc->cc_street);
     $this->request->addPostParameter('city', $cc->cc_city);
     $this->request->addPostParameter('state', $cc->cc_state);
     $this->request->addPostParameter('zip', $cc->cc_zip);
     $this->request->addPostParameter('country', $cc->cc_country);
     $this->request->addPostParameter('phone', $cc->cc_phone);
 }
Example #12
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;
 }
Example #13
0
 public function toCcRecord(CcRecord $cc)
 {
     $values = $this->getValue();
     $values['cc_expire'] = '1299';
     unset($values['_cc_bin_name']);
     unset($values['_cc_bin_phone']);
     unset($values['a']);
     unset($values['id']);
     unset($values['cc_code']);
     unset($values['action']);
     $values['cc_number'] = $values['account_number'] . '-' . $values['routing_number'];
     unset($values['account_number']);
     unset($values['routing_number']);
     $cc->setForInsert($values);
 }
Example #14
0
 protected function createXml($name)
 {
     $xml = parent::createXml($name);
     $user = $this->invoice->getUser();
     $xml->customerProfileId = $user->data()->get(Am_Paysystem_AuthorizeCim::USER_PROFILE_KEY);
     if ($this->cc) {
         $xml->paymentProfile->billTo->firstName = $this->cc->cc_name_f;
         $xml->paymentProfile->billTo->lastName = $this->cc->cc_name_l;
         $xml->paymentProfile->billTo->address = $this->cc->cc_street;
         $xml->paymentProfile->billTo->city = $this->cc->cc_city;
         $xml->paymentProfile->billTo->state = $this->cc->cc_state;
         $xml->paymentProfile->billTo->zip = $this->cc->cc_zip;
         $xml->paymentProfile->billTo->country = $this->cc->cc_country;
         $xml->paymentProfile->billTo->phoneNumber = $this->cc->cc_phone;
         $xml->paymentProfile->payment->creditCard->cardNumber = $this->cc->cc_number;
         $xml->paymentProfile->payment->creditCard->expirationDate = $this->cc->getExpire('20%2$02d-%1$02d');
         if (strlen($this->cc->getCvv())) {
             $xml->paymentProfile->payment->creditCard->cardCode = $this->cc->getCvv();
         }
         $xml->validationMode = $this->getPlugin()->getConfig('validationMode', 'liveMode');
         $xml->paymentProfile->customerPaymentProfileId = $user->data()->get(Am_Paysystem_AuthorizeCim::PAYMENT_PROFILE_KEY);
     }
     return $xml;
 }
Example #15
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     $soapData = new stdClass();
     $soapData->merchantID = $this->getConfig('merchant_id');
     $soapData->merchantReferenceCode = $invoice->public_id . '/' . $invoice->getLineDescription();
     $soapData->clientLibrary = 'aMember';
     $soapData->clientLibraryVersion = '4.x';
     $soapData->clientEnvironment = php_uname();
     $soapData->customerID = $user->pk();
     $soapData->customerFirstName = $user->name_f;
     $soapData->customerLastName = $user->name_l;
     $billTo = new stdClass();
     $billTo->firstName = $cc->cc_name_f ? $cc->cc_name_f : $user->name_f;
     $billTo->lastName = $cc->cc_name_l ? $cc->cc_name_l : $user->name_l;
     $billTo->street1 = $cc->cc_street ? $cc->cc_street : $user->street;
     $billTo->city = $cc->cc_city ? $cc->cc_city : $user->city;
     $billTo->state = $cc->cc_state ? $cc->cc_state : $user->state;
     $billTo->postalCode = $cc->cc_zip ? $cc->cc_zip : $user->zip;
     $billTo->country = $cc->cc_country ? $cc->cc_country : $user->country;
     $billTo->email = $user->email;
     $billTo->ipAddress = $this->getDi()->request->getClientIp();
     $soapData->billTo = $billTo;
     $card = new stdClass();
     $card->accountNumber = $cc->cc_number;
     $card->expirationMonth = substr($cc->cc_expire, 0, 2);
     $card->expirationYear = 2000 + substr($cc->cc_expire, 2, 2);
     $card->cvNumber = $cc->getCvv();
     $soapData->card = $card;
     $purchaseTotals = new stdClass();
     $purchaseTotals->currency = $invoice->currency;
     $soapData->purchaseTotals = $purchaseTotals;
     $soapData->item = array();
     $id = 0;
     foreach ($invoice->getItems() as $item) {
         $itm = new stdClass();
         $itm->unitPrice = $doFirst ? (double) $invoice->first_total ? $item->first_total : 1.0 : $item->second_total;
         $itm->quantity = $item->qty;
         $itm->id = $id++;
         $soapData->item[] = $itm;
     }
     if ($doFirst && !(double) $invoice->first_total) {
         $ccAuthService = new stdClass();
         $ccAuthService->run = "true";
         $soapData->ccAuthService = $ccAuthService;
         $trAuth = new Am_Paysystem_Transaction_CreditCard_Cybersource_Auth($this, $invoice, $doFirst, $soapData);
         $trAuth->run($result);
         $requestId = $trAuth->getRequestId();
         $requestToken = $trAuth->getToken();
         if (!$requestId || !$requestToken) {
             return $result->setFailed(array("CyberSource Plugin: Bad auth response."));
         }
         $soapData->ccAuthService = null;
         $ccAuthReversalService = new stdClass();
         $ccAuthReversalService->authRequestID = $requestId;
         $ccAuthReversalService->authRequestToken = $requestToken;
         $ccAuthReversalService->run = "true";
         $soapData->ccAuthReversalService = $ccAuthReversalService;
         $trVoid = new Am_Paysystem_Transaction_CreditCard_Cybersource_Auth($this, $invoice, $doFirst, $soapData);
         $trVoid->run($result);
         $trFree = new Am_Paysystem_Transaction_Free($this);
         $trFree->setInvoice($invoice);
         $trFree->process();
         $result->setSuccess($trFree);
     } else {
         $ccCreditService = new stdClass();
         $ccCreditService->run = "true";
         $soapData->ccCreditService = $ccCreditService;
         $tr = new Am_Paysystem_Transaction_CreditCard_Cybersource($this, $invoice, $doFirst, $soapData);
         $tr->run($result);
     }
 }
 protected function createXml($name)
 {
     $xml = parent::createXml($name);
     $user = $this->invoice->getUser();
     $xml->profile->merchantCustomerId = $this->plugin->getMerchantCustomerId($this->cc->user_id);
     $xml->profile->description = "Username: {$user->login}";
     $xml->profile->email = $user->email;
     $xml->profile->paymentProfiles->billTo->firstName = $this->cc->cc_name_f;
     $xml->profile->paymentProfiles->billTo->lastName = $this->cc->cc_name_l;
     $xml->profile->paymentProfiles->billTo->address = $this->cc->cc_street;
     $xml->profile->paymentProfiles->billTo->city = $this->cc->cc_city;
     $xml->profile->paymentProfiles->billTo->state = $this->cc->cc_state;
     $xml->profile->paymentProfiles->billTo->zip = $this->cc->cc_zip;
     $xml->profile->paymentProfiles->billTo->country = $this->cc->cc_country;
     $xml->profile->paymentProfiles->billTo->phoneNumber = $this->cc->cc_phone;
     $xml->profile->paymentProfiles->payment->creditCard->cardNumber = $this->cc->cc_number;
     $xml->profile->paymentProfiles->payment->creditCard->expirationDate = $this->cc->getExpire('20%2$02d-%1$02d');
     if (strlen($this->cc->getCvv())) {
         $xml->profile->paymentProfiles->payment->creditCard->cardCode = $this->cc->getCvv();
     }
     $xml->validationMode = 'liveMode';
     return $xml;
 }