コード例 #1
0
 public function sendData($data)
 {
     // Initialise the PaymentWall configuration
     $this->setPaymentWallObject();
     // Create the charge object
     $charge = new \Paymentwall_Charge($data['sale_id']);
     $charge->get();
     // Get the response data -- this is returned as a JSON string.
     $charge_data = json_decode($charge->getRawResponseData(), true);
     // Construct the response object
     $this->response = new Response($this, $charge_data);
     return $this->response;
 }
コード例 #2
0
 /**
  * @param int $order_id
  * @return array
  */
 function process_payment($order_id)
 {
     $order = new jigoshop_order($order_id);
     $this->init_paymentwall_configs();
     $return = array('result' => 'fail', 'redirect' => '');
     $charge = new Paymentwall_Charge();
     try {
         $charge->create(array_merge($this->prepare_user_profile_data($order), $this->prepare_card_info($order)));
         $response = $charge->getPublicData();
         if ($charge->isSuccessful()) {
             if ($charge->isCaptured()) {
                 // Add order note
                 $order->add_order_note(sprintf(__('Brick payment approved (ID: %s, Card: xxxx-%s)', PW_JIGO_TEXT_DOMAIN), $charge->getId(), $charge->getCard()->getAlias()));
                 // Payment complete
                 $order->payment_complete();
                 $return['result'] = 'success';
                 $checkout_redirect = apply_filters('jigoshop_get_checkout_redirect_page_id', jigoshop_get_page_id('thanks'));
                 $return['redirect'] = add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink($checkout_redirect)));
             } elseif ($charge->isUnderReview()) {
                 $order->update_status('on-hold');
             }
             // Clear shopping cart
             jigoshop_cart::empty_cart();
         } else {
             $errors = json_decode($response, true);
             jigoshop::add_error(__($errors['error']['message']), 'error');
         }
     } catch (Exception $e) {
         jigoshop::add_error($e->getMessage(), 'error');
     }
     // Return redirect
     return $return;
 }
コード例 #3
0
 public function sendData($data)
 {
     // Initialise the PaymentWall configuration
     $this->setPaymentWallObject();
     // Create the charge object
     $charge = new \Paymentwall_Charge($data['sale_id']);
     $charge->capture();
     // Get the response data -- this is returned as a JSON string.
     $charge_response = $charge->getPublicData();
     $charge_data = json_decode($charge_response, true);
     // echo "Charge Data == " . print_r($charge_data, true) . "\n";
     // Get the remaining data from the response
     // echo "Charge == " . print_r($charge, true) . "\n";
     // echo "Charge ID == " . $charge->getId() . "\n";
     $charge_data['transaction_reference'] = $charge->getId();
     // Construct the response object
     $this->response = new Response($this, $charge_data);
     return $this->response;
 }
コード例 #4
0
ファイル: brick.php プロジェクト: paymentwall/module-opencart
 /**
  * Validate Brick request
  */
 public function validate()
 {
     $this->load->model('checkout/order');
     $this->load->model('payment/brick');
     $this->load->model('account/activity');
     $this->load->model('setting/setting');
     $this->language->load('payment/brick');
     $defaultConfigs = $this->model_setting_setting->getSetting('config');
     $data = array('status' => 'error', 'message' => '', 'redirect' => false);
     if (!isset($this->session->data['order_id']) || !isset($this->request->post['cc_brick_token']) || !isset($this->request->post['cc_brick_token'])) {
         $data['message'] = "Oops, Something went wrong. Please try again!";
     } elseif ($orderInfo = $this->model_checkout_order->getOrder($this->session->data['order_id'])) {
         if ($this->customer->isLogged()) {
             $activity_data = array('customer_id' => $this->customer->getId(), 'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName(), 'order_id' => $this->session->data['order_id']);
             $this->model_account_activity->addActivity('order_account', $activity_data);
         } else {
             $activity_data = array('name' => $this->session->data['guest']['firstname'] . ' ' . $this->session->data['guest']['lastname'], 'order_id' => $this->session->data['order_id']);
             $this->model_account_activity->addActivity('order_guest', $activity_data);
         }
         $this->model_payment_brick->initBrickConfig();
         $charge = new Paymentwall_Charge();
         $charge->create(array_merge($this->prepareCardInfo($orderInfo), $this->getUserProfileData($orderInfo)));
         $response = $charge->getPublicData();
         if ($charge->isSuccessful()) {
             if ($charge->isCaptured()) {
                 $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('brick_complete_status'), 'The order approved, Transaction ID: #' . $charge->getId(), true);
                 $data['message'] = $this->language->get('text_order_processed');
             } elseif ($charge->isUnderReview()) {
                 $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('brick_under_review_status'), 'The order is under review!', true);
                 $data['message'] = $this->language->get('text_order_under_review');
             }
             $data['status'] = 'success';
             $data['redirect'] = $this->url->link('checkout/success');
         } else {
             $response = json_decode($response, true);
             $data['message'] = $response['error']['message'];
         }
     } else {
         $data['message'] = $this->language->get('text_order_invalid');
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($data));
 }
