| Conditions | 7 |
| Paths | 16 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 20 | function paiementpro4give_verify_payment() { |
||
| 21 | |||
| 22 | $getData = give_clean( $_GET ); |
||
|
|
|||
| 23 | $donationId = ! empty( $getData['order_id'] ) ? $getData['order_id'] : false; |
||
| 24 | $transactionId = ! empty( $getData['pp_status'] ) ? $getData['pp_status'] : ''; |
||
| 25 | |||
| 26 | // Bailout, if donation id not received from paiementpro gateway. |
||
| 27 | if ( ! $donationId ) { |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | |||
| 31 | $donationGateway = give_get_payment_gateway( $donationId ); |
||
| 32 | $supportedGateways = paiementpro4give_get_supported_payment_methods(); |
||
| 33 | |||
| 34 | // Bailout, if not `$donationGateway` payment gateway. |
||
| 35 | if ( ! in_array( $donationGateway, $supportedGateways, true ) ) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | $credentialId = paiementpro4give_get_credential_id(); |
||
| 40 | $merchantId = paiementpro4give_get_merchant_id(); |
||
| 41 | $successStatus = sha1("{$donationId}success{$merchantId}{$credentialId}" ); |
||
| 42 | |||
| 43 | // Success, if transaction id exists, else failed. |
||
| 44 | if ( ! empty( $transactionId ) && $transactionId === $successStatus ) { |
||
| 45 | give_update_payment_status( $donationId, 'publish' ); |
||
| 46 | } else { |
||
| 47 | give_update_payment_status( $donationId, 'failed' ); |
||
| 48 | } |
||
| 51 | add_action( 'init', 'paiementpro4give_verify_payment' ); |
||