Making WordPress.org

Ticket #1074: #1074.patch

File #1074.patch, 1.3 KB (added by saurabhshukla, 9 years ago)
  • addons/payment-paypal.php

    diff --git a/addons/payment-paypal.php b/addons/payment-paypal.php
    index ee99700..4e1f59d 100644
    a b  
    4242                        'api_password'  => '',
    4343                        'api_signature' => '',
    4444                        'sandbox'       => true,
     45                        'refund-expiry' => 60,
    4546                ), $this->get_payment_options() );
    4647
    4748                add_action( 'template_redirect', array( $this, 'template_redirect' ) );
     
    736737                /** @var $camptix CampTix_Plugin */
    737738                global $camptix;
    738739
     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
    739766                $result = $this->send_refund_request( $payment_token );
    740767
    741768                if ( CampTix_Plugin::PAYMENT_STATUS_REFUNDED != $result['status'] ) {