diff --git a/addons/payment-paypal.php b/addons/payment-paypal.php
index ee99700..4e1f59d 100644
a
|
b
|
|
42 | 42 | 'api_password' => '', |
43 | 43 | 'api_signature' => '', |
44 | 44 | 'sandbox' => true, |
| 45 | 'refund-expiry' => 60, |
45 | 46 | ), $this->get_payment_options() ); |
46 | 47 | |
47 | 48 | add_action( 'template_redirect', array( $this, 'template_redirect' ) ); |
… |
… |
|
736 | 737 | /** @var $camptix CampTix_Plugin */ |
737 | 738 | global $camptix; |
738 | 739 | |
| 740 | // assume it is refundable |
| 741 | $is_refundable = true; |
| 742 | |
| 743 | $refund_expiry = $this->options['refund-expiry']; |
| 744 | |
| 745 | if ( ! empty( $refund_expiry ) ){ |
| 746 | |
| 747 | $today = date( 'Y-m-d' ); |
| 748 | |
| 749 | $txn_details = $camptix->get_post_meta_from_payment_token( $payment_token, 'tix_transaction_details' ); |
| 750 | |
| 751 | $txn_date = $txn_details['raw']['TIMESTAMP']; |
| 752 | |
| 753 | // more than 60 days since transaction |
| 754 | if( strtotime( $txn_date ."+ $refund_expiry days" ) < strtotime( $today ) ) |
| 755 | $is_refundable = false; |
| 756 | |
| 757 | } |
| 758 | |
| 759 | if ( ! $is_refundable ){ |
| 760 | |
| 761 | $camptix->error( sprintf( __( 'Paypal only allows refunds within %d days of purchase.' ), $refund_expiry ) ); |
| 762 | |
| 763 | return false; |
| 764 | } |
| 765 | |
739 | 766 | $result = $this->send_refund_request( $payment_token ); |
740 | 767 | |
741 | 768 | if ( CampTix_Plugin::PAYMENT_STATUS_REFUNDED != $result['status'] ) { |