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

Commit

Permalink
Adds delete credit card functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 21, 2016
1 parent eb342d1 commit be50122
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
24 changes: 24 additions & 0 deletions src/Vault.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand All @@ -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
*
Expand Down

0 comments on commit be50122

Please sign in to comment.