Example #1
0
 protected function getConfig()
 {
     if (!isset($this->config)) {
         $this->config = Paymentwall_Config::getInstance();
     }
     return $this->config;
 }
Example #2
0
 public function index()
 {
     $this->language->load('payment/brick');
     $this->load->model('payment/brick');
     $this->model_payment_brick->initBrickConfig();
     $data['text_credit_card'] = $this->language->get('text_credit_card');
     $data['text_start_date'] = $this->language->get('text_start_date');
     $data['text_wait'] = $this->language->get('text_wait');
     $data['text_loading'] = $this->language->get('text_loading');
     $data['entry_cc_number'] = $this->language->get('entry_cc_number');
     $data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date');
     $data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2');
     $data['button_confirm'] = $this->language->get('button_confirm');
     $data['public_key'] = Paymentwall_Config::getInstance()->getPublicKey();
     $data['months'] = array();
     for ($i = 1; $i <= 12; $i++) {
         $data['months'][] = array('text' => sprintf('%02d', $i), 'value' => sprintf('%02d', $i));
     }
     $today = getdate();
     $data['year_expire'] = array();
     for ($i = $today['year']; $i < $today['year'] + 11; $i++) {
         $data['year_expire'][] = array('text' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)), 'value' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)));
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/brick.tpl')) {
         return $this->load->view($this->config->get('config_template') . '/template/payment/brick.tpl', $data);
     } else {
         return $this->load->view('default/template/payment/brick.tpl', $data);
     }
 }
Example #3
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
 public function __construct()
 {
     $this->id = 'paymentwall';
     $this->icon = plugins_url('paymentwall-for-woocommerce/images/icon.png');
     $this->has_fields = true;
     $this->method_title = __('Paymentwall', 'woocommerce');
     // Load the form fields.
     $this->init_form_fields();
     // Load the settings.
     $this->init_settings();
     // Load Paymentwall Merchant Information
     $this->app_key = $this->settings['appkey'];
     $this->secret_key = $this->settings['secretkey'];
     $this->widget_code = $this->settings['widget'];
     $this->description = $this->settings['description'];
     Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $this->app_key, 'private_key' => $this->secret_key));
     $this->title = 'Paymentwall';
     $this->notify_url = str_replace('https:', 'http:', add_query_arg('wc-api', 'Paymentwall_Gateway', home_url('/')));
     // Our Actions
     add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
     add_action('woocommerce_receipt_paymentwall', array($this, 'receipt_page'));
     add_action('woocommerce_api_paymentwall_gateway', array($this, 'check_ipn_response'));
 }
 /**
  * Displays credit card form
  */
 public function payment_fields()
 {
     $this->init_paymentwall_configs();
     echo $this->get_template('cc_form.html', array('payment_id' => $this->id, 'public_key' => Paymentwall_Config::getInstance()->getPublicKey(), 'entry_card_number' => __("Card number", PW_JIGO_TEXT_DOMAIN), 'entry_card_expiration' => __("Card expiration", PW_JIGO_TEXT_DOMAIN), 'entry_card_cvv' => __("Card CVV", PW_JIGO_TEXT_DOMAIN)));
 }
Example #6
0
function initPaymentwallConfigs($appKey, $appSecret)
{
    Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $appKey, 'private_key' => $appSecret));
}
 public function initPaymentwallConfig()
 {
     Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $this->config->get('paymentwall_key'), 'private_key' => $this->config->get('paymentwall_secret')));
 }
