Skip to content

Latest commit

 

History

History
1534 lines (1449 loc) · 50 KB

README.VisualBasic.md

File metadata and controls

1534 lines (1449 loc) · 50 KB

Ler em outras linguagens de programação: C#, F#.

Índice - Visual Basic

Implementações .NET com suporte

Essa biblioteca foi feito em (.NET Standard 1.2 e VS2017) e tem suporte das seguintes implementações do .NET:

  • .NET Core 1.0 ou superior
  • .NET Framework 4.5.1 ou superior
  • Mono 4.6 ou superior
  • Xamarin.iOS 10.0 ou superior
  • Xamarin.Android 7.0 ou superior
  • Universal Windows Platform 10 ou superior
  • Windows 8.1 ou superior
  • Windows Phone 8.1 ou superior

Para mais informações: .NET Standard.

Aviso Importante

Pensando em melhorar ainda mais a sua segurança e para atender a padrões internacionais do nosso selo PCI Compliance, o Wirecard desativará protocolos de segurança TLS (Transport Layer Security) inferiores a 1.2 à partir do dia 30/06/2018. Verifique se o seu projeto já possui TLS na versão 1.2, caso não, você receberá uma exceção:

- InnerException = {"A solicitação foi anulada: Não foi possível criar um canal seguro para SSL/TLS."}

Para isso, adicione o seguinte código no seu projeto:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Para mais informações : TLS1.2.

Instalação

Execute o comando para instalar via NuGet:

PM> Install-Package Wirecard

💥 Obs: Trocamos a biblioteca MoipCSharp por Wirecard.

Autenticando e configurando o ambiente (E-Commerce)

Escolha o "ambiente" você quer executar suas ações e informe seu (token, chave):

Imports Wirecard
Imports Wirecard.Models

Private Const Token As String = "xxxxxxxxxxxxxxxxxxx"
Private Const Key As String = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
Private WC As New WirecardClient(Environments.SANDBOX, Token, Key)

Para obter um token e a chave, primeiro faça o login aqui.

Você pode acessá-las em Minha conta > Configurações > Chaves de Acesso.

Autenticando e configurando o ambiente (Marketplace)

Escolha o "ambiente" você quer executar suas ações e informe seu accesstoken:

Imports Wirecard
Imports Wirecard.Models

Private Const AccessToken As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_v2"
Private WC As New WirecardClient(Environments.SANDBOX, AccessToken)

Para obter o accesstoken, você precisa criar um App.

Assíncrona x Síncrona

Todos os métodos são assíncronos, caso você queira executar de forma síncrona, veja o exemplo:

Dim result As OrdersResponse = Task.Run(Function() WC.Order.List()).Result

Conta Clássica

Verificar se usuário já possui Conta Wirecard (email)

🚩 Essa função funciona somente na conta clássica.

 Dim result = Await WC.ClassicAccount.AccountExist("[email protected]")
 If result = HttpStatusCode.OK Then
     ' já existe
     'HttpStatusCode.OK == 200 (já existe)
     'HttpStatusCode.BadRequest == 400 (CPF inválido)
     'HttpStatusCode.NotFound == 404 (Para CPF válido, mas não possui Conta Wirecard)
 End If

Verificar se usuário já possui Conta Wirecard (documento)

🚩 Essa função funciona somente na conta clássica.

Dim result = Await WC.ClassicAccount.AccountExist("123.456.789-01")
If result = HttpStatusCode.OK Then
    ' já existe
    'HttpStatusCode.OK == 200 (já existe)
    'HttpStatusCode.BadRequest == 400 (CPF inválido)
    'HttpStatusCode.NotFound == 404 (Para CPF válido, mas não possui Conta Wirecard)
End If

Criar Conta Wirecard Clássica (Conta PF)

Dim body = New ClassicAccountRequest With {
    .Email = New Email With {
        .Address = "[email protected]"
    },
    .Person = New Person With {
        .Name = "Fulano",
        .LastName = "da Silva",
        .TaxDocument = New Taxdocument With {
            .Type = "CPF",
            .Number = "123.456.789-91"
        },
        .IdentityDocument = New Identitydocument With {
            .Type = "RG",
            .Number = "434322344",
            .Issuer = "SPP",
            .IssueDate = "2000-12-12"
        },
        .BirthDate = "1990-01-01",
        .Phone = New Phone With {
            .CountryCode = "55",
            .AreaCode = "11",
            .Number = "965213244"
        },
        .Address = New Address With {
            .Street = "Av. Brigadeiro Faria Lima",
            .StreetNumber = "2927",
            .District = "Itaim",
            .ZipCode = "01234-000",
            .City = "São Paulo",
            .State = "SP",
            .Country = "BRA"
        }
    },
    .Type = "MERCHANT"
}
Dim result = Await WC.ClassicAccount.Create(body)

Criar Conta Wirecard Clássica (Conta PJ)

