Plugin Directory

Changeset 1309659


Ignore:
Timestamp:
12/16/2015 05:51:38 AM (10 years ago)
Author:
Paymentwall
Message:

Update to version 1.3.1

Location:
paymentwall-for-woocommerce/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • paymentwall-for-woocommerce/trunk/includes/admin/settings/brick.php

    r1293920 r1309659  
    2727        'default' => __("Pay via Brick Credit Card Processing.", PW_TEXT_DOMAIN)
    2828    ),
     29    'projectkey' => array(
     30        'title' => __('Project Key', PW_TEXT_DOMAIN),
     31        'type' => 'text',
     32        'description' => __('Your Paymentwall Key', PW_TEXT_DOMAIN),
     33        'default' => ''
     34    ),
     35    'secretkey' => array(
     36        'title' => __('Secret Key', PW_TEXT_DOMAIN),
     37        'type' => 'text',
     38        'description' => __('Your Paymentwall Secret Key', PW_TEXT_DOMAIN),
     39        'default' => ''
     40    ),
    2941    'publickey' => array(
    3042        'title' => __('Public Key', PW_TEXT_DOMAIN),
     
    3446    ),
    3547    'privatekey' => array(
    36         'title' => __('Secret Key', PW_TEXT_DOMAIN),
     48        'title' => __('Private Key', PW_TEXT_DOMAIN),
    3749        'type' => 'text',
    3850        'description' => __('Your Brick Private Key', PW_TEXT_DOMAIN),
    3951        'default' => ''
    4052    ),
    41     't_publickey' => array(
    42         'title' => __('Test Public Key', PW_TEXT_DOMAIN),
    43         'type' => 'text',
    44         'description' => __('Your Brick Test Public Key', PW_TEXT_DOMAIN),
    45         'default' => ''
    46     ),
    47     't_privatekey' => array(
    48         'title' => __('Test Secret Key', PW_TEXT_DOMAIN),
    49         'type' => 'text',
    50         'description' => __('Your Brick Test Private Key', PW_TEXT_DOMAIN),
    51         'default' => ''
    52     ),
    53     'test_mode' => array(
    54         'title' => __('Test Mode', PW_TEXT_DOMAIN),
    55         'type' => 'select',
    56         'description' => __('Enable test mode', PW_TEXT_DOMAIN),
    57         'options' => array(
    58             '0' => 'No',
    59             '1' => 'Yes'
    60         ),
    61         'default' => '1'
    62     ),
    6353);
  • paymentwall-for-woocommerce/trunk/includes/class-paymentwall-brick-subscription.php

    r1293920 r1309659  
    1414
    1515    public function __construct() {
    16 
    1716        $this->supports = array(
    1817            'products',
     
    3231
    3332        add_action('woocommerce_subscription_cancelled_' . $this->id, array($this, 'cancel_subscription_action'));
    34 
    3533        add_filter('woocommerce_subscription_payment_gateway_supports', array($this, 'add_feature_support_for_subscription'), 10, 3);
    3634    }
     
    4442    public function process_payment($order_id) {
    4543
    46         $this->init_paymentwall_configs();
    47 
     44        $this->init_brick_configs();
    4845        $order = wc_get_order($order_id);
    4946
     
    7370    public function process_subscription_payment($order, $subscription) {
    7471
     72        $this->init_brick_configs();
    7573        $return = array(
    7674            'result' => 'fail',
     
    7876        );
    7977
    80         $subscription_data = $this->prepare_subscription_data($order, $subscription);
    8178        $paymentwall_subscription = new Paymentwall_Subscription();
    82         $paymentwall_subscription->create($subscription_data);
     79        $paymentwall_subscription->create(array_merge(
     80            $this->prepare_subscription_data($order, $subscription),
     81            $this->prepare_user_profile_data($order),
     82            array(
     83                'custom[integration_module]' => 'woocommerce',
     84                'uid' => empty($order->user_id) ? $_SERVER['REMOTE_ADDR'] : $order->user_id
     85            )
     86        ));
    8387        $response = json_decode($paymentwall_subscription->GetRawResponseData());
    8488
    8589        if ($paymentwall_subscription->isSuccessful() && $response->object == 'subscription') {
    8690
    87             // Add order note
    88             $order->add_order_note(sprintf(__('Brick subscription payment approved (ID: %s)', PW_TEXT_DOMAIN), $response->id));
    89 
    90             // Payment complete
    91             $order->payment_complete($response->id);
     91            if ($paymentwall_subscription->isActive()) {
     92                // Add order note
     93                $order->add_order_note(sprintf(__('Brick subscription payment approved (ID: %s)', PW_TEXT_DOMAIN), $response->id));
     94
     95                // Payment complete
     96                $order->payment_complete($response->id);
     97            } else {
     98                $order->update_status('on-hold');
     99            }
     100
    92101
    93102            $return['result'] = 'success';
     
    97106            WC()->cart->empty_cart();
    98107        } else {
    99             $errors = json_decode($response, true);
    100             wc_add_notice(__($errors['error']['message']), 'error');
     108            wc_add_notice(__($response->error), 'error');
    101109        }
    102110
     
    199207        $this->init_paymentwall_configs();
    200208
    201         if($subscription_key = $this->get_transaction_key($subscription->order->id)){
     209        if ($subscription_key = $this->get_transaction_key($subscription->order->id)) {
    202210            $subscription_api = new Paymentwall_Subscription($subscription_key);
    203211            $subscription_api->cancel();
  • paymentwall-for-woocommerce/trunk/includes/class-paymentwall-brick.php

    r1293920 r1309659  
    1212
    1313class Paymentwall_Brick extends Paymentwall_Abstract {
     14
    1415    public $id = 'brick';
    1516    public $has_fields = true;
    1617
    1718    public function __construct() {
     19
    1820        parent::__construct();
    1921
     
    3133    /**
    3234     * Initial Paymentwall Configs
     35     * For pingback request
    3336     */
    3437    public function  init_paymentwall_configs() {
    3538        Paymentwall_Config::getInstance()->set(array(
    3639            'api_type' => Paymentwall_Config::API_GOODS,
    37             'public_key' => $this->settings['test_mode'] ? $this->settings['t_publickey'] : $this->settings['publickey'],
    38             'private_key' => $this->settings['test_mode'] ? $this->settings['t_privatekey'] : $this->settings['privatekey'],
     40            'public_key' => $this->settings['projectkey'],
     41            'private_key' => $this->settings['secretkey'],
     42        ));
     43    }
     44
     45    /**
     46     * Initial Brick Configs
     47     */
     48    public function  init_brick_configs() {
     49        Paymentwall_Config::getInstance()->set(array(
     50            'api_type' => Paymentwall_Config::API_GOODS,
     51            'public_key' => $this->settings['publickey'],
     52            'private_key' => $this->settings['privatekey'],
    3953        ));
    4054    }
     
    6074     */
    6175    public function process_payment($order_id) {
    62         $this->init_paymentwall_configs();
    6376
     77        $this->init_brick_configs();
    6478        $order = wc_get_order($order_id);
    6579
     
    8094     */
    8195    function prepare_card_info($order) {
     96
    8297        if (!isset($_POST['brick'])) {
    8398            throw new Exception("Payment Invalid!");
     
    124139        $charge->create(array_merge(
    125140            $this->prepare_user_profile_data($order), // for User Profile API
    126             $this->prepare_card_info($order)
     141            $this->prepare_card_info($order),
     142            array(
     143                'custom[integration_module]' => 'woocommerce',
     144                'uid' => empty($order->user_id) ? $_SERVER['REMOTE_ADDR'] : $order->user_id
     145            )
    127146        ));
    128147        $response = $charge->getPublicData();
     
    136155                // Payment complete
    137156                $order->payment_complete($charge->getId());
    138 
    139                 WC_Subscriptions_Manager::activate_subscriptions_for_order($order);
    140 
    141                 $return['result'] = 'success';
    142                 $return['redirect'] = $this->get_return_url($order);
    143157            } elseif ($charge->isUnderReview()) {
    144158                $order->update_status('on-hold');
    145159            }
     160
     161            $return['result'] = 'success';
     162            $return['redirect'] = $this->get_return_url($order);
    146163
    147164            // Clear shopping cart
  • paymentwall-for-woocommerce/trunk/includes/class-paymentwall-gateway.php

    r1293920 r1309659  
    1212
    1313class Paymentwall_Gateway extends Paymentwall_Abstract {
     14
    1415    public $id = 'paymentwall';
    1516    public $has_fields = true;
     
    4950        $order = wc_get_order($order_id);
    5051        $widget = new Paymentwall_Widget(
    51             $order->billing_email,
     52            empty($order->user_id) ? $_SERVER['REMOTE_ADDR'] : $order->user_id,
    5253            $this->settings['widget'],
    5354            array(
     
    6667        $iframe = $widget->getHtmlCode(array(
    6768            'width' => '100%',
    68             'height' => 400,
     69            'height' => '1000',
    6970            'frameborder' => 0
    7071        ));
     
    108109     */
    109110    function ipn_response() {
    110         $this->init_paymentwall_configs();
     111
     112        $order = wc_get_order($_GET['goodsid']);
     113        if (!$order) {
     114            die('The order is Invalid!');
     115        }
     116
     117        $payment = wc_get_payment_gateway_by_order($order);
     118        $payment->init_paymentwall_configs();
     119
    111120        $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
    112 
    113121        if ($pingback->validate()) {
    114122
    115             if ($order = wc_get_order($pingback->getProductId())) {
    116 
    117                 if ($pingback->isDeliverable()) {
    118 
    119                     // Call Delivery Confirmation API
    120                     if ($this->settings['enable_delivery']) {
    121                         // Delivery Confirmation
    122                         $delivery = new Paymentwall_GenerericApiObject('delivery');
    123                         $response = $delivery->post($this->prepare_delivery_confirmation_data($order, $pingback->getReferenceId()));
    124                     }
    125 
    126                     $order->add_order_note(__('Paymentwall payment completed', PW_TEXT_DOMAIN));
    127                     $order->payment_complete($pingback->getReferenceId());
    128 
    129                 } elseif ($pingback->isCancelable()) {
    130                     $order->update_status('cancelled', __('Reason: ' . $pingback->getParameter('reason'), PW_TEXT_DOMAIN));
    131                 } else {
    132                     // Support subscription pingback type
    133                     if (paymentwall_subscription_enable()) {
    134                         $subscription = wcs_get_subscriptions_for_order($order);
    135                         $subscription = reset($subscription); // Do not support multi subscription
    136 
    137                         if ($pingback->getType() == Paymentwall_Pingback::PINGBACK_TYPE_SUBSCRIPTION_CANCELLATION) {
    138                             $subscription->update_status('cancelled', sprintf(__('The subscription %s cancelled', PW_TEXT_DOMAIN), $subscription->id));
    139                         }
    140                     }
     123            if ($pingback->isDeliverable()) {
     124
     125                if ($order->get_status() == PW_ORDER_STATUS_PROCESSING) {
     126                    die(PW_DEFAULT_SUCCESS_PINGBACK_VALUE);
    141127                }
    142128
    143                 die(PW_DEFAULT_SUCCESS_PINGBACK_VALUE);
    144             } else {
    145                 die('The order is Invalid!');
     129                // Call Delivery Confirmation API
     130                if ($this->settings['enable_delivery']) {
     131                    // Delivery Confirmation
     132                    $delivery = new Paymentwall_GenerericApiObject('delivery');
     133                    $response = $delivery->post($this->prepare_delivery_confirmation_data($order, $pingback->getReferenceId()));
     134                }
     135
     136                $order->add_order_note(__('Payment approved by Paymentwall - Transaction Id: ' . $pingback->getReferenceId(), PW_TEXT_DOMAIN));
     137                $order->payment_complete($pingback->getReferenceId());
     138
     139            } elseif ($pingback->isCancelable()) {
     140                $order->cancel_order(__('Reason: ' . $pingback->getParameter('reason'), PW_TEXT_DOMAIN));
     141            } elseif ($pingback->isUnderReview()) {
     142                $order->update_status('on-hold');
    146143            }
    147144
     145            die(PW_DEFAULT_SUCCESS_PINGBACK_VALUE);
    148146        } else {
    149147            die($pingback->getErrorSummary());
  • paymentwall-for-woocommerce/trunk/lib/paymentwall-php/lib/Paymentwall/ApiObject.php

    r1242976 r1309659  
    109109    }
    110110
    111     protected function getResponseLogInformation()
     111    public function getResponseLogInformation()
    112112    {
    113113        return $this->_responseLogInformation;
  • paymentwall-for-woocommerce/trunk/lib/paymentwall-php/lib/Paymentwall/Pingback.php

    r1212424 r1309659  
    197197        $productIds = $this->getParameter('goodsid');
    198198
    199         if (!empty($productIds)) {
     199        if (!empty($productIds) && is_array($productIds)) {
    200200            foreach ($productIds as $Id) {
    201201                $result[] = new Paymentwall_Product($Id);
  • paymentwall-for-woocommerce/trunk/readme.txt

    r1293923 r1309659  
    3737== Changelog ==
    3838
     39= v1.3.1 [16/12/2015] =
     40* Update latest Paymentwall PHP lib
     41* Fix error cannot checkout
     42
    3943= v1.3.0 [25/11/2015] =
    4044* Add Brick subscription support.
  • paymentwall-for-woocommerce/trunk/templates/brick/form.html

    r1293920 r1309659  
    4646    // Brick manipulate the checkout
    4747    jQuery('form.checkout').unbind('checkout_place_order_{{payment_id}}').on('checkout_place_order_{{payment_id}}', function (e) {
    48         e.preventDefault();
    4948
    5049        // Check token created
Note: See TracChangeset for help on using the changeset viewer.