Example #8
0
 /**
  * Returns all HTML markup required to render an authorization and capture payment form
  *
  * @param array $contact_info An array of contact info including:
  *    - id The contact ID
  *    - client_id The ID of the client this contact belongs to
  *    - user_id The user ID this contact belongs to (if any)
  *    - contact_type The type of contact
  *    - contact_type_id The ID of the contact type
  *    - first_name The first name on the contact
  *    - last_name The last name on the contact
  *    - title The title of the contact
  *    - company The company name of the contact
  *    - address1 The address 1 line of the contact
  *    - address2 The address 2 line of the contact
  *    - city The city of the contact
  *    - state An array of state info including:
  *        - code The 2 or 3-character state code
  *        - name The local name of the country
  *    - country An array of country info including:
  *        - alpha2 The 2-character country code
  *        - alpha3 The 3-character country code
  *        - name The english name of the country
  *        - alt_name The local name of the country
  *    - zip The zip/postal code of the contact
  * @param float $amount The amount to charge this contact
  * @param array $invoice_amounts An array of invoices, each containing:
  *    - id The ID of the invoice being processed
  *    - amount The amount being processed for this invoice (which is included in $amount)
  * @param array $options An array of options including:
  *    - description The Description of the charge
  *    - return_url The URL to redirect users to after a successful payment
  *    - recur An array of recurring info including:
  *        - amount The amount to recur
  *        - term The term to recur
  *        - period The recurring period (day, week, month, year, onetime) used in conjunction with term in order to determine the next recurring payment
  * @return string HTML markup required to render an authorization and capture payment form
  */
 public function buildProcess(array $contact_info, $amount, array $invoice_amounts = null, array $options = null)
 {
     $this->initPaymentwallConfigs();
     $post_to = Configure::get("Blesta.gw_callback_url") . Configure::get("Blesta.company_id") . "/brick/";
     $fields = array();
     $contact = false;
     // Set contact email address and phone number
     if ($this->ifSet($contact_info['id'], false)) {
         Loader::loadModels($this, array("Contacts"));
         $contact = $this->Contacts->get($contact_info['id']);
     } else {
         return "Contact information invalid!";
     }
     $data = array('public_key' => Paymentwall_Config::getInstance()->getPublicKey(), 'amount' => $amount, 'merchant' => $this->ifSet($this->meta['merchant_name'], 'Blesta'), 'product_name' => $options['description'], 'currency' => $this->currency);
     $post_to .= "?data=" . $this->encodeData(array('client_id' => $contact->client_id, 'amount' => $amount, 'currency' => $this->currency, 'invoices' => $invoice_amounts, 'email' => $contact->email, 'description' => $options['description']));
     $this->view = $this->makeView("process", "default", str_replace(ROOTWEBDIR, "", dirname(__FILE__) . DS));
     $this->view->set("data", $data);
     $this->view->set("post_to", $post_to);
     $this->view->set("fields", $fields);
     return $this->view->fetch();
 }
Example #9
0
<?php