Dim body = New ClassicAccountRequest With {
    .Email = New Email With {
        .Address = "[email protected]"
    },
    .Person = New Person With {
        .Name = "Fulano",
        .LastName = "da Silva",
        .BirthDate = "1990-01-01",
        .TaxDocument = New Taxdocument With {
            .Type = "CPF",
            .Number = "123.456.789-91"
        },
        .IdentityDocument = New Identitydocument With {
            .Type = "RG",
            .Number = "434322344",
            .Issuer = "SPP",
            .IssueDate = "2000-12-12"
        },
        .Phone = New Phone With {
            .CountryCode = "55",
            .AreaCode = "11",
            .Number = "965213244"
        },
        .Address = New Address With {
            .Street = "Av. Brigadeiro Faria Lima",
            .StreetNumber = "2927",
            .District = "Itaim",
            .ZipCode = "01234-000",
            .City = "São Paulo",
            .State = "SP",
            .Country = "BR"
        }
    },
    .Company = New Company With {
        .Name = "Noma da empresa",
        .BusinessName = "Wirecard Pagamentos",
        .OpeningDate = "2011-01-01",
        .TaxDocument = New Taxdocument With {
            .Type = "CNPJ",
            .Number = "11.698.147/0001-13"
        },
        .MainActivity = New Mainactivity With {
            .Cnae = "82.91-1/00",
            .Description = "Atividades de cobranças e informações cadastrais"
        },
        .Phone = New Phone With {
            .CountryCode = "55",
            .AreaCode = "11",
            .Number = "32234455"
        },
        .Address = New Address With {
            .Street = "Av. Brigadeiro Faria Lima",
            .StreetNumber = "2927",
            .District = "Itaim",
            .ZipCode = "01234-000",
            .City = "São Paulo",
            .State = "SP",
            .Country = "BRA"
        }
    },
    .BusinessSegment = New Businesssegment With {
        .Id = 3
    },
    .Type = "MERCHANT"
}
Dim result = Await WC.ClassicAccount.Create(body)

Consultar Conta Wirecard

Dim result = Await WC.ClassicAccount.Consult("MPA-XXXXXXXXXXXX")

Solicitar Permissões de Acesso ao Usuário

🚩 O código a seguir não consome API, apenas monta o URL. Mais informações clica aqui.

Dim response_type As String = "code"
Dim client_id As String = "APP-FFFGVQMOK123"
Dim redirect_uri As String = "https://example.com/abc?DEF=あいう えお"
Dim scope As String = "RECEIVE_FUNDS,MANAGE_ACCOUNT_INFO,DEFINE_PREFERENCES"
Dim url = Utilities.RequestUserAccessPermissions(response_type, client_id, redirect_uri, scope)

'https://connect-sandbox.moip.com.br/oauth/authorize?response_type=code&client_id=APP-
'FFFGVQMOK123&redirect_uri=https://example.com/abc?DEF=%E3%81%82%E3%81%84%E3%81%86%20%
'E3%81%88%E3%81%8A&scope=RECEIVE_FUNDS,MANAGE_ACCOUNT_INFO,DEFINE_PREFERENCES

Veja aqui como funciona a permissão.

Gerar Access Token

Dim client_id As String = "APP-M11STAPPOAU"
Dim client_secret As String = "SplxlOBeZQQYbYS6WxSbIA"
Dim redirect_uri As String = "http://localhost/moip/callback"
Dim grant_type As String = "authorization_code"
Dim code As String = "4d9e0466bc14aad85b894237145b217219e9a825"
Dim result = Await WC.ClassicAccount.GenerateAccessToken(client_id, client_secret, redirect_uri, grant_type, code)

Atualizar accessToken

Dim grant_type As String = "refresh_token"
Dim refresh_token As String = "2381dfbbcbd645268af1dd0e4456bfe1_v2"
Dim result = Await WC.ClassicAccount.UpdateAccessToken(grant_type, refresh_token)

Obter chave pública de uma Conta Wirecard

Dim result = Await WC.ClassicAccount.GetPublickey()

Conta Transparente

Criar Conta Wirecard Transparente

Dim body = New TransparentAccountRequest With {
    .TransparentAccount = True,
    .Type = "MERCHANT",
    .Email = New Email With {
        .Address = "[email protected]"
    },
    .Person = New Person With {
        .Name = "PrimeiroNome",
        .LastName = "SegundoNome",
        .TaxDocument = New Taxdocument With {
            .Type = "CPF",
            .Number = "123.456.798-91"
        },
        .BirthDate = "2011-01-01",
        .Phone = New Phone With {
            .CountryCode = "55",
            .AreaCode = "11",
            .Number = "965213244"
        },
        .Address = New Address With {
            .Street = "Av. Brigadeiro Faria Lima",
            .StreetNumber = "2927",
            .District = "Itaim",
            .ZipCode = "01234000",
            .City = "Osasco",
            .State = "SP",
            .Country = "BRA"
        }
    }
}
Dim result = Await WC.TransparentAccount.Create(body)

Clientes

Criar Cliente - (E-COMMERCE)

Dim body = New CustomerRequest With {
    .OwnId = "meu_id_customer_002",
    .FullName = "Maria Oliveira",
    .Email = "[email protected]",
    .BirthDate = "1980-5-10",
    .TaxDocument = New Taxdocument With {
        .Type = "CPF",
        .Number = "22288866644"
    },
    .Phone = New Phone With {
        .CountryCode = "55",
        .AreaCode = "11",
        .Number = "55552266"
    },
    .ShippingAddress = New Shippingaddress With {
        .City = "São Paulo",
        .Complement = "10",
        .District = "Itaim Bibi",
        .Street = "Avenida Faria Lima",
        .StreetNumber = "500",
        .ZipCode = "01234000",
        .State = "SP",
        .Country = "BRA"
    },
    .FundingInstrument = New Fundinginstrument With {
        .Method = "CREDIT_CARD",
        .CreditCard = New Creditcard With {
            .ExpirationMonth = "06",
            .ExpirationYear = "22",
            .Number = "6362970000457013",
            .Cvc = "123",
            .Holder = New Holder With {
                .FullName = "Maria Oliveira",
                .BirthDate = "1988-12-30",
                .TaxDocument = New Taxdocument With {
                    .Type = "CPF",
                    .Number = "33333333333"
                },
                .BillingAddress = New Billingaddress With {
                    .City = "Rio de Janeiro",
                    .District = "Copacabana",
                    .Street = "Rua Raimundo Corrêa",
                    .StreetNumber = "1200",
                    .ZipCode = "05246200",
                    .State = "SP",
                    .Country = "BRA"
                },
                .Phone = New Phone With {
                    .CountryCode = "55",
                    .AreaCode = "11",
                    .Number = "66778899"
                }
            }
        }
    }
}
Dim result = Await WC.Customer.Create(body)

