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

Commit

Permalink
Adds purchase ability through vault
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 23, 2016
1 parent 93c0ca8 commit 8f186ef
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ public function valid()
case 'res_lookup_masked':
$errors[] = Validator::set($params, 'data_key') ? null : 'Data key not provided.';

break;
case 'res_purchase_cc':
$errors[] = Validator::set($params, 'data_key') ? null : 'Data key not provided.';
$errors[] = Validator::set($params, 'order_id') ? null : 'Order id not provided.';
$errors[] = Validator::set($params, 'amount') ? null : 'Amount not provided.';

break;
default:
$errors[] = $params['type'].' is not a supported transaction type.';
Expand Down
47 changes: 33 additions & 14 deletions src/Vault.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ public function add(CreditCard $card)
return $this->process($transaction);
}

/**
* Create a new Vault instance.
*
* @param string $id
* @param string $token
* @param string $environment
*
* @return $this
*/
public static function create(string $id, string $token, string $environment)
{
return new static($id, $token, $environment);
}

/**
* Delete a credit card from the Vault.
*
Expand All @@ -68,20 +82,6 @@ public function delete(string $key)
return $this->process($transaction);
}

/**
* Create a new Vault instance.
*
* @param string $id
* @param string $token
* @param string $environment
*
* @return $this
*/
public static function create(string $id, string $token, string $environment)
{
return new static($id, $token, $environment);
}

/**
* Get all expiring credit cards from the Moneris Vault.
*
Expand Down Expand Up @@ -117,6 +117,25 @@ public function peek(string $key, bool $full = false)
return $this->process($transaction);
}

/**
* Make a purchase.
*
* @param array $params
*
* @return \CraigPaul\Moneris\Response
*/
public function purchase(array $params = [])
{
$params = array_merge($params, [
'type' => 'res_purchase_cc',
'crypt_type' => Crypt::SSL_ENABLED_MERCHANT,
]);

$transaction = $this->transaction($params);

return $this->process($transaction);
}

/**
* Tokenize a previous transaction to save the credit
* card used in the Moneris Vault.
Expand Down

0 comments on commit 8f186ef

Please sign in to comment.