# Required File Includes
include "../../../init.php";
$whmcs->load_function('gateway');
$whmcs->load_function('invoice');
define('PW_WHMCS_ITEM_TYPE_HOSTING', 'Hosting');
require_once ROOTDIR . "/includes/api/paymentwall_api/lib/paymentwall.php";
$gateway = getGatewayVariables("paymentwall");
if (!$gateway["type"]) {
    die("Module Not Activated");
}
Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $gateway['appKey'], 'private_key' => $gateway['secretKey']));
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
$invoiceid = checkCbInvoiceID($pingback->getProductId(), $gateway["name"]);
if ($invoiceid && $pingback->validate()) {
    $orderData = mysql_fetch_assoc(select_query('tblorders', 'userid,id', array("invoiceid" => $invoiceid)));
    $userData = mysql_fetch_assoc(select_query('tblclients', 'email, firstname, lastname, country, address1, state, phonenumber, postcode, city, id', array("id" => $orderData['userid'])));
    if ($pingback->isDeliverable()) {
        processDeliverable($invoiceid, $pingback, $gateway, $userData, $orderData);
    } elseif ($pingback->isCancelable()) {
        // WHMCS not supported
        logTransaction($gateway["name"], $_GET, "Not Supported");
        die("Not Supported");
    } else {
        switch ($pingback->getType()) {
            /*
            case Paymentwall_Pingback::PINGBACK_TYPE_SUBSCRIPTION_EXPIRED:
            case Paymentwall_Pingback::PINGBACK_TYPE_SUBSCRIPTION_PAYMENT_FAILED:
                // Do not process transaction
                break;
Example #10
0
function fn_paymentwall_initPaymentwallSdk($projectKey, $secretKey, $apiType = Paymentwall_Config::API_GOODS)
{
    Paymentwall_Config::getInstance()->set(array('api_type' => $apiType, 'public_key' => $projectKey, 'private_key' => $secretKey));
}
Example #11
0
<?php

session_start();
header('Content-type: application/json');
require_once 'utils/bootstrap.php';
require_once '../vendor/autoload.php';
if (isset($_SESSION['projectId'])) {
    $client = new GuzzleHttp\Client();
    $res = $client->get('https://api.paymentwall.com/pwapi/merchant/application/' . $_SESSION['projectId'], ['query' => ['access_token' => $_SESSION['token'], 'version' => '1']]);
    $body = json_decode($res->getBody());
    if (preg_match('/^Digital/', $body->api_type)) {
        $api_type = 2;
    } elseif (preg_match('/^Virtual/', $body->api_type)) {
        $api_type = 1;
    } else {
        $api_type = 3;
    }
    $signatureVersion = $body->signature_version;
    unset($_SESSION['projectId']);
} else {
    $api_type = $_SESSION['apiType'];
    $key = $_SESSION['publicKey'];
    $secret = $_SESSION['secretKey'];
    $signatureVersion = $_SESSION['signatureVersion'];
}
Paymentwall_Config::getInstance()->set(array('api_type' => $api_type, 'public_key' => $key, 'private_key' => $secret));
$response_array['status'] = 'success';
// $response_array['test'] = $body;
$widget = new Paymentwall_Widget('*****@*****.**', 'p1_1', array(new Paymentwall_Product('product301', 9.99, 'USD', '1 month membership', Paymentwall_Product::TYPE_FIXED)), array('ps' => $_POST['option'], 'email' => '*****@*****.**', 'any_custom_parameter' => 'value', 'sign_version' => $signatureVersion));
$response_array['widget'] = $widget->getHtmlCode();
echo json_encode($response_array);
Example #12
0
 /**
  * Initial Paymentwall settings
  */
 public function initPaymentwallConfigs()
 {
     Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $this->meta['project_key'], 'private_key' => $this->meta['secret_key']));
 }
Example #13
0
 protected function getTestDetailsForOneTimeToken()
 {
     return array_merge(array('public_key' => Paymentwall_Config::getInstance()->getPublicKey()), $this->getTestCardDetails());
 }
<?php

// Paymentwall PHP Library: https://www.paymentwall.com/lib/php
require_once '/path/to/paymentwall-php/lib/paymentwall.php';
Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => 't_93b2b286cd0f503dfa230b364ead9e', 'private_key' => 't_2866c0e8bd75bda4ba0e9df7d855b7'));
$widget = new Paymentwall_Widget('user40012', 'p10', array(new Paymentwall_Product('product301', 9.99, 'USD', 'Gold Membership', Paymentwall_Product::TYPE_FIXED)), array('email' => '*****@*****.**', 'any_custom_parameter' => 'value'));
echo $widget->getHtmlCode();
<?php