Criar Cliente - (MARKETPLACE / PLATAFORMA)

 Dim body = New CustomerRequest With {
     .OwnId = "meu_id_customer",
     .FullName = "João Silva",
     .Email = "[email protected]",
     .BirthDate = "1990-10-22",
     .TaxDocument = New Taxdocument With {
         .Type = "CPF",
         .Number = "22288866644"
     },
     .Phone = New Phone With {
         .CountryCode = "55",
         .AreaCode = "11",
         .Number = "55552266"
     },
     .ShippingAddress = New Shippingaddress With {
         .City = "São Paulo",
         .Complement = "10",
         .District = "Itaim Bibi",
         .Street = "Avenida Faria Lima",
         .StreetNumber = "500",
         .ZipCode = "01234000",
         .State = "SP",
         .Country = "BRA"
     }
}
Dim result = Await WC.Customer.Create(body)

Adicionar Cartão de Crédito

Dim body = New CustomerRequest With {
    .Method = "CREDIT_CARD",
    .CreditCard = New Creditcard With {
        .ExpirationMonth = "06",
        .ExpirationYear = "2022",
        .Number = "4012001037141112",
        .Cvc = "123",
        .Holder = New Holder With {
            .FullName = "João da Silva",
            .BirthDate = "1961-03-01",
            .TaxDocument = New Taxdocument With {
                .Type = "CPF",
                .Number = "11111111111"
            },
            .Phone = New Phone With {
                .CountryCode = "55",
                .AreaCode = "11",
                .Number = "111111111"
            }
        }
    }
}
Dim result = Await WC.Customer.AddCreditCard(body, "CUS-XXXXXXXXXXXX")

Deletar Cartão de Crédito

Dim result = Await WC.Customer.DeleteCreditCard("CRC-XXXXXXXXXXXX")

Consultar Cliente

Dim result = Await WC.Customer.Consult("CUS-XXXXXXXXXXXX")

Listar Todos os Clientes

Dim result = Await WC.Customer.List()

Pedidos

Criar Pedido

Dim body = New OrderRequest With {
    .OwnId = "id_pedido",
    .Amount = New Amount With {
        .Currency = "BRL",
        .Subtotals = New Subtotals With {
            .Shipping = 1000
        }
    },
    .Items = New List(Of Item) From {
        New Item With {
            .Product = "Descrição do pedido",
            .Category = "VIDEO_GAME_SOFTWARE",
            .Quantity = 1,
            .Detail = "Mais info...",
            .Price = 22000
        }
    },
    .Customer = New Customer With {
        .Id = "CUS-7AKU0VORZ2D4"
    },
    .Receivers = New List(Of Receiver) From {
        New Receiver With {
            .Type = "SECONDARY",
            .FeePayor = False,
            .MoipAccount = New Moipaccount With {
                .Id = "MPA-E3C8493A06AE"
            },
            .Amount = New Amount With {
                .Fixed = 5000
            }
        }
    }
}
Dim result = Await WC.Order.Create(body)

Consultar Pedido

Dim result = Await WC.Order.Consult("ORD-XXXXXXXXXXXX")

Listar Todos os Pedidos - Sem Filtros

Dim result = Await WC.Order.List()

Listar Todos os Pedidos - Com Filtros

Dim filtros As String = "q=josesilva&filters=status::in(PAID,WAITING)|paymentMethod::in(CREDIT_CARD,BOLETO)|value::bt(5000,10000)&limit=3&offset=0"
    Dim result = Await WC.Order.ListFilter(filtros)

Veja a tabela filtros de busca aqui.

Pagamentos

Criar Pagamento - Cartão de Crédito

Dim body = New PaymentRequest With {
   .InstallmentCount = 1,
   .FundingInstrument = New Fundinginstrument With {
       .Method = "CREDIT_CARD",
       .CreditCard = New Creditcard With {
           .Id = "CRC-XXXXXXXXXXXX",
           .Cvc = "123",
           .Holder = New Holder With {
               .FullName = "Jose Portador da Silva",
               .BirthDate = "1988-12-30",
               .TaxDocument = New Taxdocument With {
                   .Type = "CPF",
                   .Number = "33333333333"
               }
           }
       }
   }
}
Dim result = Await WC.Payment.Create(body, "ORD-XXXXXXXXXXXX")

Criar Pagamento - Boleto

