Changeset 1309659
- Timestamp:
- 12/16/2015 05:51:38 AM (10 years ago)
- Location:
- paymentwall-for-woocommerce/trunk
- Files:
-
- 8 edited
-
includes/admin/settings/brick.php (modified) (2 diffs)
-
includes/class-paymentwall-brick-subscription.php (modified) (7 diffs)
-
includes/class-paymentwall-brick.php (modified) (6 diffs)
-
includes/class-paymentwall-gateway.php (modified) (4 diffs)
-
lib/paymentwall-php/lib/Paymentwall/ApiObject.php (modified) (1 diff)
-
lib/paymentwall-php/lib/Paymentwall/Pingback.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
templates/brick/form.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
paymentwall-for-woocommerce/trunk/includes/admin/settings/brick.php
r1293920 r1309659 27 27 'default' => __("Pay via Brick Credit Card Processing.", PW_TEXT_DOMAIN) 28 28 ), 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 ), 29 41 'publickey' => array( 30 42 'title' => __('Public Key', PW_TEXT_DOMAIN), … … 34 46 ), 35 47 'privatekey' => array( 36 'title' => __(' SecretKey', PW_TEXT_DOMAIN),48 'title' => __('Private Key', PW_TEXT_DOMAIN), 37 49 'type' => 'text', 38 50 'description' => __('Your Brick Private Key', PW_TEXT_DOMAIN), 39 51 'default' => '' 40 52 ), 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 ),63 53 ); -
paymentwall-for-woocommerce/trunk/includes/class-paymentwall-brick-subscription.php
r1293920 r1309659 14 14 15 15 public function __construct() { 16 17 16 $this->supports = array( 18 17 'products', … … 32 31 33 32 add_action('woocommerce_subscription_cancelled_' . $this->id, array($this, 'cancel_subscription_action')); 34 35 33 add_filter('woocommerce_subscription_payment_gateway_supports', array($this, 'add_feature_support_for_subscription'), 10, 3); 36 34 } … … 44 42 public function process_payment($order_id) { 45 43 46 $this->init_paymentwall_configs(); 47 44 $this->init_brick_configs(); 48 45 $order = wc_get_order($order_id); 49 46 … … 73 70 public function process_subscription_payment($order, $subscription) { 74 71 72 $this->init_brick_configs(); 75 73 $return = array( 76 74 'result' => 'fail', … … 78 76 ); 79 77 80 $subscription_data = $this->prepare_subscription_data($order, $subscription);81 78 $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 )); 83 87 $response = json_decode($paymentwall_subscription->GetRawResponseData()); 84 88 85 89 if ($paymentwall_subscription->isSuccessful() && $response->object == 'subscription') { 86 90 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 92 101 93 102 $return['result'] = 'success'; … … 97 106 WC()->cart->empty_cart(); 98 107 } else { 99 $errors = json_decode($response, true); 100 wc_add_notice(__($errors['error']['message']), 'error'); 108 wc_add_notice(__($response->error), 'error'); 101 109 } 102 110 … … 199 207 $this->init_paymentwall_configs(); 200 208 201 if ($subscription_key = $this->get_transaction_key($subscription->order->id)){209 if ($subscription_key = $this->get_transaction_key($subscription->order->id)) { 202 210 $subscription_api = new Paymentwall_Subscription($subscription_key); 203 211 $subscription_api->cancel(); -
paymentwall-for-woocommerce/trunk/includes/class-paymentwall-brick.php
r1293920 r1309659 12 12 13 13 class Paymentwall_Brick extends Paymentwall_Abstract { 14 14 15 public $id = 'brick'; 15 16 public $has_fields = true; 16 17 17 18 public function __construct() { 19 18 20 parent::__construct(); 19 21 … … 31 33 /** 32 34 * Initial Paymentwall Configs 35 * For pingback request 33 36 */ 34 37 public function init_paymentwall_configs() { 35 38 Paymentwall_Config::getInstance()->set(array( 36 39 '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'], 39 53 )); 40 54 } … … 60 74 */ 61 75 public function process_payment($order_id) { 62 $this->init_paymentwall_configs();63 76 77 $this->init_brick_configs(); 64 78 $order = wc_get_order($order_id); 65 79 … … 80 94 */ 81 95 function prepare_card_info($order) { 96 82 97 if (!isset($_POST['brick'])) { 83 98 throw new Exception("Payment Invalid!"); … … 124 139 $charge->create(array_merge( 125 140 $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 ) 127 146 )); 128 147 $response = $charge->getPublicData(); … … 136 155 // Payment complete 137 156 $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);143 157 } elseif ($charge->isUnderReview()) { 144 158 $order->update_status('on-hold'); 145 159 } 160 161 $return['result'] = 'success'; 162 $return['redirect'] = $this->get_return_url($order); 146 163 147 164 // Clear shopping cart -
paymentwall-for-woocommerce/trunk/includes/class-paymentwall-gateway.php
r1293920 r1309659 12 12 13 13 class Paymentwall_Gateway extends Paymentwall_Abstract { 14 14 15 public $id = 'paymentwall'; 15 16 public $has_fields = true; … … 49 50 $order = wc_get_order($order_id); 50 51 $widget = new Paymentwall_Widget( 51 $order->billing_email,52 empty($order->user_id) ? $_SERVER['REMOTE_ADDR'] : $order->user_id, 52 53 $this->settings['widget'], 53 54 array( … … 66 67 $iframe = $widget->getHtmlCode(array( 67 68 'width' => '100%', 68 'height' => 400,69 'height' => '1000', 69 70 'frameborder' => 0 70 71 )); … … 108 109 */ 109 110 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 111 120 $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']); 112 113 121 if ($pingback->validate()) { 114 122 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); 141 127 } 142 128 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'); 146 143 } 147 144 145 die(PW_DEFAULT_SUCCESS_PINGBACK_VALUE); 148 146 } else { 149 147 die($pingback->getErrorSummary()); -
paymentwall-for-woocommerce/trunk/lib/paymentwall-php/lib/Paymentwall/ApiObject.php
r1242976 r1309659 109 109 } 110 110 111 p rotectedfunction getResponseLogInformation()111 public function getResponseLogInformation() 112 112 { 113 113 return $this->_responseLogInformation; -
paymentwall-for-woocommerce/trunk/lib/paymentwall-php/lib/Paymentwall/Pingback.php
r1212424 r1309659 197 197 $productIds = $this->getParameter('goodsid'); 198 198 199 if (!empty($productIds) ) {199 if (!empty($productIds) && is_array($productIds)) { 200 200 foreach ($productIds as $Id) { 201 201 $result[] = new Paymentwall_Product($Id); -
paymentwall-for-woocommerce/trunk/readme.txt
r1293923 r1309659 37 37 == Changelog == 38 38 39 = v1.3.1 [16/12/2015] = 40 * Update latest Paymentwall PHP lib 41 * Fix error cannot checkout 42 39 43 = v1.3.0 [25/11/2015] = 40 44 * Add Brick subscription support. -
paymentwall-for-woocommerce/trunk/templates/brick/form.html
r1293920 r1309659 46 46 // Brick manipulate the checkout 47 47 jQuery('form.checkout').unbind('checkout_place_order_{{payment_id}}').on('checkout_place_order_{{payment_id}}', function (e) { 48 e.preventDefault();49 48 50 49 // Check token created
Note: See TracChangeset
for help on using the changeset viewer.