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

DoDirectPayment - Display Blank Message, PFW-321 #1250

Merged
merged 1 commit into from Dec 8, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions classes/wc-gateway-paypal-pro-angelleye.php
Expand Up @@ -1620,6 +1620,8 @@ public function add_payment_method() {
'PaymentDetails' => $PaymentDetails
);
$result = $this->PayPal->DoDirectPayment(apply_filters('angelleye_woocommerce_do_direct_payment_request_args', $PayPalRequestData));
$redirect_url = wc_get_account_endpoint_url('payment-methods');
AngellEYE_Gateway_Paypal::angelleye_paypal_for_woocommerce_curl_error_handler($result, $methos_name = 'DoDirectPayment', $gateway = 'PayPal Website Payments Pro (DoDirectPayment)', $this->error_email_notify, $redirect_url);
if ($result['ACK'] == 'Success' || $result['ACK'] == 'SuccessWithWarning') {
$customer_id = get_current_user_id();
$TRANSACTIONID = $result['TRANSACTIONID'];
Expand Down
8 changes: 6 additions & 2 deletions paypal-for-woocommerce.php
Expand Up @@ -526,7 +526,7 @@ function angelleye_woocommerce_process_product_meta_own( $post_id ){
update_post_meta( $post_id, '_enable_ec_button', $_enable_ec_button );
}

public static function angelleye_paypal_for_woocommerce_curl_error_handler($PayPalResult, $methos_name = null, $gateway = null, $error_email_notify = true) {
public static function angelleye_paypal_for_woocommerce_curl_error_handler($PayPalResult, $methos_name = null, $gateway = null, $error_email_notify = true, $redirect_url = null) {
if( isset( $PayPalResult['CURL_ERROR'] ) ){
try {
if($error_email_notify == true) {
Expand All @@ -539,7 +539,11 @@ public static function angelleye_paypal_for_woocommerce_curl_error_handler($PayP
$display_error = 'There was a problem connecting to the payment gateway.';
wc_add_notice($display_error, 'error');
if (!is_ajax()) {
wp_redirect(get_permalink(wc_get_page_id('cart')));
if($redirect_url == null) {
wp_redirect(get_permalink(wc_get_page_id('cart')));
} else {
wp_redirect($redirect_url);
}
exit;
} else {
wp_send_json_error( array( 'error' => $display_error ) );
Expand Down