Skip to content

Commit 90cbd6d

Browse files
committed
fix paystack event response code error
1 parent 726a9b1 commit 90cbd6d

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

includes/class-paystack-deprecated.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,12 @@ public function process_webhooks() {
397397
exit;
398398
}
399399

400-
http_response_code(200);
401-
402400
$event = json_decode( $json );
403401

404402
if( 'charge.success' == $event->event ) {
405403

404+
http_response_code(200);
405+
406406
$order_details = explode( '_', $event->data->reference );
407407

408408
$order_id = (int) $order_details[0];
@@ -416,7 +416,6 @@ public function process_webhooks() {
416416
}
417417

418418
if( in_array( $order->get_status(), array( 'processing', 'completed', 'on-hold' ) ) ) {
419-
wp_redirect( $this->get_return_url( $order ) );
420419
exit;
421420
}
422421

@@ -457,8 +456,10 @@ public function process_webhooks() {
457456
wc_empty_cart();
458457
}
459458

460-
wp_redirect( $this->get_return_url( $order ) );
459+
exit;
461460
}
461+
462+
exit;
462463
}
463464

464465
}

includes/class-paystack.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,12 @@ public function process_webhooks() {
567567
exit;
568568
}
569569

570-
http_response_code(200);
571-
572570
$event = json_decode( $json );
573571

574572
if( 'charge.success' == $event->event ) {
575573

574+
http_response_code(200);
575+
576576
$order_details = explode( '_', $event->data->reference );
577577

578578
$order_id = (int) $order_details[0];
@@ -586,7 +586,6 @@ public function process_webhooks() {
586586
}
587587

588588
if( in_array( $order->get_status(), array( 'processing', 'completed', 'on-hold' ) ) ) {
589-
wp_redirect( $this->get_return_url( $order ) );
590589
exit;
591590
}
592591

@@ -629,8 +628,10 @@ public function process_webhooks() {
629628

630629
$this->save_card_details( $event, $order->get_user_id(), $order_id );
631630

632-
wp_redirect( $this->get_return_url( $order ) );
631+
exit;
633632
}
633+
634+
exit;
634635
}
635636

636637

0 commit comments

Comments
 (0)