Cards

The Payments module let's you safely store cards and charge them by token.

Creating Cards

After installing and configuring your payment gateway extension(s) you can create a card like this:

$card = new CardModel(
    [
        'first_name'       => 'Ryan',
        'last_name'        => 'Thompson',
        'number'           => '4242424242424242',
        'type'             => 'visa',
        'security_code'    => '123',
        'expiration_month' => '12',
        'expiration_year'  => '2020',
        'gateway'          => 'stripe',
    ]
);

$card->send(); // Returns bool

echo $card->getCardReference(); // Gateway reference to card

The gateway value can be an instance or any valid string identifier.

Charging Cards

Charging cards is very much like making normal payments with a PaymentInterface instance.

$cards = app(CardRepositoryInterface::class);

$card = $cards->findByStrId($id);

$payment = new PaymentModel(
    [
        'amount'   => 25.00,
        'currency' => 'USD',
        'card'     => $card,
        'gateway'  => 'stripe', // Must match card's gateway.
        'related'  => $order, // Optional related order / product / object
    ]
);

$payment->purchase(); // Returns bool

Deleting Cards

To delete cards simply delete the card model.