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

Commit

Permalink
Adds tokenization functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 21, 2016
1 parent ed0c92b commit 97b5fc1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public function valid()
}

break;
case 'res_tokenize_cc':
case 'purchasecorrection':
$errors[] = Validator::set($params, 'order_id') ? null : 'Order id not provided.';
$errors[] = Validator::set($params, 'txn_number') ? null : 'Transaction number not provided.';
Expand Down
27 changes: 27 additions & 0 deletions src/Vault.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,33 @@ public static function create(string $id, string $token, string $environment)
return new static($id, $token, $environment);
}

/**
* Tokenize a previous transaction to save the credit
* card used in the Moneris Vault.
*
* @param $transaction
* @param string|null $order
*
* @return \CraigPaul\Moneris\Response
*/
public function tokenize($transaction, string $order = null)
{
if ($transaction instanceof Transaction) {
$order = $transaction->order();
$transaction = $transaction->number();
}

$params = [
'type' => 'res_tokenize_cc',
'txn_number' => $transaction,
'order_id' => $order,
];

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

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

/**
* Update an existing credit card in the Vault.
*
Expand Down

0 comments on commit 97b5fc1

Please sign in to comment.