break; } else { $this->success = false; $this->error = true; break; } $count++; } } public function createAccount() { $this->xml = "<?xml version='1.0' encoding='utf-8'?>\r\t\t <ARBCreateSubscriptionRequest xmlns='AnetApi/xml/v1/schema/AnetApiSchema.xsd'>\r\t\t <merchantAuthentication>\r\t\t <name>" . $this->params['login'] . "</name>\r\r\t\t <transactionKey>" . $this->params['transkey'] . "</transactionKey>\r\r\t\t </merchantAuthentication>\r\r\t\t <refId>" . $this->params['refID'] . "</refId>\r\r\t\t <subscription>\r\r\t\t <name>" . $this->params['subscrName'] . "</name>\r\r\t\t <paymentSchedule>\r\r\t\t <interval>\r\r\t\t <length>" . $this->params['interval_length'] . "</length>\r\r\t\t <unit>" . $this->params['interval_unit'] . "</unit>\r\r\t\t </interval>\r\r\t\t <startDate>" . $this->params['startDate'] . "</startDate>\r\r\t\t <totalOccurrences>" . $this->params['totalOccurrences'] . "</totalOccurrences>\r\r\t\t <trialOccurrences>" . $this->params['trialOccurrences'] . "</trialOccurrences>\r\r\t\t </paymentSchedule>\r\r\t\t <amount>" . $this->params['amount'] . "</amount>\r\r\t\t <trialAmount>" . $this->params['trialAmount'] . "</trialAmount>\r\r\t\t <payment>\r\r\t\t <creditCard>\r\r\t\t <cardNumber>" . $this->params['cardNumber'] . "</cardNumber>\r\r\t\t <expirationDate>" . $this->params['expirationDate'] . "</expirationDate>\r\r\t\t <cardCode>" . $this->params['cardCode'] . "</cardCode>\r\r\t\t </creditCard>\r\r\t\t </payment>\r\r\t\t <order>\r\r\t\t <invoiceNumber>" . $this->params['orderInvoiceNumber'] . "</invoiceNumber>\r\r\t\t <description>" . $this->params['orderDescription'] . "</description>\r\r\t\t </order>\r\r\t\t <customer>\r\r\t\t <id>" . $this->params['customerId'] . "</id>\r\r\t\t <email>" . $this->params['customerEmail'] . "</email>\r\r\t\t <phoneNumber>" . $this->params['customerPhoneNumber'] . "</phoneNumber>\r\r\t\t <faxNumber>" . $this->params['customerFaxNumber'] . "</faxNumber>\r\r\t\t </customer>\r\r\t\t <billTo>\r\r\t\t <firstName>" . $this->params['firstName'] . "</firstName>\r\r\t\t <lastName>" . $this->params['lastName'] . "</lastName>\r\r\t\t <address>" . $this->params['address'] . "</address>\r\r\t\t <city>" . $this->params['city'] . "</city>\r\r\t\t <state>" . $this->params['state'] . "</state>\r\r\t\t <zip>" . $this->params['zip'] . "</zip>\r\r\t\t </billTo>\r\r\t\t </subscription>\r\r\t\t </ARBCreateSubscriptionRequest>";
function parse_return($content) { $refId = OSECONNECTOR::substring_between($content, '<refId>', '</refId>'); $resultCode = OSECONNECTOR::substring_between($content, '<resultCode>', '</resultCode>'); $code = OSECONNECTOR::substring_between($content, '<code>', '</code>'); $text = OSECONNECTOR::substring_between($content, '<text>', '</text>'); $subscriptionId = OSECONNECTOR::substring_between($content, '<subscriptionId>', '</subscriptionId>'); $Status = OSECONNECTOR::substring_between($content, '<Status>', '</Status>'); if (!empty($Status)) { return array($refId, $resultCode, $code, $text, $subscriptionId, $Status); } else { return array($refId, $resultCode, $code, $text, $subscriptionId); } }
function BeanStreamDeleteProfile($orderInfo, $params = array()) { require_once OSEMSC_B_LIB . DS . 'class.connection.php'; //$orderInfo = oseRegistry::call('payment')->getOrder(array('order_id'=>319),'obj'); $pConfig = oseRegistry::call('msc')->getConfig('payment', 'obj'); $merchant_id = $pConfig->beanstream_merchant_id; $passcode = $pConfig->beanstream_passcode; $orderInfoParams = oseJson::decode($orderInfo->params); $postVar = array(); $postVar['serviceVersion'] = '1.0'; $postVar['operationType'] = 'M'; $postVar['merchantId'] = $merchant_id; $postVar['passcode'] = $passcode; $postVar['rbAccountID'] = $orderInfo->payment_serial_number; $postVar['rbBillingState'] = 'C'; $postVar['processBackPayments'] = '0'; $postVar['ref5'] = ''; $hostname = 'www.beanstream.com'; $workstring = http_build_query($postVar); $uri = "/scripts/recurring_billing.asp"; $res = OSECONNECTOR::send_request_via_fsockopen($hostname, $uri, $workstring, 'urlencoded'); $res = stristr($res, "\r\n\r\n"); $res = trim($res); //$post = array(); //parse_str($res,$post); $result = array(); $code = OSECONNECTOR::substring_between($res, '<code>', '</code>'); $message = OSECONNECTOR::substring_between($res, '<message>', '</message>'); $result['success'] = $code == 1 ? true : false; $result['title'] = JText::_('Cancel'); $result['content'] = $code == 1 ? JText::_('Your membership subscription is cancelled.') : JText::_('Error') . ':' . $message; return $result; }
private function eWayRebillAPIConnect($eWayCustomerID, $eWayUsername, $eWayPassword = null, $test_mode = true, $postVar, $rebill = true) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'class.connection.php'; //$pConfig= oseMscConfig :: getConfig('payment', 'obj'); //if(!isset($pConfig->cc_testmode) || $pConfig->cc_testmode == true) { // $test_mode= true; //} else { // $test_mode= false; //} //$eWayCustomerID= $pConfig->eWayCustomerID; //$eWayUsername= $pConfig->eWayUsername; //$eWayPassword= $pConfig->eWayPassword; // Double check, not quite necessary, just in case; //if($test_mode == false && empty($eWayCustomerID) || empty($eWayUsername)) { // return false; //} $API_Endpoint = 'www.eway.com.au'; if ($test_mode == true) { //$eWayCustomerID = '87654321'; //$eWayUsername = '******'; //$eWayPassword = '******'; $API_Path = '/gateway/rebill/test/Upload_test.aspx'; } else { $API_Path = '/gateway/rebill/upload.aspx'; } $xmlRequest = "<RebillUpload>\n" . "<NewRebill>\n" . "<eWayCustomerID>" . $eWayCustomerID . "</eWayCustomerID>\n" . "<Customer>\n" . "<CustomerRef>" . $postVar['CustomerRef'] . "</CustomerRef>\n" . "<CustomerTitle></CustomerTitle>\n" . "<CustomerFirstName>" . $postVar['CustomerFirstName'] . "</CustomerFirstName>\n" . "<CustomerLastName>" . $postVar['CustomerLastName'] . "</CustomerLastName>\n" . "<CustomerCompany></CustomerCompany>\n" . "<CustomerJobDesc></CustomerJobDesc>\n" . "<CustomerEmail>" . $postVar['CustomerEmail'] . "</CustomerEmail>\n" . "<CustomerAddress>" . $postVar['CustomerAddress'] . " St</CustomerAddress>\n" . "<CustomerSuburb></CustomerSuburb>\n" . "<CustomerState>" . $postVar['CustomerState'] . "</CustomerState>\n" . "<CustomerPostCode>" . $postVar['CustomerPostCode'] . "</CustomerPostCode>\n" . "<CustomerCountry>" . $postVar['CustomerCountry'] . "</CustomerCountry>\n" . "<CustomerPhone1></CustomerPhone1>\n" . "<CustomerPhone2></CustomerPhone2>\n" . "<CustomerFax></CustomerFax>\n" . "<CustomerURL></CustomerURL>\n" . "<CustomerComments></CustomerComments>\n" . "</Customer>\n" . "<RebillEvent>\n" . "<RebillInvRef>" . $postVar['RebillInvRef'] . "</RebillInvRef>\n" . "<RebillInvDesc>" . $postVar['RebillInvDesc'] . "</RebillInvDesc>\n" . "<RebillCCName>" . $postVar['RebillCCName'] . "</RebillCCName>\n" . "<RebillCCNumber>" . $postVar['RebillCCNumber'] . "</RebillCCNumber>\n" . "<RebillCCExpMonth>" . $postVar['RebillCCExpMonth'] . "</RebillCCExpMonth>\n" . "<RebillCCExpYear>" . $postVar['RebillCCExpYear'] . "</RebillCCExpYear>\n" . "<RebillInitAmt>" . $postVar['RebillInitAmt'] . "</RebillInitAmt>\n" . "<RebillInitDate>" . $postVar['RebillInitDate'] . "</RebillInitDate>" . "<RebillRecurAmt>" . $postVar['RebillRecurAmt'] . "</RebillRecurAmt>\n" . "<RebillStartDate>" . $postVar['RebillStartDate'] . "</RebillStartDate>\n" . "<RebillInterval>" . $postVar['RebillInterval'] . "</RebillInterval>\n" . "<RebillIntervalType>" . $postVar['RebillIntervalType'] . "</RebillIntervalType>\n" . "<RebillEndDate>" . $postVar['RebillEndDate'] . "</RebillEndDate>\n" . "</RebillEvent>\n" . "</NewRebill>\n" . "</RebillUpload>"; $response = OSECONNECTOR::send_request_via_fsockopen($API_Endpoint, $API_Path, $xmlRequest); $resArray = self::parseResponse($response, $rebill); return $resArray; }
private function PaypalAPIConnect($postString) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'class.connection.php'; $pConfig = oseMscConfig::getConfig('payment', 'obj'); $test_mode = $pConfig->paypal_testmode; $API_UserName = $pConfig->paypal_api_username; $API_Password = $pConfig->paypal_api_passwd; $API_Signature = $pConfig->paypal_api_signature; $subject = ''; if (empty($API_UserName) || empty($API_Password) || empty($API_Signature)) { return false; } define('VERSION', '64.0'); define('ACK_SUCCESS', 'SUCCESS'); define('ACK_SUCCESS_WITH_WARNING', 'SUCCESSWITHWARNING'); if ($test_mode == true) { $API_Endpoint = 'api-3t.sandbox.paypal.com'; $Paypal_URL = 'https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token='; } else { $API_Endpoint = 'api-3t.paypal.com'; $Paypal_URL = 'https://www.paypal.com/webscr&cmd=_express-checkout&token='; } $postVar['PWD'] = $API_Password; $postVar['USER'] = $API_UserName; $postVar['SIGNATURE'] = $API_Signature; $postVar['VERSION'] = VERSION; $postHead = ''; foreach ($postVar as $key => $val) { $postHead .= "&" . urlencode($key) . "=" . $val; } $postString = $postString . $postHead; $response = OSECONNECTOR::send_request_via_fsockopen($API_Endpoint, '/nvp', $postString, 'urlencoded'); $resArray = self::parseResults($response); $resArray["Paypal_URL"] = $Paypal_URL; return $resArray; }
private function eWayRebillAPIConnect($eWayCustomerID, $eWayUsername, $eWayPassword = null, $test_mode = true, $postVar, $rebill = true) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'class.connection.php'; $API_Endpoint = 'www.eway.com.au'; if ($test_mode == true) { $API_Path = '/gateway/rebill/test/Upload_test.aspx'; } else { $API_Path = '/gateway/rebill/upload.aspx'; } $xmlRequest = "<RebillUpload>\n" . "<NewRebill>\n" . "<eWayCustomerID>" . $eWayCustomerID . "</eWayCustomerID>\n" . "<Customer>\n" . "<CustomerRef>" . $postVar['CustomerRef'] . "</CustomerRef>\n" . "<CustomerTitle></CustomerTitle>\n" . "<CustomerFirstName>" . $postVar['CustomerFirstName'] . "</CustomerFirstName>\n" . "<CustomerLastName>" . $postVar['CustomerLastName'] . "</CustomerLastName>\n" . "<CustomerCompany></CustomerCompany>\n" . "<CustomerJobDesc></CustomerJobDesc>\n" . "<CustomerEmail>" . $postVar['CustomerEmail'] . "</CustomerEmail>\n" . "<CustomerAddress>" . $postVar['CustomerAddress'] . " St</CustomerAddress>\n" . "<CustomerSuburb></CustomerSuburb>\n" . "<CustomerState>" . $postVar['CustomerState'] . "</CustomerState>\n" . "<CustomerPostCode>" . $postVar['CustomerPostCode'] . "</CustomerPostCode>\n" . "<CustomerCountry>" . $postVar['CustomerCountry'] . "</CustomerCountry>\n" . "<CustomerPhone1></CustomerPhone1>\n" . "<CustomerPhone2></CustomerPhone2>\n" . "<CustomerFax></CustomerFax>\n" . "<CustomerURL></CustomerURL>\n" . "<CustomerComments></CustomerComments>\n" . "</Customer>\n" . "<RebillEvent>\n" . "<RebillInvRef>" . $postVar['RebillInvRef'] . "</RebillInvRef>\n" . "<RebillInvDesc>" . $postVar['RebillInvDesc'] . "</RebillInvDesc>\n" . "<RebillCCName>" . $postVar['RebillCCName'] . "</RebillCCName>\n" . "<RebillCCNumber>" . $postVar['RebillCCNumber'] . "</RebillCCNumber>\n" . "<RebillCCExpMonth>" . $postVar['RebillCCExpMonth'] . "</RebillCCExpMonth>\n" . "<RebillCCExpYear>" . $postVar['RebillCCExpYear'] . "</RebillCCExpYear>\n" . "<RebillInitAmt>" . $postVar['RebillInitAmt'] . "</RebillInitAmt>\n" . "<RebillInitDate>" . $postVar['RebillInitDate'] . "</RebillInitDate>" . "<RebillRecurAmt>" . $postVar['RebillRecurAmt'] . "</RebillRecurAmt>\n" . "<RebillStartDate>" . $postVar['RebillStartDate'] . "</RebillStartDate>\n" . "<RebillInterval>" . $postVar['RebillInterval'] . "</RebillInterval>\n" . "<RebillIntervalType>" . $postVar['RebillIntervalType'] . "</RebillIntervalType>\n" . "<RebillEndDate>" . $postVar['RebillEndDate'] . "</RebillEndDate>\n" . "</RebillEvent>\n" . "</NewRebill>\n" . "</RebillUpload>"; $response = OSECONNECTOR::send_request_via_fsockopen($API_Endpoint, $API_Path, $xmlRequest); $resArray = self::parseResponse($response, $rebill); return $resArray; }
public function process($retries = 1) { $this->prepareParameters(); //build the post string $poststring = ''; foreach ($this->params as $key => $val) { if ($key == "x_card_num") { $poststring .= urlencode($key) . "=" . $val . "&"; } else { $poststring .= urlencode($key) . "=" . urlencode($val) . "&"; } } $count = 0; while ($count < $retries) { // strip off trailing ampersand $poststring = substr($poststring, 0, -1); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'class.connection.php'; $this->response = OSECONNECTOR::send_request_via_fsockopen($this->url, '/gateway/transact.dll', $poststring); $this->parseResults(); if ($this->getResultResponseFull() == "Approved") { $this->approved = true; $this->declined = false; $this->error = false; break; } else { if ($this->getResultResponseFull() == "Declined") { $this->approved = false; $this->declined = true; $this->error = false; break; } } $count++; } }