Exemplo n.º 1
0
 /**
  * Create a payment source.
  *
  * @param  string $name    A meaningful name that will help you identify the source in Web Self Care environment
  * @param  string $code    A unique code that is exchanged between your application and the API
  * @param  string $url     The primary domain of your site WITH protocol scheme (http/https)
  * @param  string $fail    The relative path url your client will end up to, after a failed transaction
  * @param  string $success The relative path url your client will end up to, after a successful transaction
  * @return object
  */
 public function create($name, $code, $url, $fail, $success)
 {
     $uri = new Uri($url);
     return $this->client->post(self::ENDPOINT, [\GuzzleHttp\RequestOptions::FORM_PARAMS => ['Name' => $name, 'SourceCode' => $code, 'Domain' => $this->getDomain($uri), 'isSecure' => $this->isSecure($uri), 'PathFail' => $fail, 'PathSuccess' => $success]]);
 }
Exemplo n.º 2
0
 /**
  * Get a token for the credit card.
  *
  * @param  string $name   The cardholder's name
  * @param  mixed  $number The credit card number
  * @param  int    $cvc    The CVC number
  * @param  int    $month  The expiration month
  * @param  int    $year   The expiration year
  * @return string
  */
 public function token($name, $number, $cvc, $month, $year)
 {
     $token = $this->client->post(self::ENDPOINT, [\GuzzleHttp\RequestOptions::FORM_PARAMS => ['CardHolderName' => $name, 'Number' => $this->normalizeNumber($number), 'CVC' => $cvc, 'ExpirationDate' => $this->getExpirationDate($month, $year)], \GuzzleHttp\RequestOptions::QUERY => ['key' => $this->getKey()]]);
     return $token->Token;
 }
 /**
  * Create a recurring transaction.
  *
  * @param  string   $id
  * @param  int      $amount
  * @param  array    $parameters
  * @return object
  */
 public function createRecurring($id, $amount, array $parameters = [])
 {
     return $this->client->post(self::ENDPOINT . $id, [\GuzzleHttp\RequestOptions::FORM_PARAMS => array_merge(['Amount' => $amount], $parameters)]);
 }
Exemplo n.º 4
0
 /**
  * Create a payment order.
  *
  * @param  int   $amount     amount in cents
  * @param  array $parameters optional parameters (Full list available here: https://github.com/VivaPayments/API/wiki/Optional-Parameters)
  * @return int
  */
 public function create($amount, array $parameters = [])
 {
     $response = $this->client->post(self::ENDPOINT, [\GuzzleHttp\RequestOptions::FORM_PARAMS => array_merge(['Amount' => $amount], $parameters)]);
     return $response->OrderCode;
 }