/**
* Paymentwall widget
*
* @package paymentMethod
* @copyright Copyright 2014 Paymentwall Inc.
* @version v1.0.1
*/
require 'includes/application_top.php';
if ($_SESSION['order'] && $_SESSION['insert_id']) {
    require 'paymentwall_api/lib/paymentwall.php';
    Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => MODULE_PAYMENT_PAYMENTWALL_APP_KEY, 'private_key' => MODULE_PAYMENT_PAYMENTWALL_SECRET_KEY));
    $order = (array) unserialize(base64_decode($_SESSION['order']));
    $products_names = array();
    foreach ($order['products'] as $key => $value) {
        if (!in_array($value['name'], $products_names)) {
            array_push($products_names, $value['name']);
        }
    }
    $widget = new Paymentwall_Widget($order['customer']['email_address'], MODULE_PAYMENT_PAYMENTWALL_WIDGET_CODE, array(new Paymentwall_Product((int) $_SESSION['insert_id'], $order['info']['total'], $order['info']['currency'], implode(', ', $products_names), Paymentwall_Product::TYPE_FIXED)), array('email' => $order['customer']['email_address'], 'success_url' => strval(MODULE_PAYMENT_PAYMENTWALL_SUCCESS_URI), 'integration_module' => 'zencart', 'test_mode' => MODULE_PAYMENT_PAYMENTWALL_TEST_MODE == 'True' ? 1 : 0));
    echo $widget->getHtmlCode();
} else {
    zen_redirect('/');
}
 /**
  * Get the PaymentWall Config Instance.
  *
  * @return \Paymentwall_Config
  */
 public function getPaymentWallObject()
 {
     if (\Paymentwall_Config::getInstance()->getPublicKey() == false) {
         $this->setPaymentWallObject();
     }
     return \Paymentwall_Config::getInstance();
 }
Example #17
0
 /**
  * @Given /^Private key "([^"]*)"$/
  */
 public function privateKey($privateKey)
 {
     Paymentwall_Config::getInstance()->set(array('private_key' => $privateKey));
 }
 protected static function initPaymentwall($project_key, $secret_key)
 {
     \Paymentwall_Config::getInstance()->set(array('api_type' => \Paymentwall_Config::API_GOODS, 'public_key' => $project_key, 'private_key' => $secret_key));
 }
Example #19
0
function edd_initialize_paymentwall_lib()
{
    global $edd_options;
    require_once plugin_dir_path(__FILE__) . 'paymentwall-php/lib/paymentwall.php';
    Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $edd_options['paymentwall_application_key'], 'private_key' => $edd_options['paymentwall_secret_key']));
}
 public function paymentwall_init()
 {
     require_once 'api/lib/paymentwall.php';
     Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $this->appkey, 'private_key' => $this->secretkey));
 }
Example #21
0
<?php

/*
-------------------------------------------
              Global Settings              
-------------------------------------------
*/
$mongodb = new MongoClient("mongodb://*****:*****@localhost:12345/");
$private_var = [];
$database = [];
$settings = [];
$settings['global'] = ['base_url' => 'http://www.example.com/pay/', 'base_original_url' => 'http://original_server.example.com/pay/', 'live' => true, 'user_ip' => $_SERVER['REMOTE_ADDR']];
$private_var['private_rkey'] = 'xxx';
// Any key
Paymentwall_Config::getInstance()->set(['api_type' => Paymentwall_Config::API_GOODS, 'public_key' => 'xxx', 'private_key' => 'xxx']);
/*
-------------------------------------------
            MyOrderbox Settings            
-------------------------------------------
*/
$private_var['myorderbox'] = 'xxx';
// For MyOrderbox key
$database['myorderbox'] = $mongodb->pay->paymentwall;
$settings['myorderbox'] = ['status' => true, 'multi' => true, 'https' => 'true', 'commission' => myorderbox_commission_function, 'uni' => ['alipay' => ['key' => 'xxx', 'commission' => myorderbox_commission_alipay], 'cc' => ['key' => 'xxx', 'commission' => myorderbox_commission_function]]];
function myorderbox_commission_function($amount, $currency, $userType)
{
    return $amount * 0.027 + 0.3;
}
function myorderbox_commission_alipay($amount, $currency, $userType)
{
    return $amount * 0.12;
Example #22
0
<?php

// Paymentwall PHP Library: https://www.paymentwall.com/lib/php
require_once 'https://www.paymentwall.com/lib/php/path/to/paymentwall-php/lib/';
Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => 't_a68a575153af62c41d073d9258052c', 'private_key' => 't_fc827299dbda27447bef6e2406afe7'));
$widget = new Paymentwall_Widget('user40012', 'p10', array(new Paymentwall_Product('product301', 9.99, 'USD', 'Gold Membership', Paymentwall_Product::TYPE_FIXED)), array('email' => '*****@*****.**', 'any_custom_parameter' => 'value'));
echo $widget->getHtmlCode();
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
if ($pingback->validate()) {
    $productId = $pingback->getProduct()->getId();
    if ($pingback->isDeliverable()) {
        // deliver the product
    } else {
        if ($pingback->isCancelable()) {
            // withdraw the product
        }
    }
    echo 'OK';
} else {
    echo $pingback->getErrorSummary();
}
Example #23
0
<?php

