versão carregada: sexta, 12 de julho de 2024

Integração PIX com PagSeguro

qrcode

Oferecemos uma melhoria para a tradicional biblioteca PHP para o PagSeguro. Trata-se da nova opção de pagamento com PIX, utilizando as mesmas funções da biblioteca, para sua comodidade.

A biblioteca oficial não suporta o PIX com a nova API Orders.

A requisição e resposta são diferentes do convencional utilizado para boleto e cartão. Um exemplo de requisição:

array(6) {
  ["customer"]=>
  array(4) {
    ["name"]=>
    string(14) "CLIENTE TESTE"
    ["email"]=>
    string(19) "[email protected]"
    ["tax_id"]=>
    string(11) "67423381055"
    ["phones"]=>
    array(1) {
      [0]=>
      array(4) {
        ["country"]=>
        string(2) "55"
        ["area"]=>
        string(2) "12"
        ["number"]=>
        string(9) "312312312"
        ["type"]=>
        string(6) "MOBILE"
      }
    }
  }
  ["reference_id"]=>
  string(21) "REF-65e0f35cccb5a"
  ["currency"]=>
  string(3) "BRL"
  ["items"]=>
  array(1) {
    [0]=>
    array(4) {
      ["reference_id"]=>
      int(1)
      ["name"]=>
      string(4) "test"
      ["quantity"]=>
      int(1)
      ["unit_amount"]=>
      string(5) "10000"
    }
  }
  ["qr_codes"]=>
  array(1) {
    [0]=>
    array(2) {
      ["amount"]=>
      array(1) {
        ["value"]=>
        float(100)
      }
      ["expiration_date"]=>
      string(25) "2024-03-01T18:13:06-03:00"
    }
  }
  ["notification_urls"]=>
  array(1) {
    [0]=>
    string(84) "https://teste.com.br/site/app/apis/returnPagseguro.php"
  }
}

Agora um exemplo de resposta:

