Exemplo n.º 1
0
 protected static function authorizeFromEnv()
 {
     $apiKey = getenv('PAYJP_API_KEY');
     if (!$apiKey) {
         $apiKey = self::API_KEY;
     }
     Payjp::setApiKey($apiKey);
 }
Exemplo n.º 2
0
 public function testInvalidCredentials()
 {
     Payjp::setApiKey('invalid');
     try {
         Customer::create();
     } catch (Error\Authentication $e) {
         $this->assertSame(401, $e->getHttpStatus());
     }
 }
Exemplo n.º 3
0
 public function testSave()
 {
     $customer = self::createTestCustomer();
     $customer->email = '*****@*****.**';
     $customer->save();
     $this->assertSame($customer->email, '*****@*****.**');
     $payjpCustomer = Customer::retrieve($customer->id);
     $this->assertSame($customer->email, $payjpCustomer->email);
     $this->assertSame('*****@*****.**', $customer->email);
     Payjp::setApiKey(null);
     $customer = Customer::create(null, self::API_KEY);
     $customer->email = '*****@*****.**';
     $customer->save();
     self::authorizeFromEnv();
     $updatedCustomer = Customer::retrieve($customer->id);
     $this->assertSame($updatedCustomer->email, '*****@*****.**');
     $this->assertSame('*****@*****.**', $customer->email);
 }