require_once 'utils/bootstrap.php';
Paymentwall_Config::getInstance()->set(array('private_key' => YOUR_BRICK_PRIVATE_KEY));
$parameters = $_POST;
$cardInfo = array('email' => $parameters['email'], 'amount' => 9.99, 'currency' => 'USD', 'token' => $parameters['brick_token'], 'fingerprint' => $parameters['brick_fingerprint'], 'description' => 'Order #123');
$charge = new Paymentwall_Charge();
$charge->create($cardInfo);
$response = $charge->getPublicData();
if ($charge->isSuccessful()) {
    if ($charge->isCaptured()) {
        // deliver a product
    } elseif ($charge->isUnderReview()) {
        // decide on risk charge
    }
} else {
    $errors = json_decode($response, true);
}
echo $response;
<?php

require_once __DIR__ . '/../../vendor/autoload.php';
require_once 'GeoLocator.php';
require_once 'PaymentSystem.php';
Paymentwall_Config::getInstance()->set(array('api_type' => $_SESSION['apiType'], 'public_key' => $_SESSION['publicKey'], 'private_key' => $_SESSION['secretKey']));
 private function initPaymentwallConfig()
 {
     Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => Configuration::get('PAYMENTWALL_APP_KEY'), 'private_key' => Configuration::get('PAYMENTWALL_SECRET_KEY')));
 }
Example #26
0
function init_paymentwall_config($params)
{
    require_once getcwd() . '/includes/api/paymentwall_api/lib/paymentwall.php';
    Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $params['appKey'], 'private_key' => $params['secretKey']));
}
Example #27
0
define("CLIENTAREA", true);
define("FORCESSL", true);
include "init.php";
require_once ROOTDIR . '/includes/api/paymentwall_api/lib/paymentwall.php';
$whmcs->load_function('gateway');
$whmcs->load_function('clientarea');
$whmcs->load_function('invoice');
$gateway = getGatewayVariables("brick");
$whmcsVer = substr($CONFIG['Version'], 0, 1);
if ($whmcsVer <= 5) {
    $gateways = new WHMCS_Gateways();
} else {
    $gateways = new WHMCS\Gateways();
}
$publicKey = $gateway['isTest'] ? $gateway['publicTestKey'] : $gateway['publicKey'];
Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $publicKey, 'private_key' => $gateway['isTest'] ? $gateway['privateTestKey'] : $gateway['privateKey']));
$pagetitle = $_LANG['clientareatitle'] . " - Pay via Brick (Powered by Paymentwall)";
initialiseClientArea($pagetitle, '', 'Pay via Brick');
# Check login status
if ($_SESSION['uid'] && isset($_POST['data']) && ($post = json_decode(decrypt($_POST['data']), true))) {
    $smartyvalues = array_merge($smartyvalues, $post);
    $smartyvalues["data"] = $_POST['data'];
    $smartyvalues["whmcsVer"] = $whmcsVer;
    $smartyvalues["publicKey"] = $publicKey;
    $smartyvalues["processingerror"] = '';
    $smartyvalues["success"] = false;
    if ($_POST['frominvoice'] == "true" || $_POST['fromCCForm'] == 'true') {
        if ($whmcsVer <= 5) {
            $invoice = new WHMCS_Invoice();
        } else {
            $invoice = new WHMCS\Invoice();
Example #28
0
function init_brick_config($params)
{
    require_once ROOTDIR . '/includes/api/paymentwall_api/lib/paymentwall.php';
    Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $params['isTest'] ? $params['publicTestKey'] : $params['publicKey'], 'private_key' => $params['isTest'] ? $params['privateTestKey'] : $params['privateKey']));
}
Example #29
0
 public function initBrickConfig()
 {
     Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $this->config->get('brick_test_mode') ? $this->config->get('brick_public_test_key') : $this->config->get('brick_public_key'), 'private_key' => $this->config->get('brick_test_mode') ? $this->config->get('brick_private_test_key') : $this->config->get('brick_private_key')));
 }
