Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- final class Payment {
- public function subscribe(array $transaction) : array {
- // 1
- $transaction = [
- 'payment_method' => $transaction['payment_method'] ?? 'credit-card',
- 'amount' => $transaction['total'] ?? $transaction['subtotal'] ?? 0.0,
- 'currency' => $transaction['currency_code'] ?? 'USD'
- ] + $transaction;
- $model = new TransactionModel();
- $model->create($transaction);
- // 2
- $processor = $model->getProcessor($transaction);
- $transaction['processor_id'] = $processor['id'] ?? null;
- // 3
- $status = $model->process($transaction);
- $transaction['status'] = $status['success'] ?? false;
- // 4
- unset($transaction['card-number'], $transaction['ccv']);
- return $transaction;
- }
- }
Add Comment
Please, Sign In to add comment