Exemplo n.º 1
0
 /**
  * Add order params to request.
  *
  * @param string[] $params
  * @param int      $money
  * @param string[] $options
  *
  * @return array
  */
 protected function addOrder(array $params, $money, array $options)
 {
     $params['order_id'] = Arr::get($options, 'reference');
     $params['order_name'] = Helper::ascii(Arr::get($options, 'description', 'PayMe Purchase'));
     $params['order_price'] = $this->gateway->amount($money);
     return $params;
 }
Exemplo n.º 2
0
 /**
  * Add payment method to request.
  *
  * @param string[] $params
  * @param mixed    $payment
  * @param string[] $options
  *
  * @return array
  */
 protected function addCard(array $params, $payment, array $options)
 {
     if (is_string($payment)) {
         if (Helper::startsWith($payment, 'cus')) {
             $params['customer'] = $payment;
         } else {
             $params['source'] = $payment;
         }
     }
     return $params;
 }
Exemplo n.º 3
0
 /**
  * Return the Api class instance for the given method.
  *
  * @param string $method
  *
  * @throws \BadMethodCallException
  *
  * @return \Shoperti\PayMe\Contracts\ApiInterface
  */
 protected function getApiInstance($method)
 {
     $gateway = Helper::className($this->getDriver());
     $class = "\\Shoperti\\PayMe\\Gateways\\{$gateway}\\" . Helper::className($method);
     if (!class_exists($class)) {
         throw new BadMethodCallException("Undefined method [{$method}] called.");
     }
     return new $class($this->gateway);
 }
Exemplo n.º 4
0
 /**
  * Add order params to request.
  *
  * @param string[] $params
  * @param int      $money
  * @param string[] $options
  *
  * @return array
  */
 protected function addOrder(array $params, $money, array $options)
 {
     return array_merge($params, ['amount' => $this->gateway->amount($money), 'currency' => Arr::get($options, 'currency', $this->gateway->getCurrency()), 'description' => Helper::ascii(Arr::get($options, 'description', 'PayMe Purchase')), 'order_id' => Arr::get($options, 'reference')]);
 }
Exemplo n.º 5
0
 /**
  * Add payment method to request.
  *
  * @param string[] $params
  * @param mixed    $payment
  * @param string[] $options
  *
  * @return array
  */
 protected function addPaymentMethod(array $params, $payment, array $options)
 {
     if (is_string($payment)) {
         if ($payment == 'spei') {
             $params['bank']['type'] = 'spei';
             $params['bank']['expires_at'] = Arr::get($options, 'expires', date('Y-m-d', time() + 172800));
         } elseif ($payment == 'oxxo') {
             $params['cash']['type'] = 'oxxo';
             $params['cash']['expires_at'] = Arr::get($options, 'expires', date('Y-m-d', time() + 172800));
         } elseif (Helper::startsWith($payment, 'payee_')) {
             $params['payee_id'] = $payment;
         } else {
             $params['card'] = $payment;
         }
     } elseif ($payment instanceof CreditCard) {
         $params['card'] = [];
         $params['card']['name'] = $payment->getName();
         $params['card']['cvc'] = $payment->getCvv();
         $params['card']['number'] = $payment->getNumber();
         $params['card']['exp_month'] = $payment->getExpiryMonth();
         $params['card']['exp_year'] = $payment->getExpiryYear();
         $params['card'] = $this->addAddress($params['card'], $options);
     }
     return $params;
 }
Exemplo n.º 6
0
 /**
  * Add order params to request.
  *
  * @param string[] $params
  * @param int      $money
  * @param string[] $options
  *
  * @return array
  */
 protected function addOrder(array $params, $money, array $options)
 {
     $params['PAYMENTREQUEST_0_DESC'] = Helper::ascii(Arr::get($options, 'description', 'PayMe Purchase'));
     $params['PAYMENTREQUEST_0_INVNUM'] = Arr::get($options, 'reference');
     $params['PAYMENTREQUEST_0_CURRENCYCODE'] = Arr::get($options, 'currency', $this->gateway->getCurrency());
     $params['PAYMENTREQUEST_0_AMT'] = $this->gateway->amount($money);
     $params = $this->addLineItems($params, $options);
     $params = $this->addShippingAddress($params, $options);
     return $params;
 }