Skip to content

POC: Transaction Objects #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@
class SV_WC_Payment_Gateway_Helper {


/** Sends through sale and request for funds to be charged to cardholder's credit card. */
const TRANSACTION_TYPE_CHARGE = 'charge';

/** Sends through a request for funds to be "reserved" on the cardholder's credit card. A standard authorization is reserved for 2-5 days. Reservation times are determined by cardholder's bank. */
const TRANSACTION_TYPE_AUTHORIZATION = 'authorization';

const TRANSACTION_TYPE_CAPTURE = 'capture';

const TRANSACTION_TYPE_REFUND = 'refund';

const TRANSACTION_TYPE_VOID = 'void';

const TRANSACTION_STATUS_APPROVED = 'approved';

const TRANSACTION_STATUS_HELD = 'held';

const TRANSACTION_STATUS_FAILED = 'failed';

/** @var string the Visa card type ID **/
const CARD_TYPE_VISA = 'visa';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* WooCommerce Payment Gateway Framework
*
* This source file is subject to the GNU General Public License v3.0
* that is bundled with this package in the file license.txt.
* It is also available through the world-wide-web at this URL:
* http://www.gnu.org/licenses/gpl-3.0.html
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@skyverge.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade the plugin to newer
* versions in the future. If you wish to customize the plugin for your
* needs please refer to http://www.skyverge.com
*
* @package SkyVerge/WooCommerce/Payment-Gateway/Transactions
* @author SkyVerge
* @copyright Copyright (c) 2013-2016, SkyVerge, Inc.
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
*/

defined( 'ABSPATH' ) or exit;

if ( ! class_exists( 'SV_WC_Payment_Gateway_Payment_Transaction' ) ) :


/**
* The base payment transaction class.
*
* @since 4.7.0-dev
*/
abstract class SV_WC_Payment_Gateway_Payment_Transaction extends SV_WC_Payment_Gateway_Transaction {


/** @var the attached payment method */
protected $payment_method = null;


/**
* Gets the payment method object.
*
* @since 4.7.0-dev
*
* @return \SV_WC_Payment_Gateway_Transaction_Payment_Method|null
*/
public function get_payment_method() {

return $this->payment_method;
}


/**
* Sets the payment method object.
*
* @since 4.7.0-dev
*
* @param \SV_WC_Payment_Gateway_Transaction_Payment_Method $payment_method payment method object
*/
public function set_payment_method( SV_WC_Payment_Gateway_Transaction_Payment_Method $payment_method ) {

$this->payment_method = $payment_method;

$this->get_payment_method()->set_transaction( $this );
}


/* CRUD methods ***********************************************************/


public function save() {

parent::save();

$this->get_payment_method()->save( $this->get_order_id() );
}


}

endif;
Loading