コード例 #5
0
 /**
  * Submit a payment through the PaymentWall Library.
  *
  * @param mixed $data
  *
  * @return Response
  */
 public function sendData($data)
 {
     // Initialise the PaymentWall configuration
     $this->setPaymentWallObject();
     // if no token exists, create one
     if (empty($data['purchase']['token'])) {
         // Create a one time token
         $tokenModel = new \Paymentwall_OneTimeToken();
         $tokenObject = $tokenModel->create($data['card']);
         if ($tokenObject->type == 'Error') {
             return $this->returnError($tokenObject->error, $tokenObject->code);
         }
         $data['purchase']['token'] = $tokenObject->getToken();
     }
     if (empty($data['purchase']['token'])) {
         return $this->returnError('Payment Token could not be created', 231);
     }
     // Now we know that we have an actual token (one time or
     // permanent), we can create the charge request.
     $charge = new \Paymentwall_Charge();
     try {
         $charge->create($data['purchase']);
     } catch (\Exception $e) {
         return $this->returnError('Cannot process payment', 231, $charge->getResponseLogInformation());
     }
     // Force the charge properties to be an array
     $properties = $charge->getProperties();
     $properties = json_decode(json_encode($properties), true);
     // Construct the response object
     $this->response = new Response($this, $properties);
     if ($charge->isSuccessful()) {
         if ($charge->isCaptured()) {
             $this->response->setCaptured(true);
         } elseif ($charge->isUnderReview()) {
             $this->response->setUnderReview(true);
         }
     }
     return $this->response;
 }
