예제 #1
0
 /**
  * Create a customer.
  *
  * @param   array $data API data for customer creation
  * @param   Payplug\Payplug $payplug the client configuration
  *
  * @return  null|Customer the created Customer instance
  *
  * @throws  Payplug\Exception\ConfigurationNotSetException
  */
 public static function create(array $data, Payplug\Payplug $payplug = null)
 {
     if ($payplug === null) {
         $payplug = Payplug\Payplug::getDefaultConfiguration();
     }
     $httpClient = new Payplug\Core\HttpClient($payplug);
     $response = $httpClient->post(Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::CUSTOMER_RESOURCE), $data);
     return Payment::fromAttributes($response['httpResponse']);
 }
예제 #2
0
 /**
  * Creates a refund on a payment.
  *
  * @param   string|Payment      $payment        the payment id or the payment object
  * @param   array                       $data           API data for refund
  * @param   Payplug\Payplug $payplug  the client configuration
  *
  * @return  null|Refund the refund object
  * @throws  Payplug\Exception\ConfigurationNotSetException
  */
 public static function create($payment, array $data = null, Payplug\Payplug $payplug = null)
 {
     if ($payplug === null) {
         $payplug = Payplug\Payplug::getDefaultConfiguration();
     }
     if ($payment instanceof Payment) {
         $payment = $payment->id;
     }
     $httpClient = new Payplug\Core\HttpClient($payplug);
     $response = $httpClient->post(Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::REFUND_RESOURCE, null, array('PAYMENT_ID' => $payment)), $data);
     return Refund::fromAttributes($response['httpResponse']);
 }
예제 #3
0
 /**
  * Create a card.
  *
  * @param   Customer|string $customer The customer object or id
  * @param   array $data API data for customer creation
  * @param   Payplug\Payplug $payplug the client configuration
  *
  * @return  null|Card the created card
  *
  * @throws  Payplug\Exception\ConfigurationNotSetException
  */
 public static function create($customer, array $data, Payplug\Payplug $payplug = null)
 {
     if ($payplug === null) {
         $payplug = Payplug\Payplug::getDefaultConfiguration();
     }
     if ($customer instanceof Customer) {
         $customer = $customer->id;
     }
     $httpClient = new Payplug\Core\HttpClient($payplug);
     $response = $httpClient->post(Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::CARD_RESOURCE, null, array('CUSTOMER_ID' => $customer)), $data);
     return Payment::fromAttributes($response['httpResponse']);
 }