string(502) "{"customer":{"name":"CLIENTE TESTE","email":"[email protected]","tax_id":"67423381055","phones":[{"country":"55","area":"12","number":"312312312","type":"MOBILE"}]},"reference_id":"TORNEIO-65e0f35cccb5a","currency":"BRL","items":[{"reference_id":1,"name":"test","quantity":1,"unit_amount":"10000"}],"qr_codes":[{"amount":{"value":100},"expiration_date":"2024-03-01T18:13:06-03:00"}],"notification_urls":["https:\/\/pecbrasil.com.br\/site\/app\/apis\/subscriptions-tournaments\/returnPagseguro.php"]}"
{"id":"ORDE_B4533226-1514-4BF6-B6D2-19FB24E1CAF3","reference_id":"REF-65e0f35cccb5a","created_at":"2024-02-29T18:13:06.875-03:00","customer":{"name":"CLIENTE TESTE","email":"[email protected]","tax_id":"67423381055","phones":[{"type":"MOBILE","country":"55","area":"12","number":"312312312"}]},"items":[{"reference_id":"1","name":"test","quantity":1,"unit_amount":10000}],"qr_codes":[{"id":"QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8","expiration_date":"2024-03-01T18:13:06.000-03:00","amount":{"value":100},"text":"00020101021226830014br.gov.bcb.pix2561api.pagseguro.com/pix/v2/C3896440-D5D9-46C4-8CCF-51EBB14753B827600016BR.COM.PAGSEGURO0136C3896440-D5D9-46C4-8CCF-51EBB14753B852045311530398654041.005802BR5922Cliente Teste C6014PATOS DE MINAS62070503***6304B7D6","arrangements":["PIX"],"links":[{"rel":"QRCODE.PNG","href":"https://api.pagseguro.com/qrcode/QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8/png","media":"image/png","type":"GET"},{"rel":"QRCODE.BASE64","href":"https://api.pagseguro.com/qrcode/QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8/base64","media":"text/plain","type":"GET"}]}],"notification_urls":["https://teste.com.br/site/app/apis/returnPagseguro.php"],"links":[{"rel":"SELF","href":"https://api.pagseguro.com/orders/ORDE_B4533226-1514-4BF6-B6D2-19FB24E1CAF3","media":"application/json","type":"GET"},{"rel":"PAY","href":"https://api.pagseguro.com/orders/ORDE_B4533226-1514-4BF6-B6D2-19FB24E1CAF3/pay","media":"application/json","type":"POST"}]}string(1506) "{"id":"ORDE_B4533226-1514-4BF6-B6D2-19FB24E1CAF3","reference_id":"REF-65e0f35cccb5a","created_at":"2024-02-29T18:13:06.875-03:00","customer":{"name":"GERMANE GUERRA","email":"[email protected]","tax_id":"67423381055","phones":[{"type":"MOBILE","country":"55","area":"12","number":"312312312"}]},"items":[{"reference_id":"1","name":"test","quantity":1,"unit_amount":10000}],"qr_codes":[{"id":"QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8","expiration_date":"2024-03-01T18:13:06.000-03:00","amount":{"value":100},"text":"00020101021226830014br.gov.bcb.pix2561api.pagseguro.com/pix/v2/C3896440-D5D9-46C4-8CCF-51EBB14753B827600016BR.COM.PAGSEGURO0136C3896440-D5D9-46C4-8CCF-51EBB14753B852045311530398654041.005802BR5922Cliente Teste C6014PATOS DE MINAS62070503***6304B7D6","arrangements":["PIX"],"links":[{"rel":"QRCODE.PNG","href":"https://api.pagseguro.com/qrcode/QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8/png","media":"image/png","type":"GET"},{"rel":"QRCODE.BASE64","href":"https://api.pagseguro.com/qrcode/QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8/base64","media":"text/plain","type":"GET"}]}],"notification_urls":["https://teste.com.br/site/app/apis/returnPagseguro.php"],"links":[{"rel":"SELF","href":"https://api.pagseguro.com/orders/ORDE_B4533226-1514-4BF6-B6D2-19FB24E1CAF3","media":"application/json","type":"GET"},{"rel":"PAY","href":"https://api.pagseguro.com/orders/ORDE_B4533226-1514-4BF6-B6D2-19FB24E1CAF3/pay","media":"application/json","type":"POST"}]}"
{"status":200,"callbackLink":"https:\/\/www.pecbrasil.com.br\/painel\/atleta\/ver-inscricao-em-torneio\/65e0f35cccb5a","ticket":{"info":{"tournament":2242,"tournamentcategory":1172,"team":2990,"payment":7,"code":"65e0f35cccb5a","id":195},"register":{"id":3544,"name":"GERMANE GUERRA","cpf":"674.233.810-55","rg":"123131","genre":"Masculino","email":"[email protected]","phone":"(13) 59499-6874","celular":"(12) 31231-2312","dateofbirth":null,"country":"Brasil","state":"MG","state_full":"Minas Gerais","city":"Alpercata","district":"123","cep":"12312-312","address":"123123123","number":"1231231","complement":"12312312"},"payment":{"reference":"TORNEIO-65e0f35cccb5a","code":"ORDE_B4533226-1514-4BF6-B6D2-19FB24E1CAF3","label":null,"method":"Pix","title":"Teste m\u00f3dulo de inscricao","details":"PEC 250 - PRO (Livre) - 1\u00aa Classe - Masculino","quantity":1,"transaction":"1.00","amount":"1,00","qr_code":"https:\/\/api.pagseguro.com\/qrcode\/QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8\/png"},"log":[{"timestamp":"2024-02-29 18:13:00","status":"open"},{"status":"no-payment","timestamp":"2024-02-29 18:13:06"}],"team":[{"name":"Germane Guerra","url":"https:\/\/www.teste.com.br\/atleta\/germane-guerra","avatar":{"src":"https:\/\/www.teste.com.br\/site\/public\/img\/no-avatar-player.jpg","width":400,"height":400},"amount":"1,00"}],"status":{"code":"open","time":"2024-02-29 18:13:00","label":"Inscri\u00e7\u00e3o em aberto","class":"success"},"pix":{"link":"https:\/\/api.pagseguro.com\/qrcode\/QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8\/png","text":"00020101021226830014br.gov.bcb.pix2561api.pagseguro.com\/pix\/v2\/C3896440-D5D9-46C4-8CCF-51EBB14753B827600016BR.COM.PAGSEGURO0136C3896440-D5D9-46C4-8CCF-51EBB14753B852045311530398654041.005802BR5922Paulo Ricardo Correa C6014PATOS DE MINAS62070503***6304B7D6","id":"QRCO_C3896440-D5D9-46C4-8CCF-51EBB14753B8","due":"Pague at\u00e9 01\/03\/2024 18:13","duetimestamp":1709327587}}}

Entregamos sua cobrança via PIX automatizada com PagSeguro funcional e testada. Fazemos a configuração completa.

Quer saber mais sobre como funciona? Fale com um desenvolvedor agora mesmo!
Inscrever-se
Notify of
guest
0 Comentários
Inline Feedbacks
View all comments

Tags relacionadas