|
94 | 94 | $externalRef = $_POST["ORIGINAL_REFNOEXT"][0]; |
95 | 95 | $serviceId = $_POST["IPN_EXTERNAL_REFERENCE"][0]; |
96 | 96 | $serviceId = preg_replace( '/\D/', '', $serviceId ); |
97 | | - checkCbTransID( $transactionId ); |
98 | | - $newInvoiceItem = (array) Capsule::table( 'tblinvoiceitems' ) |
99 | | - ->join( 'tblinvoices', 'tblinvoiceitems.invoiceid', '=', 'tblinvoices.id' ) |
100 | | - ->where( 'tblinvoiceitems.relid', $serviceId ) |
101 | | - ->where( 'tblinvoices.status', 'Unpaid' ) |
102 | | - ->first(); |
103 | | - $invoiceId = $newInvoiceItem['invoiceid']; |
104 | | - $orderData = TwocheckoutApiInline::callAPI( "GET", "orders/" . $transactionId . "/", |
105 | | - $twocheckoutConfig ); |
106 | | - $paymentAmount = 0; |
107 | | - if ( ! empty( $_POST['IPN_PRICE'] ) ) { |
108 | | - foreach ( $_POST['IPN_PRICE'] as $priceAdd ) { |
109 | | - $paymentAmount = $paymentAmount + $priceAdd; |
| 97 | + if (!empty($externalRef) && !empty($serviceId)) { |
| 98 | + checkCbTransID( $transactionId ); |
| 99 | + $newInvoiceItem = (array) Capsule::table( 'tblinvoiceitems' ) |
| 100 | + ->join( 'tblinvoices', 'tblinvoiceitems.invoiceid', '=', 'tblinvoices.id' ) |
| 101 | + ->where( 'tblinvoiceitems.relid', $serviceId ) |
| 102 | + ->where( 'tblinvoices.status', 'Unpaid' ) |
| 103 | + ->first(); |
| 104 | + $invoiceId = $newInvoiceItem['invoiceid']; |
| 105 | + $orderData = TwocheckoutApiInline::callAPI( "GET", "orders/" . $transactionId . "/", |
| 106 | + $twocheckoutConfig ); |
| 107 | + $paymentAmount = 0; |
| 108 | + if ( ! empty( $_POST['IPN_PRICE'] ) ) { |
| 109 | + foreach ( $_POST['IPN_PRICE'] as $priceAdd ) { |
| 110 | + $paymentAmount = $paymentAmount + $priceAdd; |
| 111 | + } |
110 | 112 | } |
111 | | - } |
112 | | - if ( ! empty( $invoiceId ) && in_array( $orderData['Status'], [ 'AUTHRECEIVED', 'COMPLETE' ] ) ) { |
113 | | - addInvoicePayment( $invoiceId, $transactionId, $paymentAmount, null, $twocheckoutConfig['name'] ); |
| 113 | + if ( ! empty( $invoiceId ) && in_array( $orderData['Status'], [ 'AUTHRECEIVED', 'COMPLETE' ] ) ) { |
| 114 | + addInvoicePayment( $invoiceId, $transactionId, $paymentAmount, null, $twocheckoutConfig['name'] ); |
| 115 | + } |
| 116 | + } else { |
| 117 | + logModuleCall($gatewayModuleName, 'error', '', 'Recurring 2Checkout transaction ' . $transactionId . ' IPN with no item external reference'); |
114 | 118 | } |
115 | 119 | // IPN for any case other than recurring |
116 | 120 | } else { |
|
0 commit comments