Removed 3rd Party Web Service Support.
* These scripts will eventually pop up in another git repository, they just don't belong in the core of PICKLES.
This commit is contained in:
parent
55f1b2b8df
commit
e38803641e
10 changed files with 0 additions and 803 deletions
|
@ -1,228 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Authorize.Net Advanced Integrated Method (AIM) Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* Authorize.Net Advanced Integrated Method (AIM) Web Service
|
||||
*/
|
||||
class WebService_AuthorizeNet_AIM extends WebService_Common {
|
||||
|
||||
private $test_url = 'https://test.authorize.net/gateway/transact.dll';
|
||||
private $prod_url = 'https://secure.authorize.net/gateway/transact.dll';
|
||||
|
||||
private $test_login = '7wYB5c6R';
|
||||
private $test_transaction_key = '4px54kx6ZZ7489Gq';
|
||||
|
||||
private $response_variables = array(
|
||||
'response_code',
|
||||
'response_subcode',
|
||||
'response_reason_code',
|
||||
'response_reason_text',
|
||||
'authorization_code',
|
||||
'avs_response',
|
||||
'transaction_id',
|
||||
'invoice_number',
|
||||
'description',
|
||||
'amount',
|
||||
'method',
|
||||
'transaction_type',
|
||||
'customer_id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'company',
|
||||
'address',
|
||||
'city',
|
||||
'state',
|
||||
'zip_code',
|
||||
'country',
|
||||
'phone',
|
||||
'fax',
|
||||
'email_address',
|
||||
'ship_to_first_name',
|
||||
'ship_to_last_name',
|
||||
'ship_to_company',
|
||||
'ship_to_address',
|
||||
'ship_to_city',
|
||||
'ship_to_state',
|
||||
'ship_to_zip_code',
|
||||
'ship_to_country',
|
||||
'tax',
|
||||
'duty',
|
||||
'feight',
|
||||
'tax_exempt',
|
||||
'purchase_order_number',
|
||||
'md5_hash',
|
||||
'card_code_response',
|
||||
'cardholder_authentication_verification_response',
|
||||
'reserved'
|
||||
);
|
||||
|
||||
public function process() {
|
||||
|
||||
// Loads the API keys based on what URL is being loaded
|
||||
if (preg_match("/{$this->config->webservices->authorizenet_aim->domain}/", $_SERVER['HTTP_HOST'])) {
|
||||
$url = $this->prod_url;
|
||||
$login = $this->config->webservices->authorizenet_aim->login;
|
||||
$transaction_key = $this->config->webservices->authorizenet_aim->transaction_key;
|
||||
$test_request = 'FALSE';
|
||||
}
|
||||
else {
|
||||
$url = $this->test_url;
|
||||
$login = $this->test_login;
|
||||
$transaction_key = $this->test_transaction_key;
|
||||
$test_request = 'TRUE';
|
||||
}
|
||||
|
||||
// Assembles an array of all our transaction variables and values
|
||||
$post_variables = array(
|
||||
'x_test_request' => $test_request,
|
||||
'x_invoice_num' => $this->order_id,
|
||||
'x_cust_id' => trim($this->customer_id) != '' ? $this->customer_id : 'N/A',
|
||||
'x_cust_up' => $this->customer_ip,
|
||||
'x_description' => 'Menopause Solutions',
|
||||
'x_login' => $login,
|
||||
'x_version' => '3.1',
|
||||
'x_delim_char' => '|',
|
||||
'x_delim_data' => 'TRUE',
|
||||
'x_type' => 'AUTH_CAPTURE', // @todo let the user pass this in for more functionality
|
||||
'x_method' => 'CC',
|
||||
'x_tran_key' => $transaction_key,
|
||||
'x_relay_response' => 'FALSE',
|
||||
|
||||
// Payment information
|
||||
'x_card_num' => $this->card_number,
|
||||
'x_exp_date' => $this->expiration_month . $this->expiration_year,
|
||||
'x_amount' => $this->total_amount,
|
||||
'x_freight' => 'Shipping<|>Standard<|>' . $this->shipping,
|
||||
|
||||
// Billing address information
|
||||
'x_company' => $this->billing_company,
|
||||
'x_first_name' => $this->billing_first_name,
|
||||
'x_last_name' => $this->billing_last_name,
|
||||
'x_address' => $this->billing_address1,
|
||||
'x_city' => $this->billing_city,
|
||||
'x_state' => $this->billing_state,
|
||||
'x_zip' => $this->billing_zip_code,
|
||||
'x_country' => $this->billing_country,
|
||||
'x_email' => $this->billing_email,
|
||||
'x_phone' => $this->billing_phone,
|
||||
'x_fax' => $this->billing_fax,
|
||||
|
||||
// Shipping address information
|
||||
'x_ship_to_company' => $this->shipping_company,
|
||||
'x_ship_to_first_name' => $this->shipping_first_name,
|
||||
'x_ship_to_last_name' => $this->shipping_last_name,
|
||||
'x_ship_to_address' => $this->shipping_address1,
|
||||
'x_ship_to_city' => $this->shipping_city,
|
||||
'x_ship_to_state' => $this->shipping_state,
|
||||
'x_ship_to_zip' => $this->shipping_zip_code,
|
||||
'x_ship_to_country' => $this->shipping_country,
|
||||
|
||||
// Order information
|
||||
// @todo I'd like to change the line item stuff to be part of the array and
|
||||
// then looped through pragmatically, opposed to tacking it all to the end
|
||||
// of the transaction (see below)
|
||||
//'x_line_item' => '',
|
||||
|
||||
// Email receipt information
|
||||
'x_email_customer' => true,
|
||||
|
||||
// @todo These currently aren't in use
|
||||
// 'x_tax' => '',
|
||||
// 'se_session_token' => '',
|
||||
// 'x_header_email_receipt' => '',
|
||||
// 'x_footer_email_receipt' => '',
|
||||
|
||||
// @todo Debugging / testing information
|
||||
//'x_email' => 'joshsherman@gmail.com',
|
||||
//'x_card_num' => '4242424242424242',
|
||||
);
|
||||
|
||||
// Assembles the POSTed fields
|
||||
$fields = '';
|
||||
foreach ($post_variables as $variable => $value) {
|
||||
$fields .= $variable . '=' . urlencode($value) . '&';
|
||||
}
|
||||
|
||||
// Tacks the line items to the end of the assemble POST fields
|
||||
if (is_array($this->products)) {
|
||||
foreach ($this->products as $product_id => $product) {
|
||||
//$fields .= 'x_line_item=' . $product['sku'] . '<|>' . substr($product['name'], 0, 31) . '<|>' . substr($product['name'], 0, 255) . '<|>' . $product['quantity'] . '<|>' . $product['price'] . '<|>N&';
|
||||
$fields .= 'x_line_item=' . $product['sku'] . '<|>><|>' . substr($product['name'], 0, 255) . '<|>' . $product['quantity'] . '<|>' . $product['price'] . '<|>N&';
|
||||
}
|
||||
}
|
||||
|
||||
// POSTs the transaction to Authorize.Net
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, rtrim($fields, '& ')); // use HTTP POST to send form data
|
||||
|
||||
// @todo uncomment this line if you get no gateway response, or whatever they way
|
||||
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
// Breaks apart the response and assigns it to an associative array
|
||||
$response_values = explode('|', $response, 41);
|
||||
$response = array_combine($this->response_variables, $response_values);
|
||||
|
||||
file_put_contents('/tmp/authnet.log', print_r($response, true), FILE_APPEND);
|
||||
|
||||
// Trims all of the variables up
|
||||
// @todo Replace this with a user defined trim() and use array_walk()
|
||||
foreach ($response as $key => $value) {
|
||||
$response[$key] = trim($value);
|
||||
}
|
||||
|
||||
// Deciphers the cryptic internal response code
|
||||
// @todo case 4 is not represented
|
||||
switch ($response['response_code']) {
|
||||
case 1: $value = 'Approved'; break;
|
||||
case 2: $value = 'Declined'; break;
|
||||
default: $value = 'Error'; break;
|
||||
}
|
||||
|
||||
$response['response_code'] = $value;
|
||||
|
||||
// Deciphers the cryptic internal card code response
|
||||
switch ($response['card_code_response']) {
|
||||
case 'M': $value .= ' = Match'; break;
|
||||
case 'N': $value .= ' = No Match'; break;
|
||||
case 'P': $value .= ' = Not Processed'; break;
|
||||
case 'S': $value .= ' = Should have been present'; break;
|
||||
case 'U': $value .= ' = Issuer unable to process request'; break;
|
||||
case '': $value = 'No value returned'; break;
|
||||
default: $value .= ' = Unknown value'; break;
|
||||
}
|
||||
|
||||
$response['card_code_response'] = $value;
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Authorize.Net Customer Information Manager (CIM) Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* Authorize.Net Customer Information Manager (CIM) Web Service
|
||||
*/
|
||||
class WebService_AuthorizeNet_AIM extends WebService_Common {
|
||||
|
||||
private $loginname = "YourApiLogin"; // Keep this secure.
|
||||
private $transactionkey = "YourTransactionKey"; // Keep this secure.
|
||||
private $url = "apitest.authorize.net";
|
||||
private $path = "/xml/v1/request.api";
|
||||
|
||||
public function createCustomerProfile() { }
|
||||
public function createCustomerPaymentProfile() { }
|
||||
public function createCustomerShippingAddress() { }
|
||||
public function createCustomerProfileTransaction() { }
|
||||
public function deleteCustomerProfile() { }
|
||||
public function deleteCustomerPaymentProfile() { }
|
||||
public function deleteCustomerShippingAddress() { }
|
||||
public function getCustomerProfileIds() { }
|
||||
public function getCustomerProfile() { }
|
||||
public function getCustomerPaymentProfile() { }
|
||||
public function getCustomerShippingAddress() { }
|
||||
public function updateCustomerProfile() { }
|
||||
public function updateCustomerPaymentProfile() { }
|
||||
public function updateCustomerShippingAddress() { }
|
||||
public function validateCustomerPaymentProfile() { }
|
||||
|
||||
public function process() {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Common Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* Common Web Service Class
|
||||
*
|
||||
* This is the class that each gateway class should be extending from.
|
||||
*/
|
||||
abstract class WebService_Common extends Object {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Runs the parent's constructor and adds the module to the object.
|
||||
*/
|
||||
public function __construct(Config $config, Error $error) {
|
||||
parent::__construct();
|
||||
|
||||
$this->config = $config;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract processing function that is overloaded within the loaded gateway
|
||||
*/
|
||||
public abstract function process();
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Common PayPal Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* Common PayPal Web Service Class
|
||||
*
|
||||
* This is the class that each PayPal gateway class should be extending from.
|
||||
*/
|
||||
abstract class WebService_PayPal_Common extends WebService_Common {
|
||||
|
||||
private $test_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
|
||||
private $prod_url = 'https://www.paypal.com/cgi-bin/webscr';
|
||||
|
||||
protected $url = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Runs the parent's constructor and adds the module to the object.
|
||||
*/
|
||||
public function __construct(Config $config, Error $error) {
|
||||
parent::__construct($config, $error);
|
||||
|
||||
$this->config = $config;
|
||||
$this->error = $error;
|
||||
|
||||
$this->url = $this->test_url;
|
||||
|
||||
// @todo there is a test flag for paypal "test_ipn = 1"
|
||||
|
||||
// Loads the API keys based on what URL is being loaded
|
||||
// if (preg_match("/{$this->config->webservices->authorizenet_aim->domain}/", $_SERVER['HTTP_HOST'])) {
|
||||
// $url = $this->prod_url;
|
||||
// $login = $this->config->webservices->authorizenet_aim->login;
|
||||
// $transaction_key = $this->config->webservices->authorizenet_aim->transaction_key;
|
||||
// $test_request = 'FALSE';
|
||||
// }
|
||||
// else {
|
||||
// $url = $this->test_url;
|
||||
// $login = $this->test_login;
|
||||
// $transaction_key = $this->test_transaction_key;
|
||||
// $test_request = 'TRUE';
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract processing function that is overloaded within the loaded gateway
|
||||
*/
|
||||
//public abstract function process();
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PayPal Instant Payment Notification (IPN) Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* PayPal Instant Payment Notification (IPN) Web Service
|
||||
*/
|
||||
class WebService_PayPal_IPN extends WebService_PayPal_Common {
|
||||
|
||||
public function process() {
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PayPal Web Payments Standard (WPS) Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* PayPal Web Payments Standard (WPS) Web Service
|
||||
*/
|
||||
class WebService_PayPal_WPS extends WebService_PayPal_Common {
|
||||
|
||||
private $variables = array(
|
||||
'rm' => 2, // 2 == POST
|
||||
'cmd' => '_xclick', // _xclick-subscriptions
|
||||
);
|
||||
|
||||
public function set($variable, $value) {
|
||||
$this->variables[$variable] = $value;
|
||||
}
|
||||
|
||||
// @todo ENCRYPT FORM VIA PAYPAL ENCRYPTED WEBSITE PAYMENTS
|
||||
public function process() {
|
||||
|
||||
$form = '
|
||||
<form method="post" id="paypalRedirectForm" action="' . $this->url .'">
|
||||
<h2>Please wait while you are redirected to PayPal.</h2>
|
||||
If you are not redirected to PayPal within 5 seconds...
|
||||
';
|
||||
|
||||
// Adds all the variables to the form
|
||||
foreach ($this->variables as $variable => $value) {
|
||||
$form .= '<input type="hidden" name="' . $variable . '" value="' . $value . '" />' . "\n";
|
||||
}
|
||||
|
||||
$form .= '
|
||||
<input type="submit" value="Click Here">
|
||||
</form>
|
||||
';
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Common PennySMS Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* Common PennySMS Web Service Class
|
||||
*
|
||||
* This is the class that each PennySMS gateway class should be extending from.
|
||||
*/
|
||||
abstract class WebService_PennySMS_Common extends WebService_Common
|
||||
{
|
||||
protected $variables = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Runs the parent's constructor and adds the module to the object.
|
||||
*/
|
||||
public function __construct(Config $config, Error $error)
|
||||
{
|
||||
parent::__construct($config, $error);
|
||||
|
||||
$this->config = $config;
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variable Setter
|
||||
*
|
||||
* Loads an array full of our variables to use
|
||||
*/
|
||||
public function set($variable, $value)
|
||||
{
|
||||
$this->variables[$variable] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract processing function that is overloaded within the loaded gateway
|
||||
*/
|
||||
//public abstract function process();
|
||||
|
||||
/**
|
||||
* Check Variables
|
||||
*
|
||||
* Checks that the variables are present and non-blank
|
||||
*/
|
||||
protected function checkVariables()
|
||||
{
|
||||
$valid = false;
|
||||
|
||||
// Checks that the variables are set
|
||||
if (isset($this->variables['api_key'], $this->variables['from'], $this->variables['phone'], $this->variables['message']))
|
||||
{
|
||||
// Checks that the variables aren't empty
|
||||
if (trim($this->variables['api_key']) != '' && trim($this->variables['from']) != '' && trim($this->variables['phone']) != '' && trim($this->variables['message']) != '')
|
||||
{
|
||||
$valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PennySMS (via Email) Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* PennySMS (via Email) Web Service
|
||||
*/
|
||||
class WebService_PennySMS_Email extends WebService_PennySMS_Common
|
||||
{
|
||||
public function process()
|
||||
{
|
||||
// @todo check that API key is not null;
|
||||
// @todo check that the phone is there
|
||||
// @todo check that the message is <= 160 characters
|
||||
|
||||
$to = 'api@pennysms.com';
|
||||
$subject = 'Text Message via PennySMS (via Email)';
|
||||
$message = 'key: ' . $this->variables['api_key'] . "\n"
|
||||
. 'cell: ' . $this->variables['phone'] . "\n"
|
||||
. "\n"
|
||||
. substr($this->variables['message'], 0, 160);
|
||||
|
||||
mail($to, $subject, $message);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PennySMS (via JSON-RPC) Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* PennySMS (via JSON-RPC) Web Service
|
||||
*/
|
||||
class WebService_PennySMS_JSON extends WebService_PennySMS_Common
|
||||
{
|
||||
public function process()
|
||||
{
|
||||
// @todo check that API key is not null;
|
||||
// @todo check that the phone is there
|
||||
// @todo check that the message is <= 160 characters
|
||||
|
||||
$array = array(
|
||||
'method' => 'send',
|
||||
'params' => array(
|
||||
(string)$this->variables['api_key'],
|
||||
$this->variables['from'],
|
||||
$this->variables['phone'],
|
||||
addslashes(substr($this->variables['message'], 0, 160))
|
||||
)
|
||||
);
|
||||
|
||||
$json = json_encode($array);
|
||||
var_dump($json);
|
||||
|
||||
|
||||
$params = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-Type: text/json' . "\r\n",
|
||||
'content' => $json
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($params);
|
||||
$response = file_get_contents('http://api.pennysms.com/jsonrpc', false, $context);
|
||||
|
||||
// @todo error trapping / re-runs
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PennySMS (via XML-RPC) Web Service Class File for PICKLES
|
||||
*
|
||||
* PICKLES is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* PICKLES is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with PICKLES. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Joshua John Sherman <josh@phpwithpickles.org>
|
||||
* @copyright Copyright 2009 Joshua John Sherman
|
||||
* @link http://phpwithpickles.org
|
||||
* @license http://www.gnu.org/copyleft/lesser.html
|
||||
* @package PICKLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* PennySMS (via XML-RPC) Web Service
|
||||
*/
|
||||
class WebService_PennySMS_XML extends WebService_PennySMS_Common
|
||||
{
|
||||
public function process()
|
||||
{
|
||||
$success = false;
|
||||
|
||||
if ($this->checkVariables() === true)
|
||||
{
|
||||
$xml = '
|
||||
<?xml version="1.0"?>
|
||||
<methodCall>
|
||||
<methodName>send</methodName>
|
||||
<params>
|
||||
<param>
|
||||
<value><string>' . $this->variables['api_key'] . '</string></value>
|
||||
</param>
|
||||
<param>
|
||||
<value><string>' . $this->variables['from'] . '</string></value>
|
||||
</param>
|
||||
<param>
|
||||
<value><string>' . $this->variables['phone'] . '</string></value>
|
||||
</param>
|
||||
<param>
|
||||
<value><string>' . substr($this->variables['message'], 0, 160) . '</string></value>
|
||||
</param>
|
||||
</params>
|
||||
</methodCall>
|
||||
';
|
||||
|
||||
// Cleans up the XML before sending it
|
||||
$xml = str_replace(array("\t", "\r", "\n"), '', $xml);
|
||||
|
||||
$params = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-Type: text/xml' . "\r\n",
|
||||
'content' => $xml
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($params);
|
||||
$response = file_get_contents('http://api.pennysms.com/xmlrpc', false, $context);
|
||||
|
||||
Logger::write('pennysms', 'SENT: ' . $xml . ' RCVD: ' . trim($response));
|
||||
|
||||
if ($response == '<?xml version="1.0" ?><methodResponse><params><param><value><string>OK</string></value></param></params></methodResponse>' . "\n")
|
||||
{
|
||||
$success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue