diff --git a/src/Transaction.php b/src/Transaction.php index 4df9813..5d7e3c0 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -253,6 +253,10 @@ public function valid() $errors[] = Validator::set($params, 'pan') ? null : 'Credit card number not provided.'; $errors[] = Validator::set($params, 'expdate') ? null : 'Expiry date not provided.'; + break; + case 'res_delete': + $errors[] = Validator::set($params, 'data_key') ? null : 'Data key not provided.'; + break; default: $errors[] = $params['type'].' is not a supported transaction type.'; diff --git a/src/Vault.php b/src/Vault.php index 3f9f4c7..f42edc9 100644 --- a/src/Vault.php +++ b/src/Vault.php @@ -28,6 +28,8 @@ public function __construct(string $id, string $token, string $environment) } /** + * Add a credit card to the Vault. + * * @param \CraigPaul\Moneris\CreditCard $card * * @return \CraigPaul\Moneris\Response @@ -46,6 +48,26 @@ public function add(CreditCard $card) return $this->process($transaction); } + /** + * Delete a credit card from the Vault. + * + * @param string $key + * @param \CraigPaul\Moneris\CreditCard $card + * + * @return \CraigPaul\Moneris\Response + */ + public function delete(string $key) + { + $params = [ + 'type' => 'res_delete', + 'data_key' => $key, + ]; + + $transaction = $this->transaction($params); + + return $this->process($transaction); + } + /** * Create a new Vault instance. * @@ -61,6 +83,8 @@ public static function create(string $id, string $token, string $environment) } /** + * Update an existing credit card in the Vault. + * * @param string $key * @param \CraigPaul\Moneris\CreditCard $card *