/** * Retrieve the PDF version of an invoice */ public static function getInvoicePdf($invoiceNumber, $locale = null, $client = null) { $uri = self::uriForInvoice($invoiceNumber); if (is_null($client)) { $client = new Recurly_Client(); } return $client->getPdf($uri, $locale); }
/** * Retrieve the PDF version of an invoice */ public static function getInvoicePdf($invoiceNumber, $locale = null, $client = null) { $uri = Recurly_Client::PATH_INVOICES . '/' . rawurlencode($invoiceNumber); if (is_null($client)) { $client = new Recurly_Client(); } return $client->getPdf($uri, $locale); }
/** * Delete the URI, validate the response and return the object. * @param string Resource URI, if not fully qualified, the base URL will be appended * @param string Optional client for the request, useful for mocking the client */ protected static function _delete($uri, $client = null) { if (is_null($client)) $client = new Recurly_Client(); $response = $client->request(Recurly_Client::DELETE, $uri); $response->assertValidResponse(); if ($response->body) { return Recurly_Base::__parseXmlToNewObject($response->body, $client); } return null; }
/** * Post to the URI, validate the response and return the object. * @param string Resource URI, if not fully qualified, the base URL will be appended * @param string Data to post to the URI * @param string Optional client for the request, useful for mocking the client */ protected static function _post($uri, $data = null, $client = null) { if (is_null($client)) { $client = new Recurly_Client(); } $response = $client->request(Recurly_Client::POST, $uri, $data); $response->assertValidResponse(); $object = Recurly_Base::__parseXmlToNewObject($response->body, $client); $response->assertSuccessResponse($object); return $object; }
/** * Requests a PDF document from the given URI * * @param string $uri Target URI for this request (relative to the API root) * @param string $locale Locale for the PDF invoice (e.g. "en-GB", "en-US", "fr") * @return string $response PDF document */ public function getPdf($uri, $locale = null) { if (substr($uri, 0, 4) != 'http') { $uri = $this->baseUri() . $uri; } if (is_null($locale)) { $locale = $this->_acceptLanguage; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_MAXREDIRS, 1); curl_setopt($ch, CURLOPT_HEADER, FALSE); // do not return headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/pdf', Recurly_Client::__userAgent(), 'Accept-Language: ' . $locale)); curl_setopt($ch, CURLOPT_USERPWD, $this->apiKey()); $response = curl_exec($ch); if ($response === false) { $errorNumber = curl_errno($ch); $message = curl_error($ch); curl_close($ch); $this->_raiseCurlError($errorNumber, $message); } curl_close($ch); return $response; }
/** * Add new payment into database * * @author coeus solutions * @param array $data the data from REST Client * @return \Zend\View\Model\JsonModel */ public function create($data = array()) { try { $exist = $this->getService()->checkAlreadySubscribed($data['customer_id']); if (!$exist) { \Recurly_Client::$subdomain = 'incoverage123'; \Recurly_Client::$apiKey = '1087e99b0df34eb4835412e55217dc6f'; $account_code = uniqid(); // Subscription $subscription = new \Recurly_Subscription(); $subscription->plan_code = 'basic'; $subscription->currency = 'USD'; $account = new \Recurly_Account(); //$subscription->account->account_code = 'john_rambo'; $account->account_code = $account_code; $account->first_name = $data['first_name']; $account->last_name = $data['last_name']; $account->email = '*****@*****.**'; $account->address->city = $data['city']; $account->address->state = $data['state']; $account->address->country = $data['country']; $account->address->zip = $data['postal_code']; $account->address->address1 = $data['address1']; $account->create(); // Billing Infos $billing_info = new \Recurly_BillingInfo(); $billing_info->account_code = $account_code; //$billing_info->first_name = $data['first_name']; //$billing_info->last_name = $data['last_name']; //$billing_info->number = $data['number']; //$billing_info->verification_value = '123'; //$billing_info->month = $data['month']; //$billing_info->year = $data['year']; $billing_info->token_id = $data['token']; $account->billing_info = $billing_info; $subscription->account = $account; $subscription->create(); $info = array('customerId' => $data['customer_id'], 'accountCode' => $account_code, 'planCode' => 'basic'); $this->getService()->addPayment($info); /*// Adjustments $charge = new \Recurly_Adjustment(); $charge->account_code = $account_code; $charge->description = 'Charge for extra bandwidth'; $charge->unit_amount_in_cents = 5000; // $50.00 $charge->currency = 'USD'; $charge->quantity = 1; $charge->accounting_code = 'bandwidth'; $charge->tax_exempt = false; $charge->create();*/ //$billing_info->create(); } else { $error = 'Already subscribed.'; } } catch (\Recurly_NotFoundError $e) { $error = $e->getMessage(); } catch (\Recurly_ValidationError $e) { // If there are multiple errors, they are comma delimited: //$messages = explode(',', $e->getMessage()); //print 'Validation problems: ' . implode("\n", $messages); $error = $e->getMessage(); } catch (\Recurly_ServerError $e) { $error = $e->getMessage(); } catch (Exception $e) { // Assign the error message and use it to handle any customer // messages or logging $error = $e->getMessage(); } if (isset($error)) { $result['data']['status'] = false; $result['data']['error'] = $error; } else { $result['data']['status'] = true; } return new JsonModel($result); }
<?php // echo phpversion(); // echo "<br>"; // header('Content-Type: text/plain'); // require_once('settings.inc'); require_once 'modules/api_handler.inc'; require_once 'modules/GoogleAPI.php'; require_once 'twitteroauth/twitteroauth.php'; require_once 'twitteroauth/config.php'; require_once dirname(__DIR__) . '/vendor/recurly_lib/recurly.php'; require_once 'modules/simple_html_dom.php'; Recurly_Client::$subdomain = RECURLY_SUB_DOMAIN; Recurly_Client::$apiKey = RECURLY_API_KEY; $api = new ApiHandler(); // Try to setup our session // Utilities::eClincherSetupUserSession(); // For analytics/backtracing $bt = debug_backtrace(); $log_response_to_ec_error_handler = false; array_shift($bt); $ajax_time_started = microtime(TRUE); $ajax_label = 'Unknown'; if ($log_response_to_ec_error_handler) { ob_start(); } // Detect and respond to our users that we're in maintenance mode > 1 if (ECConfig::get('MAINTENANCE_MODE') > 1) { // echo "Reload page"; echo file_get_contents(ROOT_PATH . '/web/maintenance.html'); exit;
* billing cycle set "include_monthly" to false. * * this system does require that you define database configuration here * * This runs outside of CI and Wordpress to mitigate conflicts with the cron on Rackspace Cloud * this utility is meant to be run from the OS php cron not from an HTTP cron. * * @magicandmight */ if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); } include_once __DIR__ . '/_siteconfig.php'; include_once __DIR__ . '/lib/recurly.php'; Recurly_Client::$subdomain = RECURLY_SUBDOMAIN; Recurly_Client::$apiKey = RECURLY_API_PASSWORD; // database configuration $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db(DB_NAME, $con); // invoicing configuration $include_monthly = TRUE; $no_charges = ""; $charges = ""; $msg = ""; // begin routine error_log("Starting Daily Invoice Routine", 0); $sql = "select * from subscription_sync;"; $results = mysql_query($sql);
<?php Autoloader::map(array('Recurly' => __DIR__ . '/lib/recurly.php')); // include require_once __DIR__ . '/lib/recurly.php'; // load config $config = Config::get('recurly'); Recurly_Client::$apiKey = $config['api_key']; if (isset($config['private_key'])) { Recurly_js::$privateKey = $config['private_key']; }