0

I am trying to integrate omnipay into a website. The firts time I wanted to create a card, I came across this problem:

Omnipay: InvalidRequestException "The source parameter is required"

Here is my code:

$gateway = Omnipay::create('Stripe');
$gateway->setApiKey('sk_test_4IHf5iPTXVaZ8SF5GDcLTrqY');

$name_arr = explode(" ", $this->req['card-name']);

$card_data = [
    'firstname' => $name_arr[0],
    'surname' => $name_arr[1],
    'expiryMonth' => $this->req['exp-month'],
    'expiryYear' => $this->req['exp-year'],
    'number' => $this->req['card-number'],
    'email' => $client['email'],
    'cvv' => $this->req['cvv']
];

$response = $gateway->createCard($card_data)->send();

What am I missing, or doing wrong? Thanks!

cfreear
  • 1,855
  • 2
  • 19
  • 25
Eva
  • 133
  • 1
  • 14

1 Answers1

0

Ok, sorry, I have found the solution! Data has to be in the following format:

      $card_data = ['card' =>[
            'firstname' => $name_arr[0],
            'surname' => $name_arr[1],
            'expiryMonth' => $this->req['exp-month'],
            'expiryYear' => $this->req['exp-year'],
            'number' => $this->req['card-number'],
            'cvv' => $this->req['cvc']
        ]];
Eva
  • 133
  • 1
  • 14