Ler em outras linguagens de programação: C#, Visual Basic.
- Implementações .NET com suporte
- Aviso Importante
- Instalação
- Autenticando e configurando o ambiente (E-Commerce)
- Autenticando e configurando o ambiente (Marketplace)
- Conta Clássica
- Verificar se usuário já possui Conta Wirecard (email)
- Verificar se usuário já possui Conta Wirecard (documento)
- Criar Conta Wirecard Clássica (Conta PF)
- Criar Conta Wirecard Clássica (Conta PJ)
- Consultar Conta Wirecard
- Solicitar Permissões de Acesso ao Usuário
- Gerar Access Token
- Atualizar accessToken
- Obter chave pública de uma Conta Wirecard
- Conta Transparente
- Clientes
- Pedidos
- Pagamentos
- Multipedidos
- Multipagamentos
- Notificações
- Criar Preferência de Notificação para Conta Wirecard
- Criar Preferência de Notificação para App
- Criar Preferência de Notificação para App com código identificador
- Consultar Preferência de Notificação
- Listar Todas as Preferências de Notificação
- Remover Preferência de Notificação
- Consultar Webhook Enviado
- Listar Todos os Webhooks Enviados
- Desserializar WebHook
- Contas Bancárias
- Saldo Wirecard
- Lançamentos
- Transferências
- Reembolsos
- Conciliação
- Assinatura
- Criar Plano
- Listar Planos
- Consultar Plano
- Ativar Plano
- Desativar Plano
- Alterar Plano
- Criar Assinante
- Listar Assinantes
- Consultar Assinante
- Alterar Assinante
- Atualizar Cartão do Assinante
- Criar Assinaturas
- Listar Todas Assinaturas
- Consultar Assinatura -Sem Filtro
- Consultar Assinatura - Com Filtro
- Suspender Assinatura
- Reativar Assinatura
- Cancelar Assinatura
- Alterar Assinatura
- Alterar método de pagamento
- Listar Todas as Faturas de Uma Assinatura
- Consultar Fatura
- Listar todos os pagamentos de fatura
- Consultar pagamento de assinatura
- Criar Cupom
- Associar Cupom para Assinatura
- Associar Cupom para Nova Assinatura
- Consultar Cupom
- Listar Todos os Cupons
- Ativar e Inativar Cupons
- Excluir Cupom de uma Assinatura
- Retentativa de pagamento de uma fatura
- Gerar um novo boleto para uma fatura
- Criar Regras de Retentativas Automáticas
- Criar Preferência de Notificação
- Convertendo objeto para json
- Tabela - Filtros de busca
- Exceção
- Licença
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.
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:
open System.Net
ServicePointManager.SecurityProtocol <- SecurityProtocolType.Tls12
Para mais informações : TLS1.2.
Execute o comando para instalar via NuGet:
PM> Install-Package Wirecard
💥 Obs: Trocamos a biblioteca MoipCSharp por Wirecard.
Escolha o "ambiente" você quer executar suas ações e informe seu (token, chave):
open Wirecard
open Wirecard.Models
let private token = "xxxxxxxxxxxxxxxxxxx"
let private key = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
let private WC = 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.
Escolha o "ambiente" você quer executar suas ações e informe seu accesstoken:
open Wirecard
open Wirecard.Models
let private accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_v2"
let private WC = new WirecardClient(Environments.SANDBOX, accessToken)
Para obter o accesstoken, você precisa criar um App.
🚩 Essa função funciona somente na conta clássica.
let result =
async {
return! WC.ClassicAccount.AccountExist("[email protected]") |> Async.AwaitTask
} |> Async.RunSynchronously
if (result = HttpStatusCode.OK) then printfn "Conta 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)
🚩 Essa função funciona somente na conta clássica.
let result =
async {
return! WC.ClassicAccount.AccountExist("123.456.789-01") |> Async.AwaitTask
} |> Async.RunSynchronously
if (result = HttpStatusCode.OK) then printfn "Conta 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)
let body =
ClassicAccountRequest(
Email = Email(
Address = "[email protected]"),
Person = Person(
Name = "Fulano",
LastName = "da Silva",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "123.456.789-91"),
IdentityDocument = Identitydocument(
Type = "RG",
Number = "434322344",
Issuer = "SPP",
IssueDate = "2000-12-12"),
BirthDate = "1990-01-01",
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "965213244"),
Address = Address(
Street = "Av. Brigadeiro Faria Lima",
StreetNumber = "2927",
District = "Itaim",
ZipCode = "01234-000",
City = "São Paulo",
State = "SP",
Country = "BRA")),
Type = "MERCHANT")
let result =
async {
return! WC.ClassicAccount.Create(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
ClassicAccountRequest(
Email = Email(
Address = "[email protected]"),
Person = Person(
Name = "Fulano",
LastName = "da Silva",
BirthDate = "1990-01-01",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "123.456.789-91"),
IdentityDocument = Identitydocument(
Type = "RG",
Number = "434322344",
Issuer = "SPP",
IssueDate = "2000-12-12"),
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "965213244"),
Address = Address(
Street = "Av. Brigadeiro Faria Lima",
StreetNumber = "2927",
District = "Itaim",
ZipCode = "01234-000",
City = "São Paulo",
State = "SP",
Country = "BRA")),
Company = Company(
Name = "Noma da empresa",
BusinessName = "Wirecard Pagamentos",
OpeningDate = "2011-01-01",
TaxDocument = Taxdocument(
Type = "CNPJ",
Number = "11.698.147/0001-13"),
MainActivity = Mainactivity(
Cnae = "82.91-1/00",
Description = "Atividades de cobranças e informações cadastrais"),
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "32234455"),
Address = Address(
Street = "Av. Brigadeiro Faria Lima",
StreetNumber = "2927",
District = "Itaim",
ZipCode = "01234-000",
City = "São Paulo",
State = "SP",
Country = "BRA")),
BusinessSegment = Businesssegment(Id = 3),
Type = "MERCHANT")
let result =
async {
return! WC.ClassicAccount.Create(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.ClassicAccount.Consult("MPA-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
🚩 O código a seguir não consome API, apenas monta o URL. Mais informações clica aqui.
let response_type = "code"
let client_id = "APP-FFFGVQMOK123"
let redirect_uri = "https://example.com/abc?DEF=あいう えお"
let scope = "RECEIVE_FUNDS,MANAGE_ACCOUNT_INFO,DEFINE_PREFERENCES"
let 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.
let client_id = "APP-M11STAPPOAU"
let client_secret = "SplxlOBeZQQYbYS6WxSbIA"
let redirect_uri = "http://localhost/moip/callback"
let grant_type = "authorization_code"
let code = "4d9e0466bc14aad85b894237145b217219e9a825"
let result =
async {
return! WC.ClassicAccount.GenerateAccessToken(client_id, client_secret, redirect_uri, grant_type, code) |> Async.AwaitTask
} |> Async.RunSynchronously
let grant_type = "refresh_token"
let refresh_token = "2381dfbbcbd645268af1dd0e4456bfe1_v2"
let result =
async {
return! WC.ClassicAccount.UpdateAccessToken(grant_type, refresh_token) |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.ClassicAccount.GetPublickey() |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
TransparentAccountRequest(
TransparentAccount = true,
Type = "MERCHANT",
Email = Email(
Address = "[email protected]"),
Person = Person(
Name = "",
LastName = "",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "123.456.798-91"),
BirthDate = "2011-01-01",
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "965213244"),
Address = Address(
Street = "Av. Brigadeiro Faria Lima",
StreetNumber = "2927",
District = "Itaim",
ZipCode = "01234000",
City = "Osasco",
State = "SP",
Country = "BRA")))
let result =
async {
return! WC.TransparentAccount.Create(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
CustomerRequest(
OwnId = "meu_id_customer_002",
FullName = "Maria Oliveira",
Email = "[email protected]",
BirthDate = "1980-5-10",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "22288866644"),
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "55552266"),
ShippingAddress = Shippingaddress(
City = "São Paulo",
Complement = "10",
District = "Itaim Bibi",
Street = "Avenida Faria Lima",
StreetNumber = "500",
ZipCode = "01234000",
State = "SP",
Country = "BRA"),
FundingInstrument = Fundinginstrument(
Method = "CREDIT_CARD",
CreditCard = Creditcard(
ExpirationMonth = "06",
ExpirationYear = "22",
Number = "6362970000457013",
Cvc = "123",
Holder = Holder(
FullName = "Maria Oliveira",
BirthDate = "1988-12-30",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "33333333333"),
BillingAddress = Billingaddress(
City = "Rio de Janeiro",
District = "Copacabana",
Street = "Rua Raimundo Corrêa",
StreetNumber = "1200",
ZipCode = "05246200",
State = "SP",
Country = "BRA"),
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "66778899")))))
let result =
async {
return! WC.Customer.Create(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
CustomerRequest(
OwnId = "meu_id_customer",
FullName = "Maria Oliveira",
Email = "[email protected]",
BirthDate = "1980-5-10",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "22288866644"),
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "55552266"),
ShippingAddress = Shippingaddress(
City = "São Paulo",
Complement = "10",
District = "Itaim Bibi",
Street = "Avenida Faria Lima",
StreetNumber = "500",
ZipCode = "01234000",
State = "SP",
Country = "BRA"))
let result =
async {
return! WC.Customer.Create(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
CustomerRequest(
Method = "CREDIT_CARD",
CreditCard = Creditcard(
ExpirationMonth = "06",
ExpirationYear = "2022",
Number = "4012001037141112",
Cvc = "123",
Holder = Holder(
FullName = "João da Silva",
BirthDate = "1961-03-01",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "11111111111"),
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "111111111"))))
let result =
async {
return! WC.Customer.AddCreditCard(body, "CUS-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Customer.DeleteCreditCard("CRC-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Customer.Consult("CUS-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Customer.List() |> Async.AwaitTask
} |> Async.RunSynchronously
let items = ResizeArray<Item>()
items.Add(Item(
Product = "Descrição do pedido",
Category = "VIDEO_GAME_SOFTWARE",
Quantity = 1,
Detail = "Mais info...",
Price = 2200))
let receivers = ResizeArray<Receiver>()
receivers.Add(Receiver(
Type = "SECONDARY",
FeePayor = false,
MoipAccount = Moipaccount(
Id = "MPA-E3C8493A06AE"),
Amount = Amount(
Fixed = 5000)))
let body =
OrderRequest(
OwnId = "id_pedido",
Amount = Amount(
Currency = "BRL",
Subtotals = Subtotals(
Shipping = 1000)),
Items = items,
Customer = Customer(
Id = "CUS-7AKU0VORZ2D4"),
Receivers = receivers)
let result =
async {
return! WC.Order.Create(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Order.Consult("ORD-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Order.List() |> Async.AwaitTask
} |> Async.RunSynchronously
let filtros = "q=josesilva&filters=status::in(PAID,WAITING)|paymentMethod::in(CREDIT_CARD,BOLETO)|value::bt(5000,10000)&limit=3&offset=0"
let result =
async {
return! WC.Order.ListFilter(filtros) |> Async.AwaitTask
} |> Async.RunSynchronously
Veja a tabela filtros de busca aqui.
let body =
PaymentRequest(
InstallmentCount = 1,
FundingInstrument = Fundinginstrument(
Method = "CREDIT_CARD",
CreditCard = Creditcard(
Id = "CRC-XXXXXXXXXXXX",
Cvc = "123",
Holder = Holder(
FullName = "Jose Portador da Silva",
BirthDate = "1988-12-30",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "33333333333")))))
let result =
async {
return! WC.Payment.Create(body, "ORD-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
PaymentRequest(
StatementDescriptor = "Minha Loja",
FundingInstrument = Fundinginstrument(
Method = "BOLETO",
Boleto = Boleto(
ExpirationDate = "2020-06-20", //yyyy-MM-dd
InstructionLines = Instructionlines(
First = "Atenção",
Second = "fique atento à data de vencimento do boleto.",
Third = "Pague em qualquer casa lotérica."))))
let result =
async {
return! WC.Payment.Create(body, "ORD-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
PaymentRequest(
FundingInstrument = Fundinginstrument(
Method = "ONLINE_BANK_DEBIT",
OnlineBankDebit = Onlinebankdebit(
BankNumber = "341",
ExpirationDate = "2017-10-22")))
let result =
async {
return! WC.Payment.Create(body, "ORD-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Payment.ReleaseCustody("ECW-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Payment.CaptureAuthorized("PAY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Payment.CancelAuthorized("PAY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Payment.Consult("PAY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Payment.Simulate("PAY-XXXXXXXXXXXX", 26500) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
MultiOrderRequest(
OwnId = "meu_multiorder_id",
Orders = ResizeArray<Order>([
Order(
OwnId = "pedido_1_id",
Amount = Amount(
Currency = "BRL",
Subtotals = Subtotals(
Shipping = 2000)),
Items = ResizeArray<Item>([
Item(
Product = "Camisa Verde e Amarelo - Brasil",
Quantity = 1,
Detail = "Seleção Brasileira",
Price = 2000
)]),
Customer = Customer(
OwnId = "customer[1234]",
FullName = "Joao Souza",
Email = "[email protected]",
BirthDate = "1988-12-30",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "22222222222"),
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "66778899"),
ShippingAddress = Shippingaddress(
City = "São Paulo",
Complement = "10",
District = "Itaim Bibi",
Street = "Avenida Faria Lima",
StreetNumber = "500",
ZipCode = "01234000",
State = "SP",
Country = "BRA")),
Receivers = ResizeArray<Receiver>([
Receiver(
MoipAccount = new Moipaccount(
Id = "MPA-VB5OGTVPCI52"),
Type = "PRIMARY")]));
Order(
OwnId = "pedido_2_id",
Amount = Amount(
Currency = "BRL",
Subtotals = Subtotals(
Shipping = 2000)),
Items = ResizeArray<Item>([
Item(
Product = "Camisa Preta e Vermelha - Alemanha",
Quantity = 1,
Detail = "Camiseta da Copa 2014",
Price = 2000
)]),
Customer = Customer(
OwnId = "customer[1234]",
FullName = "Joao Souza",
Email = "[email protected]",
BirthDate = "1988-12-30",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "22222222222"),
Phone = Phone(
CountryCode = "55",
AreaCode = "11",
Number = "66778899"),
ShippingAddress = Shippingaddress(
City = "São Paulo",
Complement = "10",
District = "Itaim Bibi",
Street = "Avenida Faria Lima",
StreetNumber = "500",
ZipCode = "01234000",
State = "SP",
Country = "BRA")),
Receivers = ResizeArray<Receiver>([
Receiver(
MoipAccount = new Moipaccount(
Id = "MPA-VB5OGTVPCI52"),
Type = "SECONDARY",
FeePayor = false,
Amount = Amount(
Fixed = 55))]))]))
let result =
async {
return! WC.MultiOrder.Create(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.MultiOrder.Consult("MOR-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
MultiPaymentRequest(
InstallmentCount = 1,
FundingInstrument = Fundinginstrument(
Method = "CREDIT_CARD",
CreditCard = Creditcard(
Hash = "HhL0...pIkjl2+3Q==",
Holder = Holder(
FullName = "",
BirthDate = "1988-12-30",
TaxDocument = new Taxdocument(
Type = "CPF",
Number = "33333333333"),
Phone = new Phone(
CountryCode = "55",
AreaCode = "11",
Number = "66778899")))))
let result =
async {
return! WC.MultiPayment.Create(body, "MOR-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.MultiPayment.Consult("MPY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.MultiPayment.CaptureAuthorized("MPY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.MultiPayment.CancelAuthorized("MPY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.MultiPayment.ReleaseCustody |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
NotificationRequest(
Events = ResizeArray<string>(["ORDER.*"; "PAYMENT.AUTHORIZED"; "PAYMENT.CANCELLED"]),
Target = "https://webhook.site/a54daf-da54-8d5a-8d5d1-kfa4gahf42",
Media = "WEBHOOK")
let result =
async {
return! WC.Notification.CreatAccountWirecard(body) |> Async.AwaitTask
} |> Async.RunSynchronously
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.
let body =
NotificationRequest(
Events = ResizeArray<string>(["ORDER.*"]),
Target = "https://webhook.site/a54daf-da54-8d5a-8d5d1-kfa4gahf42",
Media = "WEBHOOK")
let result =
async {
return! WC.Notification.CreateApp(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
NotificationRequest(
Events = ResizeArray<string>(["ORDER.*"]),
Target = "https://webhook.site/a54daf-da54-8d5a-8d5d1-kfa4gahf42",
Media = "WEBHOOK")
let result =
async {
return! WC.Notification.CreateApp(body, "APP-3984HG73HE9") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Notification.Consult("NPR-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Notification.List() |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Notification.Remove("NPR-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
if result = HttpStatusCode.NoContent
then printfn "Caso a Preferência de Notificação tenha sido deletada, você deve receber uma response vazia (NoContent)"
let result =
async {
return! WC.Notification.ConsultWebhook("PAY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Notification.ListWebhooks() |> Async.AwaitTask
} |> Async.RunSynchronously
Ao configurar suas Preferências de Notificação você deve receber os webhooks em formato JSON e você pode desserializar.
let json = "{ \"date\": \"\", \"env\": \"\" }";
let 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:
let token = Request.Headers["Authorization"]
let body =
BankAccountRequest(
BankNumber = "237",
AgencyNumber = "12345",
AgencyCheckNumber = "0",
AccountNumber = "12345678",
AccountCheckNumber = "7",
Type = "CHECKING",
Holder = Holder(
TaxDocument = new Taxdocument(
Type = "CPF",
Number = "622.134.533-22"),
FullName = "Demo Wirecard"))
let accesstoken = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
let result =
async {
return! WC.BankAccount.Create(body, accesstoken, "MPA-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let accesstoken = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
let result =
async {
return! WC.BankAccount.Consult(accesstoken, "BKA-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let accesstoken = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
let result =
async {
return! WC.BankAccount.List(accesstoken, "MPA-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let accesstoken = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
let result =
async {
return! WC.BankAccount.Delete(accesstoken, "BKA-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
BankAccountRequest(
BankNumber = "237",
AgencyNumber = "12345",
AgencyCheckNumber = "8",
AccountNumber = "12345678",
AccountCheckNumber = "8",
Type = "CHECKING",
Holder = new Holder(
TaxDocument = new Taxdocument(
Type = "CPF",
Number = "622.134.533-22"),
FullName = "Nome Completo"))
let accesstoken = "XXXXXXXXXXXXXXXXXXXXXXXXXXX_v2"
let result =
async {
return! WC.BankAccount.Update(body, accesstoken, "MPA-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Balance.Consult() |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Launch.Consult("ENT-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Launch.List() |> Async.AwaitTask
} |> Async.RunSynchronously
let filtros = "filters=status::in(SETTLED)"
let result =
async {
return! WC.Launch.ListFilter(filtros) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
TransferRequest(
Amount = 500,
TransferInstrument = Transferinstrument(
Method = "",
BankAccount = Bankaccount(
Type = "CHECKING",
BankNumber = "001",
AgencyNumber = "1111",
AgencyCheckNumber = "2",
AccountNumber = "9999",
AccountCheckNumber = "8",
Holder = Holder(
FullName = "Nome do Portador",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "22222222222")))))
let accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_v2"
let result =
async {
return! WC.Transfer.Create(body, accessToken) |> Async.AwaitTask
} |> Async.RunSynchronously
let accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_v2"
let result =
async {
return! WC.Transfer.Revert("TRA-XXXXXXXXXXXX", accessToken) |> Async.AwaitTask
} |> Async.RunSynchronously
let accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx_v2"
let result =
async {
return! WC.Transfer.Consult("TRA-XXXXXXXXXXXX", accessToken) |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Transfer.List() |> Async.AwaitTask
} |> Async.RunSynchronously
let filtros = "filters=transferInstrument.method::in(MOIP_ACCOUNT)&limit=3&offset=0"
let result =
async {
return! WC.Transfer.ListFilter(filtros) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
RefundRequest(
//caso queira fazer um reembolso parcial é necessário informar o atributo amount na requisição
Amount = "2000")
let result =
async {
return! WC.Refund.RefundPayment(body, "PAY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
RefundRequest(
Amount = "2000")
let result =
async {
return! WC.Refund.RefundRequestCreditCard(body, "ORD-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Refund.Consult("REF-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Refund.ListPayments("PAY-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Refund.ListOrders("ORD-XXXXXXXXXXXX") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Conciliation.GetSalesFile("20180829") |> Async.AwaitTask
} |> Async.RunSynchronously
//Data no formato YYYYMMDD
let result =
async {
return! WC.Conciliation.GetFinancialFile("2018-08-29") |> Async.AwaitTask
} |> Async.RunSynchronously
//Data no formato YYYY-MM-DD
let body =
PlanRequest(
Code = "plan103",
Name = "Plano Especial",
Description = "Descrição do Plano Especial",
Amount = 990,
Setup_Fee = 500,
Max_Qty = 1,
Interval = Interval(
Length = 1,
Unit = "MONTH"),
Billing_Cycles = 12,
Trial = Trial(
Days = 30,
Enabled = true,
Hold_Setup_Fee = true))
let result =
async {
return! WC.Signature.CreatePlan(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ListPlans() |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ConsultPlan("plan101") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.EnablePlan("plan101") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.DisablePlan("plan101") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
PlanRequest(
Name = "Plano Especial",
Description = "",
Amount = 1290,
Setup_Fee = 800,
Max_Qty = 1,
Payment_Method = "CREDIT_CARD",
Interval = Interval(
Length = 1,
Unit = "MONTH"),
Billing_Cycles = 12,
Trial = Trial(
Days = 30,
Enabled = true,
Hold_Setup_Fee = true))
let result =
async {
return! WC.Signature.ChangePlan(body, "plan101") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
SubscriberRequest(
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 = Address(
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 = Billing_Info(
Credit_Card = Credit_Card(
Holder_Name = "Nome Completo",
Number = "4111111111111111",
Expiration_Month = "06",
Expiration_Year = "22")))
let result =
async {
return! WC.Signature.CreateSubscriber(body, true) |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ListSubscribers() |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ConsultSubscriber("cliente01") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
SubscriberRequest(
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 = Address(
Street = "Rua Nome da Rua1",
StreetNumber = "100",
Complement = "casa",
District = "Nome do Bairro",
City = "São Paulo",
State = "SP",
Country = "BRA",
ZipCode = "05015010"))
let result =
async {
return! WC.Signature.ChangeSubscriber(body, "cliente01") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
SubscriberRequest(
Billing_Info = Billing_Info(
Credit_Card = Credit_Card(
Holder_Name = "Novo nome222",
Number = "5555666677778884",
Expiration_Month = "12",
Expiration_Year = "20")))
let result =
async {
return! WC.Signature.UpdateSubscriberCard(body, "cliente01") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
SubscriptionRequest(
Code = "assinatura04",
Amount = "9000",
Plan = Plan(
Code = "plan101"),
Payment_Method = "CREDIT_CARD",
Customer = Customer(
Code = "cliente01"))
let result =
async {
return! WC.Signature.CreateSubscriptions(body, false) |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ListAllSubscriptions() |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ConsultSubscriptionFilter("assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let filter = "q=assinatura01&filters=status::eq(ACTIVE)"
let result =
async {
return! WC.Signature.ConsultSubscription(filter) |> Async.AwaitTask
} |> Async.RunSynchronously
Alguns exemplos de como filtrar:
- Pesquisar e Filtrar assinaturas (
q=teste&filters=status::eq(EXPIRED)
) - Filtrar assinaturas por status (
filters=status::eq(EXPIRED)&limit=10&offset=0
) - Filtrar assinaturas por creation_date (
filters=creation_date::bt(2014-11-08,2015-05-07)&limit=100&offset=0
) - Filtrar assinaturas por next_invoice_date (
filters=next_invoice_date::bt(2015-10-12,2015-10-12)&limit=100&offset=0
) - Filtrar assinaturas por plano (
filters=plan.code::eq(TESTE_WIRECARD)&limit=100&offset=0
) - Filtrar assinaturas por customer.code (
filters=customer.code::eq(HHDGOo)&limit=100&offset=0
) - Filtrar assinaturas por customer.email (
filters=customer.email::eq([email protected])&limit=100&offset=0
) - Filtrar assinaturas por customer.cpf (
filters=customer.cpf::eq(22222222222)&limit=100&offset=0
) - Filtrar assinaturas por valor (
filters=amount::bt(100,100000)
) - Pesquisar Assinatura (
q=diego nunes&limit=10&offset=0
)
let result =
async {
return! WC.Signature.SuspendSubscription("assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ReactivateSignature("assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.CancelSignature("assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
SubscriptionRequest(
Plan = Plan(
Code = "plan101"),
Amount = "9990",
Next_Invoice_Date = Next_Invoice_Date(
Day = 15,
Month = 12,
Year = 2018))
let result =
async {
return! WC.Signature.ChangeSubscription(body, "assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
SubscriptionRequest(
Payment_Method = "BOLETO")
let result =
async {
return! WC.Signature.ChangePaymentMethod(body, "assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ListSignatureInvoices("assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ConsultInvoice("10865746") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ListAllInvoicePayments("10865746") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ConsultSubscriptionPayment("PAY-123456789012") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
CouponRequest(
Code = "coupon-0002",
Name = "Coupon name",
Description = "My new coupon",
Discount = Discount(
Value = 1000,
Type = "percent"),
Status = "active",
Duration = Duration(
Type = "repeating",
Occurrences = 12),
Max_Redemptions = 100,
Expiration_Date = Expiration_Date(
Year = 2020,
Month = 08,
Day = 01))
let result =
async {
return! WC.Signature.CreateCoupon(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
CouponRequest(
Coupon = Coupon(
Code = "coupon-0001"))
let result =
async {
return! WC.Signature.AssociateCouponForExistingSignature(body, "assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let body = CouponRequest()
let result =
async {
return! WC.Signature.AssociateCouponForExistingSignature(body, "true") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ConsultCoupon("coupon-0001") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.ListAllCoupons() |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.EnableOrDisableCoupon("coupon-0001", "inactive") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.DeleteSignatureCoupon("assinatura01") |> Async.AwaitTask
} |> Async.RunSynchronously
let result =
async {
return! WC.Signature.RetentiveInvoicePayment("1548222") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
RetentativeRequest(
Year = 2020,
Month = 08,
Day = 01)
let result =
async {
return! WC.Signature.CreateNewInvoiceBoleto(body,"1548222") |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
RetentativeRequest(
First_Try = 1,
Second_Try = 3,
Third_Try = 5,
Finally = "cancel")
let result =
async {
return! WC.Signature.CreateAutomaticRetentionRules(body) |> Async.AwaitTask
} |> Async.RunSynchronously
let body =
NotificationRequest(
Notification = Notification(
Webhook = Webhook(
Url = "http://exemploldeurl.com.br/assinaturas"),
Email = Email(
Merchant = Merchant(
Enabled = true),
Customer = Customer(
Enabled = true))))
let result =
async {
return! WC.Signature.CreateNotificationPreference(body) |> Async.AwaitTask
} |> Async.RunSynchronously
As vezes você enfrenta um problema e o suporte Wirecard pede o código json para verificar se realmente está no json:
open Newtonsoft.Json
let body =
PaymentRequest(
DelayCapture = true,
InstallmentCount = 1,
FundingInstrument = Fundinginstrument(
Method = "CREDIT_CARD",
CreditCard = Creditcard(
Id = "CRC-XXXXXXXXXXXX",
Cvc = "123",
Holder = Holder(
FullName = "Jose Portador da Silva",
BirthDate = "1988-12-30",
TaxDocument = Taxdocument(
Type = "CPF",
Number = "33333333333")))))
//Aqui você pode obter json e compratilhar para suporte Wirecard
let json = 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"
}
}
}
}
}
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)
Você pode recuperar os atributos code
, path
, description
, message
e error
, veja no exemplo abaixo:
open Wirecard.Exception
try
let result =
async {
return! WC.Customer.Create(new CustomerRequest()) |> Async.AwaitTask
} |> Async.RunSynchronously
()
with
| :? WirecardException as ex ->
let t = ex.wirecardError
let t_text = ex.GetExceptionText()
()
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 |
Tem dúvidas? Fale com a gente no Slack! Algum problema ? Abre issues!