Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
src/
Browse files Browse the repository at this point in the history
Adds cards method to access the vault
  • Loading branch information
Craig Paul committed Oct 21, 2016
1 parent 61145f4 commit 3708147
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ public function capture($transaction, string $order = null, $amount = null)
return $this->process($transaction);
}

public function cards()
{
return new Vault($this->id, $this->token, $this->environment);
}

/**
* Pre-authorize a purchase.
*
Expand Down
46 changes: 46 additions & 0 deletions src/Vault.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace CraigPaul\Moneris;

/**
* CraigPaul\Moneris\Vault
*
* @property-read string $environment
* @property-read string $id
* @property-read string $token
*/
class Vault
{
use Gettable;

/**
* @var string
*/
protected $id;

/**
* @var string
*/
protected $token;

/**
* @var string
*/
protected $environment;

/**
* Create a new Vault instance.
*
* @param string $id
* @param string $token
* @param string $environment
*
* @return void
*/
public function __construct(string $id, string $token, string $environment)
{
$this->id = $id;
$this->token = $token;
$this->environment = $environment;
}
}
12 changes: 12 additions & 0 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use CraigPaul\Moneris\Vault;
use CraigPaul\Moneris\Gateway;
use CraigPaul\Moneris\Moneris;
use CraigPaul\Moneris\Response;
Expand Down Expand Up @@ -114,4 +115,15 @@ public function it_can_capture_a_pre_authorized_transaction_and_receive_a_respon
$this->assertEquals(Response::class, get_class($response));
$this->assertTrue($response->successful);
}

/** @test */
public function it_can_access_the_vault_functionality_to_handle_credit_card_data()
{
$vault = $this->gateway->cards();

$this->assertEquals(Vault::class, get_class($vault));
$this->assertObjectHasAttribute('id', $vault);
$this->assertObjectHasAttribute('token', $vault);
$this->assertObjectHasAttribute('environment', $vault);
}
}

0 comments on commit 3708147

Please sign in to comment.