From d1522e2c71d7d2f79a5f4926319e8451d6d65a28 Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Fri, 21 Oct 2016 11:47:44 -0600 Subject: [PATCH] Adds add card method. Extends default gateway --- src/Vault.php | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/Vault.php b/src/Vault.php index 99e70e1..c816f5d 100644 --- a/src/Vault.php +++ b/src/Vault.php @@ -9,25 +9,10 @@ * @property-read string $id * @property-read string $token */ -class Vault +class Vault extends Gateway { use Gettable; - /** - * @var string - */ - protected $id; - - /** - * @var string - */ - protected $token; - - /** - * @var string - */ - protected $environment; - /** * Create a new Vault instance. * @@ -39,9 +24,26 @@ class Vault */ public function __construct(string $id, string $token, string $environment) { - $this->id = $id; - $this->token = $token; - $this->environment = $environment; + parent::__construct($id, $token, $environment); + } + + /** + * @param \CraigPaul\Moneris\CreditCard $card + * + * @return \CraigPaul\Moneris\Response + */ + public function add(CreditCard $card) + { + $params = [ + 'type' => 'res_add_cc', + 'crypt_type' => $card->crypt, + 'pan' => $card->number, + 'expdate' => $card->expiry, + ]; + + $transaction = $this->transaction($params); + + return $this->process($transaction); } /**