Dim body = New PaymentRequest With {
    .StatementDescriptor = "Minha Loja",
    .FundingInstrument = New Fundinginstrument With {
        .Method = "BOLETO",
        .Boleto = New Boleto With {
            .ExpirationDate = "2020-06-20",
            .InstructionLines = New Instructionlines With {
                .First = "Atenção",
                .Second = "fique atento à data de vencimento do boleto.",
                .Third = "Pague em qualquer casa lotérica."
            }
        }
    }
}
Dim result = Await WC.Payment.Create(body, "ORD-XXXXXXXXXXXX")

Criar Pagamento - Débito Online

Dim body = New PaymentRequest With {
    .FundingInstrument = New Fundinginstrument With {
        .Method = "ONLINE_BANK_DEBIT",
        .OnlineBankDebit = New Onlinebankdebit With {
            .BankNumber = "341",
            .ExpirationDate = "2017-10-22"
        }
    }
}
Dim result = Await WC.Payment.Create(body, "ORD-XXXXXXXXXXXX")

Liberação de Custódia

Dim result = Await WC.Payment.ReleaseCustody("ECW-XXXXXXXXXXXX")

Capturar Pagamento Pré-autorizado

Dim result = Await WC.Payment.CaptureAuthorized("PAY-XXXXXXXXXXXX")

Cancelar Pagamento Pré-autorizado

Dim result = Await WC.Payment.CancelAuthorized("PAY-XXXXXXXXXXXX")

Consultar Pagamento

Dim result = Await WC.Payment.Consult("PAY-XXXXXXXXXXXX")

Simular Pagamentos (sandbox)

Dim result = Await WC.Payment.Simulate("PAY-XXXXXXXXXXXX", 26500)

Multipedidos

Criar Multipedido

Dim body = New MultiOrderRequest With {
    .OwnId = "meu_multiorder_id",
    .Orders = New List(Of Order) From {
        New Order With {
            .OwnId = "pedido_1_id",
            .Amount = New Amount With {
                .Currency = "BRL",
                .Subtotals = New Subtotals With {
                    .Shipping = 2000
                }
            },
            .Items = New List(Of Item) From {
                New Item With {
                    .Product = "Camisa Verde e Amarelo - Brasil",
                    .Quantity = 1,
                    .Detail = "Seleção Brasileira",
                    .Price = 2000
                }
            },
            .Customer = New Customer With {
                .OwnId = "customer[1234]",
                .FullName = "Joao Souza",
                .Email = "[email protected]",
                .BirthDate = "1988-12-30",
                .TaxDocument = New Taxdocument With {
                    .Type = "CPF",
                    .Number = "22222222222"
                },
                .Phone = New Phone With {
                    .CountryCode = "55",
                    .AreaCode = "11",
                    .Number = "66778899"
                },
                .ShippingAddress = New Shippingaddress With {
                    .City = "São Paulo",
                    .Complement = "10",
                    .District = "Itaim Bibi",
                    .Street = "Avenida Faria Lima",
                    .StreetNumber = "500",
                    .ZipCode = "01234000",
                    .State = "SP",
                    .Country = "BRA"
                }
            },
            .Receivers = New List(Of Receiver) From {
                New Receiver With {
                    .MoipAccount = New Moipaccount With {
                        .Id = "MPA-VB5OGTVPCI52"
                    },
                    .Type = "PRIMARY"
                }
            }
        },
        New Order With {
            .OwnId = "pedido_2_id",
            .Amount = New Amount With {
                .Currency = "BRL",
                .Subtotals = New Subtotals With {
                    .Shipping = 2000
                }
            },
            .Items = New List(Of Item) From {
                New Item With {
                    .Product = "Camisa Preta e Vermelha - Alemanha",
                    .Quantity = 1,
                    .Detail = "Camiseta da Copa 2014",
                    .Price = 2000
                }
            },
            .Customer = New Customer With {
                .OwnId = "customer[1234]",
                .FullName = "Joao Souza",
                .Email = "[email protected]",
                .BirthDate = "1988-12-30",
                .TaxDocument = New Taxdocument With {
                    .Type = "CPF",
                    .Number = "22222222222"
                },
                .Phone = New Phone With {
                    .CountryCode = "55",
                    .AreaCode = "11",
                    .Number = "66778899"
                },
                .ShippingAddress = New Shippingaddress With {
                    .City = "São Paulo",
                    .Complement = "10",
                    .District = "Itaim Bibi",
                    .Street = "Avenida Faria Lima",
                    .StreetNumber = "500",
                    .ZipCode = "01234000",
                    .State = "SP",
                    .Country = "BRA"
                }
            },
            .Receivers = New List(Of Receiver) From {
                New Receiver With {
                    .MoipAccount = New Moipaccount With {
                        .Id = "MPA-KQB1QFWS6QNM"
                    },
                    .Type = "SECONDARY",
                    .FeePayor = False,
                    .Amount = New Amount With {
                        .Fixed = 55
                    }
                }
            }
        }
    }
}
Dim result = Await WC.MultiOrder.Create(body)

Consultar Multipedido

Dim result = Await WC.MultiOrder.Consult("MOR-XXXXXXXXXXXX")

Multipagamentos

Criar Multipagamento

Dim body = New MultiPaymentRequest With {
    .InstallmentCount = 1,
    .FundingInstrument = New Fundinginstrument With {
        .Method = "CREDIT_CARD",
        .CreditCard = New Creditcard With {
            .Hash = "HhL0...pIkjl2+3Q==",
            .Holder = New Holder With {
                .FullName = "",
                .BirthDate = "1988-12-30",
                .TaxDocument = New Taxdocument With {
                    .Type = "CPF",
                    .Number = "33333333333"
                },
                .Phone = New Phone With {
                    .CountryCode = "55",
                    .AreaCode = "11",
                    .Number = "66778899"
                }
            }
        }
    }
}
Dim result = Await WC.MultiPayment.Create(body, "MOR-XXXXXXXXXXXX")