Example #30
0
function paymentwallbrick_storeremote($params)
{
    $email = $params['clientdetails']['email'];
    global $CONFIG;
    $systemurl = $CONFIG['SystemSSLURL'] ? $CONFIG['SystemSSLURL'] . '/' : $CONFIG['SystemURL'] . '/';
    if (!class_exists("Paymentwall_Config")) {
        require_once dirname(__FILE__) . "/paymentwallbrick/lib/paymentwall.php";
    }
    if ($params["test_mode"] == "on") {
        Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $params['test_public_key'], 'private_key' => $params['test_private_key']));
    } else {
        Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $params['public_key'], 'private_key' => $params['private_key']));
    }
    if ($params["action"] == "delete") {
        return array('status' => 'success');
    }
    if (isset($_POST['brick_token'])) {
        if (isset($_POST['ccupdate'])) {
            $charge = new Paymentwall_Charge();
            $charge->create(array('fingerprint' => $_POST['brick_fingerprint'], 'token' => $_POST['brick_token'], 'email' => $email, 'capture' => false, 'currency' => $params['currency'], 'amount' => 1, 'description' => 'Card Update - This charge will be automatically voided'));
            if ($charge->isSuccessful()) {
                $gatewayid = $charge->card->token;
                $_SESSION['paymentwall_card'] = $charge->card;
                $charge->void();
                return array('status' => 'success', 'gatewayid' => $gatewayid);
            } else {
                $response = $charge->getPublicData();
                $errors = json_decode($response, true);
                return array('status' => 'error', 'rawdata' => $errors['error']['message']);
            }
        } else {
            return array('status' => 'success', 'gatewayid' => "brickjs");
        }
    } elseif (isset($params['cardnum'])) {
        $tokenModel = new Paymentwall_OneTimeToken();
        $token = $tokenModel->create(array('public_key' => Paymentwall_Config::getInstance()->getPublicKey(), 'card[number]' => $params['cardnum'], 'card[exp_month]' => substr($params['cardexp'], 0, 2), 'card[exp_year]' => substr($params['cardexp'], 2, 2), 'card[cvv]' => $params['cardcvv']));
        $charge = new Paymentwall_Charge();
        $charge->create(array('token' => $token->getToken(), 'email' => $email, 'capture' => false, 'currency' => $params['currency'], 'amount' => 1, 'browser_ip' => $_SERVER['REMOTE_ADDR'], 'browser_domain' => $_SERVER['HTTP_HOST'], 'description' => 'Card Update - This charge will be automatically voided'));
        if ($charge->isSuccessful()) {
            $gatewayid = $charge->card->token;
            $charge->void();
            return array('status' => 'success', 'gatewayid' => $gatewayid);
        } else {
            $response = $charge->getPublicData();
            $errors = json_decode($response, true);
            return array('status' => 'error', 'rawdata' => $errors['error']['message']);
        }
    }
}