1. Home
  2. Docs
  3. Tutorial SDK Mercadopago
  4. Desarrollo

Desarrollo

Cobro desde lectores de tarjetas Point

    Dim mp As mllib.MPService
    Set mp = New mllib.MPService
    If mp.CreatePaymentIntent(mp.DefaultPoint, 10.1, mp.newUuid, False, "F-234") Then
        Dim PaymentId As String
        PaymentId = mp.CreatePaymentIntentResponse.Str("id")
        If mp.WaitPaymentIntent Then
            ' Obtengo informacion del pago
            Dim oPayment As mllib.IPayment
            Set oPayment = mp.GetPaymentResponseAsObj
            Dim Status As String
            Status = oPayment.Status ' approved or rejected
            MessageBox.Show (oPayment.JsonObj.AsJson)
        Else
            MessageBox.Show (mp.ErrorDesc)
        End If
    Else
        MessageBox.Show (mp.ErrorDesc)
    End If

Cobro desde QR

  Dim mp As mllib.MPService
  Dim Params As mllib.JsonObject
  Dim Item As mllib.JsonObject
  
  Set mp = New mllib.MPService
  Set Params = New mllib.JsonObject
  Params.Str("title") = "Pago QR"
  Params.Str("description") = "Pago mediante QR"
  Params.Dbl("total_amount") = 10.1
  Params.Str("external_reference") = mp.newUuid 'Se recomeienda que referencia externa debe ser unica para cada transaccion.
  Set Item = Params.Arr("items").Obj(0)
  Item.Str("title") = "Item 1"
  Item.Dbl("total_amount") = 10.1
  Item.Str("unit_measure") = "unit"
  Item.Dbl("quantity") = 1
  Item.Dbl("unit_price") = 10.1
  If mp.QRCreateOrder(Params) Then
    If mp.WaitQRPayment Then
      ' Obtengo informacion del pago. Json de ejemplo disponible en
      ' https://www.mercadopago.com.ar/developers/es/reference/payments/_payments_id/get
      Set oPayment = mp.GetPaymentResponseAsObj
      ' Guardar el id de pago en el sistema para consultarlo posteriormente en caso de ser necesario (mp.GetPayment(Id))
      id = oPayment.id
      Status = oPayment.Status ' approved, rejected, etc.
      If Status = "approved" Then
        date_approved = oPayment.date_approved
        transaction_amount = oPayment.transaction_amount
        ' Es el tipo de método de pago (tarjeta, transferencia bancaria, ticket, ATM, etc.)
        payment_type_id = oPayment.payment_type_id
        MsgBox ("Pago realizado con éxito. Id de operación  = " + id)
      ElseIf Status = "rejected" Then
        MsgBox ("El pago ha sido rechazado!")
      Else
        MsgBox ("El pago esta siendo procesado. Consulte el estado dentro de algunos minutos.")
      End If
    End If
  Else
    MsgBox (mp.ErrorDesc)
  End If

Recepción de transferencias

  ' UTILIZAR SÓLO SI NO SE RECIBEN TRANSFERENCIAS DE OTROS
  ' MEDIOS. VERIFICA LA ÚLTIMA TRANSFERENCIA RECIBIDA EN LA
  ' CUENTA.
  Dim mp As mllib.MPService 
  Set mp = New mllib.MPService
  If mp.WaitNextPayment Then
     oPayment = mp.GetPaymentResponseAsObj
     date_approved = oPayment.date_approved
     transaction_amount = oPayment.transaction_amount
     'Es el tipo de método de pago (tarjeta, transferencia bancaria, ticket, ATM, etc.)
     payment_type_id = oPayment.payment_type_id
  End If