Consultar Multipagamento

Dim result = Await WC.MultiPayment.Consult("MPY-XXXXXXXXXXXX")

Capturar Multipagamento Pré-autorizado

Dim result = Await WC.MultiPayment.CaptureAuthorized("MPY-XXXXXXXXXXXX")

Cancelar Multipagamento Pré-autorizado

Dim result = Await WC.MultiPayment.CancelAuthorized("MPY-XXXXXXXXXXXX")

Liberação de Custódia

Dim result = Await WC.MultiPayment.ReleaseCustody("ECW-XXXXXXXXXXXX")

Notificações

Criar Preferência de Notificação para Conta Wirecard

Dim body = New NotificationRequest With {
    .Events = New List(Of String) From {
        "ORDER.*",
        "PAYMENT.AUTHORIZED",
        "PAYMENT.CANCELLED"
    },
    .Target = "https://webhook.site/a54daf-da54-8d5a-8d5d1-kfa4gahf42",
    .Media = "WEBHOOK"
}
Dim result = Await WC.Notification.CreatAccountWirecard(body)

Criar Preferência de Notificação para App

Caso não tenha uma URL disponível, você pode usar o Webhook Tester para fazer seus testes e receber os webhooks.

Para isso basta acessar o site e gera uma URL automaticamente.

Dim body = New NotificationRequest With {
    .Events = New List(Of String) From {
        "ORDER.*"
    },
    .Target = "https://webhook.site/a54daf-da54-8d5a-8d5d1-kfa4gahf42",
    .Media = "WEBHOOK"
}
Dim result = Await WC.Notification.CreateApp(body)

Criar Preferência de Notificação para App com código identificador

Dim body = New NotificationRequest With {
    .Events = New List(Of String) From {
        "ORDER.*"
    },
    .Target = "https://webhook.site/a54daf-da54-8d5a-8d5d1-kfa4gahf42",
    .Media = "WEBHOOK"
}
Dim result = Await WC.Notification.CreateApp(body, "APP-3984HG73HE9")

Consultar Preferência de Notificação

Dim result = Await WC.Notification.Consult("NPR-XXXXXXXXXXXX")

Listar Todas as Preferências de Notificação

Dim result = Await WC.Notification.List()

Remover Preferência de Notificação

Dim result = Await WC.Notification.Remove("NPR-XXXXXXXXXXXX")
If result = HttpStatusCode.NoContent Then
'Caso a Preferência de Notificação tenha sido deletada, você deve receber uma response vazia (NoContent)
End If

Consultar Webhook Enviado

Dim result = Await WC.Notification.ConsultWebhook("PAY-XXXXXXXXXXXX")

Listar Todos os Webhooks Enviados

Dim result = Await WC.Notification.ListWebhooks()

Desserializar WebHook

Ao configurar suas Preferências de Notificação você deve receber os webhooks em formato JSON e você pode desserializar.

Dim json = "{ ""date"": """", ""env"": """", ... }"
Dim result = Utilities.DeserializeWebHook(json)

Veja um exemplo do webhook aqui.

Para aumentar a segurança da sua aplicação e garantir que apenas a Wirecard pode enviar notificações para o seu sistema, você pode conferir o token enviado no header dos webhooks. Este token é o mesmo que é gerado no momento do cadastro da sua URL:

Dim token = Request.Headers("Authorization")

Contas Bancárias

Criar Conta Bancária

Dim body = New BankAccountRequest With {
    .BankNumber = "237",
    .AgencyNumber = "12345",
    .AgencyCheckNumber = "0",
    .AccountNumber = "12345678",
    .AccountCheckNumber = "7",
    .Type = "CHECKING",
    .Holder = New Holder With {
        .TaxDocument = New Taxdocument With {
            .Type = "CPF",
            .Number = "622.134.533-22"
        },
        .FullName = "Demo Wirecard"
    }
}
Dim accesstoken As String = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
Dim result = Await WC.BankAccount.Create(body, accesstoken, "MPA-XXXXXXXXXXXX")

Consultar Conta Bancária

Dim accesstoken As String = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
Dim result = Await WC.BankAccount.Consult(accesstoken, "BKA-XXXXXXXXXXXX")

Listar Todas Contas Bancárias

Dim accesstoken As String = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
Dim result = Await WC.BankAccount.List(accesstoken, "MPA-XXXXXXXXXXXX")

Deletar Conta Bancária

Dim accesstoken As String = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
Dim result = Await WC.BankAccount.Delete(accesstoken, "BKA-XXXXXXXXXXXX")

Atualizar Conta Bancária

Dim body = New BankAccountRequest With {
    .BankNumber = "237",
    .AgencyNumber = "12345",
    .AgencyCheckNumber = "8",
    .AccountNumber = "12345678",
    .AccountCheckNumber = "8",
    .Type = "CHECKING",
    .Holder = New Holder With {
        .TaxDocument = New Taxdocument With {
            .Type = "CPF",
            .Number = "622.134.533-22"
        },
        .FullName = "Nome Completo"
    }
}
Dim accesstoken As String = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
Dim result = Await WC.BankAccount.Update(body, accesstoken, "BKA-XXXXXXXXXXXX")

Saldo Wirecard

Consultar Saldos

Dim result = Await WC.Balance.Consult()

Lançamentos

Consultar Lançamento

Dim result = Await WC.Launch.Consult("ENT-XXXXXXXXXXXX")

Listar Todos Lançamentos

Dim result = Await WC.Launch.List()

Listar Todos Lançamentos com Filtro

Dim filtros As String = "filters=status::in(SETTLED)"
Dim result = Await WC.Launch.ListFilter(filtros)

Transferências

Criar Transferência

Dim body = New TransferRequest With {
    .Amount = 500,
    .TransferInstrument = New Transferinstrument With {
        .Method = "",
        .BankAccount = New Bankaccount With {
            .Type = "CHECKING",
            .BankNumber = "001",
            .AgencyNumber = "1111",
            .AgencyCheckNumber = "2",
            .AccountNumber = "9999",
            .AccountCheckNumber = "8",
            .Holder = New Holder With {
                .FullName = "Nome do Portador",
                .TaxDocument = New Taxdocument With {
                    .Type = "CPF",
                    .Number = "22222222222"
                }
            }
        }
    }
}
Dim accessToken As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_v2"
Dim result = Await WC.Transfer.Create(body, accessToken)

Reverter Transferência

Dim accessToken As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_v2"
Dim result = Await WC.Transfer.Revert("TRA-XXXXXXXXXXXX", accessToken)

Consultar Transferência

Dim accessToken As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_v2"
Dim result = Await WC.Transfer.Consult("TRA-XXXXXXXXXXXX", accessToken)

Listar Todas Transferências

Dim result = Await WC.Transfer.List()

Listar Todas Transferências com filtros

Dim filtros As String = "filters=transferInstrument.method::in(MOIP_ACCOUNT)&limit=3&offset=0"
Dim result = Await WC.Transfer.ListFilter(filtros)

Reembolsos

Reembolsar Pagamento

Dim body = New RefundRequest With {
    .Amount = "2000"
}
Dim result = Await WC.Refund.RefundPayment(body, "PAY-XXXXXXXXXXXX")

Reembolsar Pedido via Cartão de Crédito

Dim body = New RefundRequest With {
    .Amount = "2000"
}
Dim result = Await WC.Refund.RefundRequestCreditCard(body, "ORD-XXXXXXXXXXXX")

Consultar Reembolso

Dim result = Await WC.Refund.Consult("REF-XXXXXXXXXXXX")

Listar Reembolsos do Pagamento

Dim result = Await WC.Refund.ListPayments("PAY-XXXXXXXXXXXX")

Listar Reembolsos do Pedido

Dim result = Await WC.Refund.ListOrders("ORD-XXXXXXXXXXXX")

Conciliação

Obter Arquivo de Vendas

Dim result = Await WC.Conciliation.GetSalesFile("20180829")
'Data no formato YYYYMMDD

Obter Arquivo Financeiro

Dim result = Await WC.Conciliation.GetFinancialFile("2018-08-29")
'Data no formato YYYY-MM-DD

Assinatura

Criar Plano

Dim body = New PlanRequest With {
    .Code = "plan103",
    .Name = "Plano Especial",
    .Description = "Descrição do Plano Especial",
    .Amount = 990,
    .Setup_Fee = 500,
    .Max_Qty = 1,
    .Interval = New Interval With {
        .Length = 1,
        .Unit = "MONTH"
    },
    .Billing_Cycles = 12,
    .Trial = New Trial With {
        .Days = 30,
        .Enabled = True,
        .Hold_Setup_Fee = True
    }
}
Dim result = Await WC.Signature.CreatePlan(body)

Listar Planos

Dim result = Await WC.Signature.ListPlans()

Consultar Plano

Dim result = Await WC.Signature.ConsultPlan("plan101")

Ativar Plano

Dim result = Await WC.Signature.EnablePlan("plan101")

Desativar Plano

Dim result = Await WC.Signature.DisablePlan("plan101")

Alterar Plano

Dim body = New PlanRequest With {
    .Name = "Plano Especial",
    .Description = "",
    .Amount = 1290,
    .Setup_Fee = 800,
    .Max_Qty = 1,
    .Payment_Method = "CREDIT_CARD",
    .Interval = New Interval With {
        .Length = 1,
        .Unit = "MONTH"
    },
    .Billing_Cycles = 12,
    .Trial = New Trial With {
        .Days = 30,
        .Enabled = True,
        .Hold_Setup_Fee = True
    }
}
Dim result = Await WC.Signature.ChangePlan(body, "plan101")

Criar Assinante

Dim body = New SubscriberRequest With {
    .Code = "cliente03",
    .Email = "[email protected]",
    .FullName = "Nome Sobrenome",
    .Cpf = "22222222222",
    .Phone_Area_Code = "11",
    .Phone_Number = "934343434",
    .BirthDate_Day = "26",
    .BirthDate_Month = "04",
    .BirthDate_Year = "1980",
    .Address = New Address With {
        .Street = "Rua Nome da Rua",
        .StreetNumber = "100",
        .Complement = "casa",
        .District = "Nome do Bairro",
        .City = "São Paulo",
        .State = "SP",
        .Country = "BRA",
        .ZipCode = "05015010"
    },
    .Billing_Info = New Billing_Info With {
        .Credit_Card = New Credit_Card With {
            .Holder_Name = "Nome Completo",
            .Number = "4111111111111111",
            .Expiration_Month = "06",
            .Expiration_Year = "22"
        }
    }
}
Dim result = Await WC.Signature.CreateSubscriber(body, True)

Listar Assinantes

Dim result = Await WC.Signature.ListSubscribers()

Consultar Assinante

Dim result = Await WC.Signature.ConsultSubscriber("cliente01")

Alterar Assinante

Dim body = New SubscriberRequest With {
    .Code = "cliente01",
    .Email = "[email protected]",
    .FullName = "Nome Sobrenome",
    .Cpf = "22222222222",
    .Phone_Area_Code = "11",
    .Phone_Number = "934343434",
    .BirthDate_Day = "26",
    .BirthDate_Month = "04",
    .BirthDate_Year = "1980",
    .Address = New Address With {
        .Street = "Rua Nome da Rua1",
        .StreetNumber = "100",
        .Complement = "casa",
        .District = "Nome do Bairro",
        .City = "São Paulo",
        .State = "SP",
        .Country = "BRA",
        .ZipCode = "05015010"
    }
}
Dim result = Await WC.Signature.ChangeSubscriber(body, "cliente01")

Atualizar Cartão do Assinante

Dim body = New SubscriberRequest With {
    .Billing_Info = New Billing_Info With {
        .Credit_Card = New Credit_Card With {
            .Holder_Name = "Novo nome222",
            .Number = "5555666677778884",
            .Expiration_Month = "12",
            .Expiration_Year = "20"
        }
    }
}
Dim result = Await WC.Signature.UpdateSubscriberCard(body, "cliente01")

Criar Assinaturas

Dim body = New SubscriptionRequest With {
    .Code = "assinatura04",
    .Amount = "9000",
    .Plan = New Plan With {
        .Code = "plan101"
    },
    .Payment_Method = "CREDIT_CARD",
    .Customer = New Customer With {
        .Code = "cliente01"
    }
}
Dim result = Await WC.Signature.CreateSubscriptions(body, False)

Listar Todas Assinaturas

Dim result = Await WC.Signature.ListAllSubscriptions()

Consultar Assinatura -Sem Filtro

Dim result = Await WC.Signature.ConsultSubscriptionFilter("assinatura01")

Consultar Assinatura - Com Filtro

Dim filter = "q=assinatura01&filters=status::eq(ACTIVE)"
Dim result = Await WC.Signature.ConsultSubscription(filter)

Alguns exemplos de como filtrar:

  1. Pesquisar e Filtrar assinaturas (q=teste&filters=status::eq(EXPIRED))
  2. Filtrar assinaturas por status (filters=status::eq(EXPIRED)&limit=10&offset=0)
  3. Filtrar assinaturas por creation_date (filters=creation_date::bt(2014-11-08,2015-05-07)&limit=100&offset=0)
  4. Filtrar assinaturas por next_invoice_date (filters=next_invoice_date::bt(2015-10-12,2015-10-12)&limit=100&offset=0)
  5. Filtrar assinaturas por plano (filters=plan.code::eq(TESTE_WIRECARD)&limit=100&offset=0)
  6. Filtrar assinaturas por customer.code (filters=customer.code::eq(HHDGOo)&limit=100&offset=0)
  7. Filtrar assinaturas por customer.email (filters=customer.email::eq([email protected])&limit=100&offset=0)
  8. Filtrar assinaturas por customer.cpf (filters=customer.cpf::eq(22222222222)&limit=100&offset=0)
  9. Filtrar assinaturas por valor (filters=amount::bt(100,100000))
  10. Pesquisar Assinatura (q=diego nunes&limit=10&offset=0)

Suspender Assinatura

Dim result = Await WC.Signature.SuspendSubscription("assinatura01")

Reativar Assinatura

Dim result = Await WC.Signature.ReactivateSignature("assinatura01")

Cancelar Assinatura

Dim result = Await WC.Signature.CancelSignature("assinatura01")

Alterar Assinatura

Dim body = New SubscriptionRequest With {
    .Plan = New Plan With {
        .Code = "plan101"
    },
    .Amount = "9990",
    .Next_Invoice_Date = New Next_Invoice_Date With {
        .Day = 15,
        .Month = 12,
        .Year = 2018
    }
}
Dim result = Await WC.Signature.ChangeSubscription(body, "assinatura01")

Alterar método de pagamento

Dim body = New SubscriptionRequest With {
    .Payment_Method = "BOLETO"
}
Dim result = Await WC.Signature.ChangePaymentMethod(body, "assinatura01")

Listar Todas as Faturas de Uma Assinatura

Dim result = Await WC.Signature.ListSignatureInvoices("assinatura01")

Consultar Fatura

Dim result = Await WC.Signature.ConsultInvoice("10865746")

Listar todos os pagamentos de fatura

Dim result = Await WC.Signature.ListAllInvoicePayments("10865746")

Consultar pagamento de assinatura

Dim result = Await WC.Signature.ConsultSubscriptionPayment("PAY-123456789012")

Criar Cupom

Dim body = New CouponRequest With {
    .Code = "coupon-0002",
    .Name = "Coupon name",
    .Description = "My new coupon",
    .Discount = New Discount With {
        .Value = 1000,
        .Type = "percent"
    },
    .Status = "active",
    .Duration = New Duration With {
        .Type = "repeating",
        .Occurrences = 12
    },
    .Max_Redemptions = 100,
    .Expiration_Date = New Expiration_Date With {
        .Year = 2020,
        .Month = 08,
        .Day = 01
    }
}
Dim result = Await WC.Signature.CreateCoupon(body)

