Beispiel #1
0
 public static function getClients(array $filter = [])
 {
     $request = new \Paymill\Request(\Config::get('laramill::private'));
     $client = new \Paymill\Models\Request\Client();
     $client->setFilter($filter);
     $response = $request->getAll($client);
     return $response;
 }
Beispiel #2
0
 public function client($description = null)
 {
     $this->currentAction = 'client';
     $client = new \Paymill\Models\Request\Client();
     $client->setEmail($this->email)->setDescription($description);
     if ($this->client_id) {
         $client->setId($this->client_id);
     }
     return new PaymillGateway($this, $client);
 }
Beispiel #3
0
 /**
  * Get the client for future requests.
  * If no client definition is found, the client will be set to null. A new
  * client will be created if none is found for the given 'email'.
  *
  * @param array $data Array containing a mandatory 'email' key and an
  *                    optional 'description' key.
  *
  * @return string Client id
  *
  * @throws \Paymill\Services\PaymillException
  */
 public function getClient($data)
 {
     if (!is_array($data) || !isset($data['email'])) {
         return;
     }
     $client = new \Paymill\Models\Request\Client();
     $client->setFilter(array('email' => $data['email']));
     $client = $this->getAll($client);
     if ($client) {
         return $client[0]['id'];
     } else {
         // client not found, create a new one
         $client = new \Paymill\Models\Request\Client();
         $client->setEmail($data['email'])->setDescription(isset($data['description']) ? $data['description'] : null);
         $client = $this->create($client);
         return $client->getId();
     }
 }
    <head>
        <meta http-equiv="content-type"
              content="text/html; charset=utf-8"/>
       <?php 
//
// Please download the Paymill PHP Wrapper using composer.
// If you don't already use Composer,
// then you probably should read the installation guide http://getcomposer.org/download/.
//
//Change the following constants
define('PAYMILL_API_KEY', 'YOUR_API_KEY');
define('CUSTOMER_EMAIL', 'SOME_TEST_EMAIL');
require 'vendor/autoload.php';
if (isset($_POST['paymillToken'])) {
    $service = new Paymill\Request(PAYMILL_API_KEY);
    $client = new Paymill\Models\Request\Client();
    $payment = new Paymill\Models\Request\Payment();
    $offer = new Paymill\Models\Request\Offer();
    $subscription = new Paymill\Models\Request\Subscription();
    try {
        $client->setEmail(CUSTOMER_EMAIL);
        $client->setDescription('This is a Testuser.');
        $clientResponse = $service->create($client);
        $payment->setClient($clientResponse->getId());
        $payment->setToken($_POST['paymillToken']);
        $paymentResponse = $service->create($payment);
        $offer->setAmount($_POST['amount'])->setCurrency($_POST['currency'])->setInterval($_POST['interval'])->setName($_POST['offer-name']);
        $offerResponse = $service->create($offer);
        $subscription->setClient($clientResponse->getId());
        $subscription->setPayment($paymentResponse->getId());
        $subscription->setOffer($offerResponse->getId());
 /**
  * @param $email
  * @param $details
  *
  * @return bool|string
  */
 public function createClient($email, $details)
 {
     $client = new \Paymill\Models\Request\Client();
     $client->setEmail($email);
     $client->setDescription($details);
     try {
         $response = $this->request->create($client);
     } catch (\Paymill\Services\PaymillException $e) {
         s($e->getResponseCode());
         s($e->getStatusCode());
         s($e->getErrorMessage());
         return false;
     }
     return $response->getId();
 }