Skip to content

Commit

Permalink
Authorization order status in WC (EC, Pro). #883
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Nov 30, 2017
1 parent 30d08cf commit e1dd10b
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct($gateway) {
$this->testmode = 'yes' === $this->gateway->get_option('testmode', 'yes');
$this->fraud_management_filters = $this->gateway->get_option('fraud_management_filters', 'place_order_on_hold_for_further_review');
$this->email_notify_order_cancellations = $this->gateway->get_option('email_notify_order_cancellations', 'no');
$this->pending_authorization_order_status = $this->gateway->get_option('pending_authorization_order_status', 'On Hold');
if ($this->testmode == false) {
$this->testmode = AngellEYE_Utility::angelleye_paypal_for_woocommerce_is_set_sandbox_product();
}
Expand Down Expand Up @@ -736,7 +737,8 @@ public function update_payment_status_by_paypal_responce($orderid, $result) {
}
switch (strtolower($payment_status)) :
case 'completed' :
if ($order->status == 'completed') {
$order_status = version_compare(WC_VERSION, '3.0', '<') ? $order->status : $this->order->get_status();
if ($order_status == 'completed') {
break;
}
if (!in_array(strtolower($transaction_type), array('merchtpmt', 'cart', 'instant', 'express_checkout', 'web_accept', 'masspay', 'send_money'))) {
Expand All @@ -751,49 +753,53 @@ public function update_payment_status_by_paypal_responce($orderid, $result) {
}
switch (strtolower($pending_reason)) {
case 'address':
$pending_reason = __('Address: The payment is pending because your customer did not include a confirmed shipping address and your Payment Receiving Preferences is set such that you want to manually accept or deny each of these payments. To change your preference, go to the Preferences section of your Profile.', 'paypal-for-woocommerce');
$pending_reason_text = __('Address: The payment is pending because your customer did not include a confirmed shipping address and your Payment Receiving Preferences is set such that you want to manually accept or deny each of these payments. To change your preference, go to the Preferences section of your Profile.', 'paypal-for-woocommerce');
break;
case 'authorization':
$pending_reason = __('Authorization: The payment is pending because it has been authorized but not settled. You must capture the funds first.', 'paypal-for-woocommerce');
$pending_reason_text = __('Authorization: The payment is pending because it has been authorized but not settled. You must capture the funds first.', 'paypal-for-woocommerce');
break;
case 'echeck':
$pending_reason = __('eCheck: The payment is pending because it was made by an eCheck that has not yet cleared.', 'paypal-for-woocommerce');
$pending_reason_text = __('eCheck: The payment is pending because it was made by an eCheck that has not yet cleared.', 'paypal-for-woocommerce');
break;
case 'intl':
$pending_reason = __('intl: The payment is pending because you hold a non-U.S. account and do not have a withdrawal mechanism. You must manually accept or deny this payment from your Account Overview.', 'paypal-for-woocommerce');
$pending_reason_text = __('intl: The payment is pending because you hold a non-U.S. account and do not have a withdrawal mechanism. You must manually accept or deny this payment from your Account Overview.', 'paypal-for-woocommerce');
break;
case 'multicurrency':
case 'multi-currency':
$pending_reason = __('Multi-currency: You do not have a balance in the currency sent, and you do not have your Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment.', 'paypal-for-woocommerce');
$pending_reason_text = __('Multi-currency: You do not have a balance in the currency sent, and you do not have your Payment Receiving Preferences set to automatically convert and accept this payment. You must manually accept or deny this payment.', 'paypal-for-woocommerce');
break;
case 'order':
$pending_reason = __('Order: The payment is pending because it is part of an order that has been authorized but not settled.', 'paypal-for-woocommerce');
$pending_reason_text = __('Order: The payment is pending because it is part of an order that has been authorized but not settled.', 'paypal-for-woocommerce');
break;
case 'paymentreview':
$pending_reason = __('Payment Review: The payment is pending while it is being reviewed by PayPal for risk.', 'paypal-for-woocommerce');
$pending_reason_text = __('Payment Review: The payment is pending while it is being reviewed by PayPal for risk.', 'paypal-for-woocommerce');
break;
case 'unilateral':
$pending_reason = __('Unilateral: The payment is pending because it was made to an email address that is not yet registered or confirmed.', 'paypal-for-woocommerce');
$pending_reason_text = __('Unilateral: The payment is pending because it was made to an email address that is not yet registered or confirmed.', 'paypal-for-woocommerce');
break;
case 'verify':
$pending_reason = __('Verify: The payment is pending because you are not yet verified. You must verify your account before you can accept this payment.', 'paypal-for-woocommerce');
$pending_reason_text = __('Verify: The payment is pending because you are not yet verified. You must verify your account before you can accept this payment.', 'paypal-for-woocommerce');
break;
case 'other':
$pending_reason = __('Other: For more information, contact PayPal customer service.', 'paypal-for-woocommerce');
$pending_reason_text = __('Other: For more information, contact PayPal customer service.', 'paypal-for-woocommerce');
break;
case 'none':
default:
$pending_reason = __('No pending reason provided.', 'paypal-for-woocommerce');
$pending_reason_text = __('No pending reason provided.', 'paypal-for-woocommerce');
break;
}
$order->add_order_note(sprintf(__('Payment via Express Checkout Pending. PayPal reason: %s.', 'paypal-for-woocommerce'), $pending_reason));
$order->update_status('on-hold');
if ( $old_wc ) {
if ( ! get_post_meta( $orderid, '_order_stock_reduced', true ) ) {
$order->reduce_order_stock();
}
$order->add_order_note(sprintf(__('Payment via Express Checkout Pending. PayPal reason: %s.', 'paypal-for-woocommerce'), $pending_reason_text));
if ( strtolower($pending_reason) == 'authorization' && $this->pending_authorization_order_status == 'Processing' ) {
$order->payment_complete($transaction_id);
} else {
wc_maybe_reduce_stock_levels( $orderid );
$order->update_status('on-hold');
if ( $old_wc ) {
if ( ! get_post_meta( $orderid, '_order_stock_reduced', true ) ) {
$order->reduce_order_stock();
}
} else {
wc_maybe_reduce_stock_levels( $orderid );
}
}
break;
case 'denied' :
Expand Down
21 changes: 21 additions & 0 deletions classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function __construct() {
$this->invoice_id_prefix = $this->get_option('invoice_id_prefix', '');
$this->paypal_marketing_solutions_cid_production = $this->get_option('paypal_marketing_solutions_cid_production', '');
$this->show_on_minicart = $this->get_option('show_on_minicart', 'yes');
$this->pending_authorization_order_status = $this->get_option('pending_authorization_order_status', 'On Hold');
if ($this->enable_notifyurl == 'yes') {
$this->notifyurl = $this->get_option('notifyurl');
if (isset($this->notifyurl) && !empty($this->notifyurl)) {
Expand Down Expand Up @@ -225,6 +226,13 @@ function callback_onsuccess_production(containerId) {
</script>
<?php } ?>
<script type="text/javascript">
jQuery('#woocommerce_paypal_express_payment_action').change(function () {
if ( this.value === 'Authorization' ) {
jQuery('#woocommerce_paypal_express_pending_authorization_order_status').closest('tr').show();
} else {
jQuery('#woocommerce_paypal_express_pending_authorization_order_status').closest('tr').hide();
}
}).change();
var display_disable_terms = "<?php echo $display_disable_terms; ?>";
<?php if ($guest_checkout === 'no') { ?>
jQuery("#woocommerce_paypal_express_skip_final_review").prop("checked", false);
Expand Down Expand Up @@ -639,6 +647,19 @@ public function init_form_fields() {
'default' => 'Sale',
'desc_tip' => true,
),
'pending_authorization_order_status' => array(
'title' => __('Pending Authorization Order Status', 'paypal-for-woocommerce'),
'label' => __('Pending Authorization Order Status.', 'paypal-for-woocommerce'),
'description' => __('Pending Authorization Order Status.'),
'type' => 'select',
'class' => 'wc-enhanced-select',
'options' => array(
'On Hold' => 'On Hold',
'Processing' => 'Processing'
),
'default' => 'On Hold',
'desc_tip' => true,
),
'billing_address' => array(
'title' => __('Billing Address', 'paypal-for-woocommerce'),
'label' => __('Set billing address in WooCommerce using the address returned by PayPal.', 'paypal-for-woocommerce'),
Expand Down
Loading

0 comments on commit e1dd10b

Please sign in to comment.