Skip to content

Commit

Permalink
total amount check added on success url
Browse files Browse the repository at this point in the history
  • Loading branch information
airmax-7 committed Oct 9, 2020
1 parent 0d4180b commit ed90465
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions woo-yenepay.php
Expand Up @@ -230,11 +230,15 @@ public function success_webhook() {
//cURL used here to call yenepay's payment gateway API
$result = $checkoutHelper->RequestPDT($pdtModel);
if($result['result'] == 'SUCCESS' && ($result['Status'] == 'Paid' || $result['Status'] == 'Delivered' || $result['Status'] == 'Completed')){
// Payment complete
$order->payment_complete();
// Add order note
$order->add_order_note( sprintf( __( 'YenePay payment approved! Transaction ID: %s ', 'woocommerce' ), $transactionId ) );

if(floatval($result['TotalAmount']) == $order->get_total()){
// Payment complete
$order->payment_complete();
// Add order note
$order->add_order_note( sprintf( __( 'YenePay payment approved! Transaction ID: %s ', 'woocommerce' ), $transactionId ) );
}
else{
self::log("Total amount mismatch on PDT request for order: ".$order_id);
}
}
else{
self::log("failed PDT request. PDT result is: ".var_dump($result));
Expand Down Expand Up @@ -310,7 +314,7 @@ public function ipn_webhook(){
$helper = new CheckoutHelper();

//check if the order total here and the total amount sent via ipn match
if(floatval($_POST['TotalAmount']) == $wc_order->get_order_total){
if(floatval($_POST['TotalAmount']) == $wc_order->get_total()){
//Call yenepay's payment gateway API and check the IPN validity
//cURL used here to call yenepay's payment gateway API
if($helper->isIPNAuthentic($ipnModel))
Expand Down

0 comments on commit ed90465

Please sign in to comment.