Métodos de pago para Chile y el mundo

Seba Gamboa

CTO en Welcu

  • github.com/sagmor
  • twitter.com/sagmor

Cobrar en latinoamerica es un parto

En serio si pueden evitarlo, haganlo!

Awww, Stripe...


Stripe.api_key = "sk_test_mkGsLqEW6SLnZa487HYfJVLf"

Stripe::Charge.create(
  amount: 400,
  currency: "usd",
  card: {
    name: "John Doe",
    number: 4111111111111111,
    exp_month: 1,
    exp_year: 2014,
    cvc: 123
  },
  description: "Give me the money!"
)
          

Awww, Stripe...


$ curl https://api.stripe.com/v1/charges \
    -u "sk_test_mkGsLqEW6SLnZa487HYfJVLf:" \
    -d "amount=400" \
    -d "currency=usd" \
    -d "card[name]=John Doe" \
    -d "card[number]=4111111111111111" \
    -d "card[exp_month]=1" \
    -d "card[exp_year]=2014" \
    -d "card[cvc]=123" \
    -d "description=Mum me can charge from thy terminal!"
          

"US Only" :(

Pero he oido de excepciones ;)

Paypal to the rescue

All new API


curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H 'Content-Type:application/json' \
-H 'Authorization:Bearer EOjEJigcsRhdOgD7_76lPfrr45UfuI43zzNzTktUk1MK' \
-d '{
  "intent":"sale",
  "redirect_urls":{
    "return_url":"http://return URL here",
    "cancel_url":"http://cancel URL here"
  },
  "payer":{
    "payment_method":"paypal"
  },
  "transactions":[
    {
      "amount":{
        "total":"7.47",
        "currency":"USD"
      },
      "description":"This is the payment transaction description."
    }
  ]
}'
          

https://developer.paypal.com/webapps/developer/docs/integration/web/accept-paypal-payment/

Show me the money!

Retira tu platita con Retiros Multicaja
https://www.multicaja.cl/retiros/

A veces na' que hacerle

Aceptar débito, aceptar CLP

Chan, chan, chaaaaaaann!!!!!

What if!

No CGIs

include TBK


@payment = Webpay::Payment.new({
  amount: 10_000,
  order_id: 1234,
  success_url: webpay_success_url,
  confirmation_url: webpay_confirmation_url
  failure_url: webpay_failure_url
})

redirect_to @payment.redirect_url
          

http://sagmor.com/tbk

Iniciar un Pago


class WebpayController < ApplicationController
  def pay
    @payment = TBK::Webpay::Payment.new({
      amount: ORDER_AMOUNT,
      order_id: ORDER_ID,
      success_url: webpay_success_url,
      # Webpay can only access the HTTP protocol to a direct IP address (keep that in mind)
      confirmation_url: webpay_confirmation_url(host: SERVER_IP_ADDRESS, protocol: 'http'),
      failure_url: webpay_failure_url # success_url is used by default
    })

    # Redirect the user to Webpay
    redirect_to @payment.redirect_url
  end
end
          

Confirmar el pago


class WebpayController < ApplicationController
  def confirmation
    @confirmation = TBK::Webpay::Confirmation.new(request.raw_post)

    if ... # confirmation is invalid for some reason (wrong order_id or amount, double payment, etc...)
      render text: @confirmation.reject
      return # reject and stop execution
    end

    if @confirmation.success?
      # EXITO!
      # perform everything you have to do here.
    end

    # Acknowledge payment
    render text: @confirmation.acknowledge
  end

end
          

¿Funciona?

creo que $500.000.000+ procesados de esta forma lo demuestran

Pendientes

  • Logger compatible con CGIs
    (Pa' que transbank no webee)
  • github.com/sagmor/tbk/issues

'U no liking using Ruby?

meesa Sorry :(

  1. https://github.com/sagmor/tbk/tree/master/lib/tbk/webpay
  2. http://sagmor.com/rants/technical/webpay-communication-protocol/

¡Hack Transbank!

Tranquilos no ese tipo de hacking ;)

Alguien dijo "Transbank developer network"?

Alguien les tiene que hacer la pega parece

Issue #16

https://github.com/sagmor/tbk/issues/16

Y latinoamerica?

Bastante menos documentadas pero con interfaz similar

  • github.com/sagmor/pagosonline
  • github.com/sagmor/pag_seguro
  • github.com/sagmor/mercado_pago

Muchas gracias

¿Preguntas?