Página 1 de 1

Pequeño problema con return

NotaPublicado: 2015-01-22 08:44 @405
por luisbal
Estoy integrando mi sitio con stripe, el código es sencillo y he encontrado el módulo Perl (Business::Stripe).

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. my $stripe = Business::Stripe->new(
  2.    -api_key => 'c6EiNIusHip8x5hkdIjtur7KNUA3TTpE'
  3. );
  4.  
  5. $stripe->charges_create(
  6.     amount => 400,
  7.     card => 'tok_5EuIyKyCTc0f2V',
  8.     description => 'Ice cream'
  9. ) and return $stripe->success;
  10.  
  11. print $stripe->error->{message}, "\n";
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4

Les explico: quiero modificar esto, de modo que pueda manejarlo de este modo:
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
IF (SUCCESS){
HAGO ALGO
}
ELSE {
DEVUELVO ERROR
}
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


¿Pueden ayudarme, por favor?

Re: Pequeño problema con return

NotaPublicado: 2015-01-22 09:08 @422
por explorer
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. my $stripe = Business::Stripe->new(
  2.    -api_key => 'c6EiNIusHip8x5hkdIjtur7KNUA3TTpE'
  3. );
  4.  
  5. if ($stripe->charges_create(
  6.     amount => 400,
  7.     card => 'tok_5EuIyKyCTc0f2V',
  8.     description => 'Ice cream'
  9. )) {
  10.     ...;    # HACER ALGO
  11. }
  12. else {
  13.     print $stripe->error->{message}, "\n";
  14. }
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Re: Pequeño problema con return

NotaPublicado: 2015-01-22 09:35 @441
por luisbal
¡Gracias, explorer!