Skip to content

smartcoinpayments/smartcoin-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Latest Stable Version License

Crie sua conta na Smartcoin.

Vamos fazer

Exemplo de uso:

\Smartcoin\Smartcoin::api_key('pk_test_407d1f51a61756');
\Smartcoin\Smartcoin::api_secret('sk_test_86e4486a0078b2');

//Credit Card Charge without token as card param
try {
  $charge = \Smartcoin\Charge::create(array(
    'amount' => 100,
    'currency' => 'brl',
    'card' => array(
      'number' => '4242424242424242',
      'exp_month' => 10,
      'exp_year' => 15,
      'cvc' => '083'
    ),
    'description' => 'Smartcoin charge test for [email protected]'
  ));
  echo $charge->to_json();  
}catch(\Smartcoin\Error $e){
  echo json_encode($e->get_json_body());
}

//Credit Card Charge with token as card param
try {
  $charge = \Smartcoin\Charge::create(array(
    'amount' => 100,
    'currency' => 'brl',
    'card' => 'tok_434343434343434343434',
    'description' => 'Smartcoin charge test for [email protected]'
  ));
  echo $charge->to_json();  
}catch(\Smartcoin\Error $e){
  echo json_encode($e->get_json_body());
}

//Bank Slip Charge
try {
  $charge = \Smartcoin\Charge::create(array(
    'amount' => 1000,
    'currency' => 'brl',
    'type' => 'bank_slip'
  ));
  echo $charge->to_json();
}catch(\Smartcoin\Error $e){
  echo json_encode($e->get_json_body());
}

//Create Subscription
try {
  $customer = \Smartcoin\Customer::create(array(
    'email' => '[email protected]',
    "card" => array('number' => 5454545454545454,
                    'exp_month' => 11,
                    'exp_year' => 2017,
                    'cvc' => 111,
                    'name' => 'Doctor Who')
      ));

  $sub = $customer->subscriptions()->create(array(
    'plan' => 'silver'
  ));
  echo $sub->to_json();
}catch(\Smartcoin\Error $e){
  echo json_encode($e->get_json_body());
}

Veja os testes para mais exemplos.

Teste

Para instalar a suite de teste, execute o SimpleTest via Composer:

composer update --dev

Para executar o teste:

php ./test/Smartcoin.php

About

Smartcoin library for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages