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); }
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']); } }
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); } }
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; }
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); } }
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; }
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; }