コード例 #6
0
ファイル: brickccform.php プロジェクト: fanytest/module-whmcs
     $invoice = new WHMCS_Invoice();
 } else {
     $invoice = new WHMCS\Invoice();
 }
 $invoice->setID($_POST["invoiceid"]);
 $invoiceData = $invoice->getOutput();
 // Prepare form data
 $smartyvalues["client"] = $invoiceData['clientsdetails'];
 $smartyvalues['months'] = $gateways->getCCDateMonths();
 $smartyvalues['years'] = $gateways->getCCExpiryDateYears();
 $smartyvalues['invoice'] = $invoiceData;
 $smartyvalues['invoiceItems'] = $invoice->getLineItems();
 if ($_POST['fromCCForm'] == 'true') {
     # Check form submit & capture payment
     $cardInfo = array('email' => $invoiceData['clientsdetails']['email'], 'amount' => $post['amount'], 'currency' => $post["currency"], 'token' => $_POST['brick_token'], 'fingerprint' => $_POST['brick_fingerprint'], 'description' => $invoiceData['pagetitle']);
     $charge = new Paymentwall_Charge();
     $charge->create(array_merge($cardInfo, brick_get_user_profile_data($invoiceData)));
     $response = $charge->getPublicData();
     if ($charge->isSuccessful()) {
         if ($charge->isCaptured()) {
             addInvoicePayment($_POST["invoiceid"], $charge->getId(), null, null, 'brick');
         } elseif ($charge->isUnderReview()) {
             // decide on risk charge
         }
         logTransaction($gateway['name'], $cardInfo, "Successful");
         $smartyvalues["success"] = true;
     } else {
         $error = json_decode($response, true);
         $smartyvalues["processingerror"] = '<li>' . $error['error']['message'] . '</li>';
         logTransaction($gateway['name'], $cardInfo, "Unsuccessful");
     }
コード例 #7
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;
コード例 #8
0
ファイル: ChargeContext.php プロジェクト: VPNht/brick-whmcs
 protected function getChargeObject()
 {
     $chargeModel = new Paymentwall_Charge();
     return $chargeModel->create($this->getTestDetailsForCharge());
 }
コード例 #9
0
ファイル: brick.php プロジェクト: paymentwall/module-blesta
 /**
  * Validates the incoming POST/GET response from the gateway to ensure it is
  * legitimate and can be trusted.
  *
  * @param array $get The GET data for this request
  * @param array $post The POST data for this request
  * @return array An array of transaction data, sets any errors using Input if the data fails to validate
  *  - client_id The ID of the client that attempted the payment
  *  - amount The amount of the payment
  *  - currency The currency of the payment
  *  - invoices An array of invoices and the amount the payment should be applied to (if any) including:
  *    - id The ID of the invoice to apply to
  *    - amount The amount to apply to the invoice
  *    - status The status of the transaction (approved, declined, void, pending, reconciled, refunded, returned)
  *    - reference_id The reference ID for gateway-only use with this transaction (optional)
  *    - transaction_id The ID returned by the gateway to identify this transaction
  *    - parent_transaction_id The ID returned by the gateway to identify this transaction's original transaction (in the case of refunds)
  */
 public function validate(array $get, array $post)
 {
     if (!isset($get['data'])) {
         return false;
     }
     $data = $this->decodeData($get['data']);
     unset($get['data']);
     list($company_id, $payment_method) = $get;
     if ($payment_method != 'brick') {
         return false;
     }
     $brick = $post['brick'];
     $this->initPaymentwallConfigs();
     $status = 'error';
     $cardInfo = array('email' => $data['email'], 'amount' => $data['amount'], 'currency' => $data['currency'], 'description' => $data['description'], 'token' => $brick['token'], 'fingerprint' => $brick['fingerprint']);
     $charge = new Paymentwall_Charge();
     $charge->create($cardInfo);
     $response = json_decode($charge->getPublicData(), true);
     if ($charge->isSuccessful()) {
         if ($charge->isCaptured()) {
             // deliver a product
             $status = 'approved';
         } elseif ($charge->isUnderReview()) {
             // decide on risk charge
             $status = 'pending';
         }
     } else {
         $_SESSION['brick_errors'] = $response['error']['message'];
     }
     return array('client_id' => $data['client_id'], 'amount' => $data['amount'], 'currency' => $data['currency'], 'status' => $status, 'reference_id' => null, 'transaction_id' => $charge->getId() ? $charge->getId() : false, 'parent_transaction_id' => null, 'invoices' => $data['invoices']);
 }
コード例 #10
0
ファイル: pingback.php プロジェクト: VPNht/brick-whmcs
$gatewayParams = getGatewayVariables("paymentwallbrick");
// Die if module is not active.
if (!$gatewayParams['type']) {
    die("Module Not Activated");
}
if (!class_exists("Paymentwall_Config")) {
    require_once dirname(__FILE__) . "/lib/paymentwall.php";
}
if ($gatewayParams["test_mode"] == "on") {
    Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $gatewayParams['test_public_key'], 'private_key' => $gatewayParams['test_private_key']));
} else {
    Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $gatewayParams['public_key'], 'private_key' => $gatewayParams['private_key']));
}
$charge_id = $_GET["ref"];
$invoice_id = $_GET["goodsid"];
$status = $_GET['type'];
$charge = new Paymentwall_Charge($_GET["ref"]);
logTransaction($gatewayParams["name"], $_GET, "PingBack");
$charge->get();
if ($status == 201 && $charge->isCaptured()) {
    $invoiceId = checkCbInvoiceID($invoice_id, $gatewayParams['name']);
    checkCbTransID($charge_id);
    logTransaction($gatewayParams["name"], var_export($charge, true), "Charge Approved via PingBack");
    addInvoicePayment($invoiceId, $charge_id, null, null, "paymentwallbrick");
} elseif ($status == 202) {
    $invoiceId = checkCbInvoiceID($invoice_id, $gatewayParams['name']);
    checkCbTransID($charge_id);
    logTransaction($gatewayParams["name"], var_export($charge, true), "Charge Declined via PingBack");
    sendMessage("Credit Card Payment Failed", $invoiceId);
}
echo "OK";
コード例 #11
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']);
        }
    }
}