Associar Cupom para Assinatura

Dim body = New CouponRequest With {
    .Coupon = New Coupon With {
        .Code = "coupon-0001"
    }
}
Dim result = Await WC.Signature.AssociateCouponForExistingSignature(body, "assinatura01")

Associar Cupom para Nova Assinatura

Dim body = New CouponRequest()
Dim result = Await WC.Signature.AssociateCouponForExistingSignature(body, "true")

Consultar Cupom

Dim result = Await WC.Signature.ConsultCoupon("coupon-0001")

Listar Todos os Cupons

Dim result = Await WC.Signature.ListAllCoupons()

Ativar e Inativar Cupons

Dim result = Await WC.Signature.EnableOrDisableCoupon("coupon-0001", "inactive")

Excluir Cupom de uma Assinatura

Dim result = Await WC.Signature.DeleteSignatureCoupon("assinatura01")

Retentativa de pagamento de uma fatura

Dim result = Await WC.Signature.RetentiveInvoicePayment("1548222")

Gerar um novo boleto para uma fatura

Dim body = New RetentativeRequest With {
    .Year = 2020,
    .Month = 08,
    .Day = 01
}
Dim result = Await WC.Signature.CreateNewInvoiceBoleto(body, "1548222")

Criar Regras de Retentativas Automáticas

Dim body = New RetentativeRequest With {
    .First_Try = 1,
    .Second_Try = 3,
    .Third_Try = 5,
    .[Finally] = "cancel"
}
Dim result = Await WC.Signature.CreateAutomaticRetentionRules(body)

Criar Preferência de Notificação

Dim body = New NotificationRequest With {
    .Notification = New Notification With {
        .Webhook = New Webhook With {
            .Url = "http://exemploldeurl.com.br/assinaturas"
        },
        .Email = New Email With {
            .Merchant = New Merchant With {
                .Enabled = True
            },
            .Customer = New Customer With {
                .Enabled = True
            }
        }
    }
}
Dim result = Await WC.Signature.CreateNotificationPreference(body)

Convertendo objeto para json

As vezes você enfrenta um problema e o suporte Wirecard pede o código json para verificar se realmente está no json:

Imports Newtonsoft.Json;

Dim body = New PaymentRequest With {
    .DelayCapture = True,
    .InstallmentCount = 1,
    .FundingInstrument = New Fundinginstrument With {
        .Method = "CREDIT_CARD",
        .CreditCard = New Creditcard With {
            .Id = "CRC-XXXXXXXXXXXX",
            .Cvc = "123",
            .Holder = New Holder With {
                .FullName = "Jose Portador da Silva",
                .BirthDate = "1988-12-30",
                .TaxDocument = New Taxdocument With {
                    .Type = "CPF",
                    .Number = "33333333333"
                }
            }
        }
    }
}

'Aqui você pode obter json e compratilhar para suporte Wirecard
Dim json As String = JsonConvert.SerializeObject(body, Formatting.Indented)

Veja como ficou na variável json:

{
  "installmentCount": 1,
  "delayCapture": true,
  "fundingInstrument": {
    "method": "CREDIT_CARD",
    "creditCard": {
      "id": "CRC-XXXXXXXXXXXX",
      "cvc": "123",
      "holder": {
        "fullname": "Jose Portador da Silva",
        "birthdate": "1988-12-30",
        "taxDocument": {
          "type": "CPF",
          "number": "33333333333"
        }
      }
    }
  }
}

Tabela - Filtros de busca

Nome Tipo Descrição
limit int Quantidade de registros por busca (página). O valor default é 20
offset int Registro a partir do qual a busca vai retornar. O valor default é 0
gt(x) number or date Maior que - “Greater Than”
ge(x) number or date Maior ou igual - “Greater than or Equal”
lt(x) number or date Menor que - “Less Than”
le(x) number or date Menor ou igual - “Less than or Equal”
bt(x,y) string Entre - “Between”
in(x,y…z) string Em - “IN”
q Consulta um valor em específico

✅ Fazendo uma busca com os seguintes requisitos:

+ Transações de valores entre 5000 e 10000 (em centavos);
+ Formas de pagamento: Cartão de Crédito e Boleto;
+ Cliente com o nome jose silva;
+ Retornando 3 resultados.

GET https: //sandbox.moip.com.br/v2/orders?q=jose silva &filters=status::in(PAID,WAITING)|paymentMethod::in(CREDIT_CARD,BOLETO) |value::bt(5000,10000)&limit=3&offset=0

Você pode também fazer uma busca por pedidos dentro de um intervalo de tempo:

GET https: //sandbox.moip.com.br/v2/orders?filters=createdAt::bt(2017-10-10T13:07:00Z,2017-10-25T13:08:00Z)

Exceção

Obter erros

Você pode recuperar os atributos code, path, description, message e error, veja no exemplo abaixo:

Imports Wirecard.Exception

Try
    Dim result = Await WC.Customer.Create(New CustomerRequest())
Catch ex As WirecardException
    Dim t = ex.wirecardError
    Dim t_text = ex.GetExceptionText()
End Try

Tabela de erros

Nome Descrição Detalhe
code Código identificador do erro string
path Parâmetro relacionado ao erro string
description Descrição do erro string
message Mensagem do retorno Wirecard string

Licença

The MIT License

Tem dúvidas? Fale com a gente no Slack! Algum problema ? Abre issues!