smartcoin/smartcoin-php

0.3.6 2015-05-20 19:09 UTC

This package is not auto-updated.

Last update: 2024-10-26 17:45:33 UTC


README

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 example@test.com'
  ));
  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 example@test.com'
  ));
  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' => 'test@examplo.com',
    "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