Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Express Checkout - Organize Settings, PFW-33 #1144

Merged
merged 3 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ public function angelleye_paypal_express_checkout_redirect_to_paypal($data, $err
if (empty($_POST['woocommerce_checkout_update_totals']) && 0 === $notice_count) {
try {
WC()->session->set('post_data', $_POST);
$this->process_customer($_POST);
if (isset($_POST['payment_method']) && 'paypal_express' === $_POST['payment_method'] && $this->function_helper->ec_notice_count('error') == 0) {
$this->function_helper->ec_redirect_after_checkout();
}
Expand Down Expand Up @@ -1146,46 +1145,5 @@ public function angelleye_display_custom_message_review_page() {
}
}
}

public function process_customer( $data ) {
$customer_id = apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() );
if ( ! is_user_logged_in() && ( WC()->checkout->is_registration_required() || ! empty( $data['createaccount'] ) ) ) {
$username = ! empty( $data['account_username'] ) ? $data['account_username'] : '';
$password = ! empty( $data['account_password'] ) ? $data['account_password'] : '';
$customer_id = wc_create_new_customer( $data['billing_email'], $username, $password );
if ( is_wp_error( $customer_id ) ) {
throw new Exception( $customer_id->get_error_message() );
}
wp_set_current_user( $customer_id );
wc_set_customer_auth_cookie( $customer_id );
WC()->session->set( 'reload_checkout', true );
WC()->cart->calculate_totals();
}
if ( $customer_id && is_multisite() && is_user_logged_in() && ! is_user_member_of_blog() ) {
add_user_to_blog( get_current_blog_id(), $customer_id, 'customer' );
}
if ( $customer_id && apply_filters( 'woocommerce_checkout_update_customer_data', true) ) {
$customer = new WC_Customer( $customer_id );
if ( ! empty( $data['billing_first_name'] ) ) {
$customer->set_first_name( $data['billing_first_name'] );
}
if ( ! empty( $data['billing_last_name'] ) ) {
$customer->set_last_name( $data['billing_last_name'] );
}
if ( is_email( $customer->get_display_name() ) ) {
$customer->set_display_name( $data['billing_first_name'] . ' ' . $data['billing_last_name'] );
}
foreach ( $data as $key => $value ) {
if ( is_callable( array( $customer, "set_{$key}" ) ) ) {
$customer->{"set_{$key}"}( $value );
} elseif ( 0 === stripos( $key, 'billing_' ) || 0 === stripos( $key, 'shipping_' ) ) {
$customer->update_meta_data( $key, $value );
}
}
do_action( 'woocommerce_checkout_update_customer', $customer, $data );
$customer->save();
}
do_action( 'woocommerce_checkout_update_user_meta', $customer_id, $data );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class WC_Gateway_PayPal_Express_Request_AngellEYE {
public $confirm_order_id;
public $order_param;
public $user_email_address;
public $recipient;

public function __construct($gateway) {
try {
Expand Down Expand Up @@ -356,17 +355,6 @@ public function angelleye_do_express_checkout_payment() {
update_post_meta($order->get_id(), '_express_chekout_transactionid', isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : '' );
update_post_meta($order->get_id(), 'paypal_email', $payeremail);
}

if ($old_wc) {
update_post_meta($order_id, 'PayPal Transaction Fee', isset($this->paypal_response['PAYMENTINFO_0_FEEAMT']) ? $this->paypal_response['PAYMENTINFO_0_FEEAMT'] : '');
} else {
update_post_meta($order->get_id(), 'PayPal Transaction Fee', isset($this->paypal_response['PAYMENTINFO_0_FEEAMT']) ? $this->paypal_response['PAYMENTINFO_0_FEEAMT'] : '');
}
if ($old_wc) {
update_post_meta($order_id, 'Payment Type', isset($this->paypal_response['PAYMENTINFO_0_PAYMENTTYPE']) ? $this->paypal_response['PAYMENTINFO_0_PAYMENTTYPE'] : '');
} else {
update_post_meta($order->get_id(), 'Payment Type', isset($this->paypal_response['PAYMENTINFO_0_PAYMENTTYPE']) ? $this->paypal_response['PAYMENTINFO_0_PAYMENTTYPE'] : '');
}
$order->add_order_note(sprintf(__('%s payment Transaction ID: %s', 'paypal-for-woocommerce'), $this->gateway->title, isset($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']) ? $this->paypal_response['PAYMENTINFO_0_TRANSACTIONID'] : ''));
WC()->cart->empty_cart();
wc_clear_notices();
Expand Down Expand Up @@ -670,11 +658,9 @@ public function angelleye_set_express_checkout_request() {
);

if (empty($_GET['pay_for_order'])) {

$post_data = WC()->session->get('post_data');
if (!empty($post_data)) {
if( !empty($post_data['billing_email']) ) {
$SECFields['email'] = $post_data['billing_email'];
}
$SECFields['addroverride'] = 1;
if (!empty($post_data['ship_to_different_address'])) {
$shiptoname = '';
Expand All @@ -685,12 +671,14 @@ public function angelleye_set_express_checkout_request() {
} elseif (!empty($post_data['shipping_last_name'])) {
$shiptoname = $post_data['shipping_last_name'];
}

if (!empty($post_data['shipping_company'])) {
$shipping_company = $post_data['shipping_company'];
$Payment['shiptoname'] = wc_clean(stripslashes($shipping_company . ' - ' . $shiptoname));
} else {
$Payment['shiptoname'] = wc_clean(stripslashes($shiptoname));
}

$Payment['shiptostreet'] = !empty($post_data['shipping_address_1']) ? $post_data['shipping_address_1'] : '';
$Payment['shiptostreet2'] = !empty($post_data['shipping_address_2']) ? $post_data['shipping_address_2'] : '';
$Payment['shiptocity'] = !empty($post_data['shipping_city']) ? wc_clean(stripslashes($post_data['shipping_city'])) : '';
Expand Down Expand Up @@ -1008,9 +996,6 @@ public function angelleye_write_error_log_and_send_email_notification($paypal_ac
}
if ($this->gateway->error_email_notify) {
$mailer = WC()->mailer();
$recipients = array_map( 'trim', explode( ',', $this->gateway->recipient ) );
$recipients = array_filter( $recipients, 'is_email' );
$all_emails = implode( ', ', $recipients );
$error_email_notify_subject = apply_filters('ae_ppec_error_email_subject', 'PayPal Express Checkout Error Notification');
$message = sprintf(
"<strong>".__('PayPal %s API call failed', 'paypal-for-woocommerce')."</strong>" . PHP_EOL .PHP_EOL
Expand All @@ -1026,7 +1011,7 @@ public function angelleye_write_error_log_and_send_email_notification($paypal_ac
);
$message = apply_filters('ae_ppec_error_email_message', $message, $ErrorCode, $ErrorSeverityCode, $ErrorShortMsg, $ErrorLongMsg);
$message = $mailer->wrap_message($error_email_notify_subject, $message);
$mailer->send($all_emails, strip_tags($error_email_notify_subject), $message);
$mailer->send(get_option('admin_email'), strip_tags($error_email_notify_subject), $message);
}
if ($this->gateway->error_display_type == 'detailed') {
$sec_error_notice = $ErrorCode . ' - ' . $ErrorLongMsg;
Expand All @@ -1041,7 +1026,6 @@ public function angelleye_write_error_log_and_send_email_notification($paypal_ac
}

public function angelleye_write_paypal_request_log($paypal_action_name) {
WC_Gateway_PayPal_Express_AngellEYE::log('Environment: ' . $this->testmode);
if ($paypal_action_name == 'SetExpressCheckout') {
WC_Gateway_PayPal_Express_AngellEYE::log('Redirecting to PayPal');
WC_Gateway_PayPal_Express_AngellEYE::log(sprintf(__('PayPal for WooCommerce Version: %s', 'paypal-for-woocommerce'), VERSION_PFW));
Expand Down Expand Up @@ -1352,7 +1336,7 @@ public function DoReferenceTransaction($order_id) {
$PaymentDetails['itemamt'] = AngellEYE_Gateway_Paypal::number_format($this->order_param['itemamt']);
$PayPalRequestData['PaymentDetails'] = $PaymentDetails;
$this->paypal_response = $this->paypal->DoReferenceTransaction($PayPalRequestData);
AngellEYE_Gateway_Paypal::angelleye_paypal_for_woocommerce_curl_error_handler($this->paypal_response, $methos_name = 'DoExpressCheckoutPayment', $gateway = 'PayPal Express Checkout', $this->gateway->error_email_notify, $this->gateway->recipient);
AngellEYE_Gateway_Paypal::angelleye_paypal_for_woocommerce_curl_error_handler($this->paypal_response, $methos_name = 'DoExpressCheckoutPayment', $gateway = 'PayPal Express Checkout', $this->gateway->error_email_notify);
WC_Gateway_PayPal_Express_AngellEYE::log('Test Mode: ' . $this->testmode);
WC_Gateway_PayPal_Express_AngellEYE::log('Endpoint: ' . $this->gateway->API_Endpoint);
$PayPalRequest = isset($this->paypal_response['RAWREQUEST']) ? $this->paypal_response['RAWREQUEST'] : '';
Expand Down Expand Up @@ -1448,7 +1432,7 @@ public function angelleye_process_refund($order_id, $amount = null, $reason = ''
$this->paypal_response = $this->paypal->RefundTransaction($PayPalRequestData);


AngellEYE_Gateway_Paypal::angelleye_paypal_for_woocommerce_curl_error_handler($this->paypal_response, $methos_name = 'RefundTransaction', $gateway = 'PayPal Express Checkout', $this->gateway->error_email_notify, $this->gateway->recipient);
AngellEYE_Gateway_Paypal::angelleye_paypal_for_woocommerce_curl_error_handler($this->paypal_response, $methos_name = 'RefundTransaction', $gateway = 'PayPal Express Checkout', $this->gateway->error_email_notify);
WC_Gateway_PayPal_Express_AngellEYE::log('Test Mode: ' . $this->testmode);
WC_Gateway_PayPal_Express_AngellEYE::log('Endpoint: ' . $this->gateway->API_Endpoint);
$PayPalRequest = isset($this->paypal_response['RAWREQUEST']) ? $this->paypal_response['RAWREQUEST'] : '';
Expand Down
3 changes: 3 additions & 0 deletions assets/css/checkout.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@ p.woocommerce-SavedPaymentMethods-saveNew label {
margin-left: 0px;
margin-top: 12px;
}
.woocommerce form .form-row-last, .woocommerce-page form .form-row-last {
float: left;
}
}
1 change: 0 additions & 1 deletion classes/wc-gateway-braintree-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,6 @@ public function angelleye_do_payment($order) {
}

if ($this->debug) {
$this->add_log('Environment: ' . $this->environment);
$this->add_log('Begin Braintree_Transaction::sale request');
$this->add_log('Order: ' . print_r($order->get_order_number(), true));
$log = $request_data;
Expand Down
5 changes: 2 additions & 3 deletions classes/wc-gateway-paypal-advanced-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -1144,10 +1144,9 @@ public function receipt_page($order_id) {
$this->securetoken = $old_wc ? get_post_meta($order->id, '_secure_token', true) : get_post_meta($order->get_id(), '_secure_token', true);

//Log the browser and its version
if ($this->debug == 'yes') {
$this->add_log('Environment: ' . $PF_MODE);
if ($this->debug == 'yes')
$this->log->add('paypal_advanced', sprintf(__('Browser Info: %s', 'paypal-for-woocommerce'), $_SERVER['HTTP_USER_AGENT']));
}

//display the form in IFRAME, if it is layout C, otherwise redirect to paypal site
if ($this->layout == 'MINLAYOUT' || $this->layout == 'C') {
//define the url
Expand Down
4 changes: 2 additions & 2 deletions classes/wc-gateway-paypal-credit-cards-rest-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public function admin_options() {
<?php
if(version_compare(WC_VERSION,'2.6','<')) {
AngellEYE_Utility::woo_compatibility_notice();
} elseif (version_compare(phpversion(), '5.4', '<')) {
echo '<div class="error angelleye-notice" style="display:none;"><div class="angelleye-notice-logo"><span></span></div><div class="angelleye-notice-message">' . __('PayPal for WooCommerce requires PHP version 5.4 or higher.','paypal-for-woocommerce') . '</div></div>';
} elseif (version_compare(phpversion(), '5.3.0', '<')) {
echo '<div class="error angelleye-notice" style="display:none;"><div class="angelleye-notice-logo"><span></span></div><div class="angelleye-notice-message">' . __('PayPal for WooCommerce requires PHP version 5.3.0 or higher.','paypal-for-woocommerce') . '</div></div>';
} else {
$this->generate_settings_html();
}
Expand Down
Loading