Exemple #1
0
 /**
  * Make a "one off" charge on the customer for the given amount.
  *
  * @param  int  $amount
  * @param  array  $options
  * @return bool|mixed
  */
 public function charge($amount, array $options = [])
 {
     $options = array_merge(['currency' => $this->getCurrency()], $options);
     $options['amount'] = $amount;
     if (!array_key_exists('source', $options) && $this->billable->hasGatewayId()) {
         $options['customer'] = $this->billable->getGatewayId();
     }
     if (!array_key_exists('source', $options) && !array_key_exists('customer', $options)) {
         throw new InvalidArgumentException('No payment source provided.');
     }
     try {
         $response = GatewayCharge::create($options);
     } catch (GatewayErrorCard $e) {
         return false;
     }
     return $response;
 }