Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problemas ao executar pagamento via cartão de crédito - PRODUÇÃO #26

Open
jhonyjss opened this issue Mar 8, 2022 · 1 comment
Open

Comments

@jhonyjss
Copy link

jhonyjss commented Mar 8, 2022

Olá estou enfrentando problemas ao tentar virar a chave para produção,

Meu código funciona perfeitamente em ambiente de TESTE, porém quando coloco a chave de PROD ele identifica que eu não estou enviando campos como esse erro abaixo, porém estou enviando sim, e como eu disse, em ambiente de TESTE funciona, acredito eu que o ambiente de PROD está pegando alguma coisa da Versão anterior, pelo menos não consegui executar.

antes que me perguntem eu estou sim iniciando a chave aqui >>

$client = new \PagarmeCoreApiLib\PagarmeCoreApiClient($basicAuthUserName, $basicAuthPassword);
"gateway_response": {
                  "code": "400",
                    "errors": [
                        {
                            "message": "invalid_parameter | customer[document_number] | n\u00famero do documento est\u00e1 faltando"
                        },
                        {
                            "message": "invalid_parameter | customer[address][zipcode] | CEP est\u00e1 faltando"
                        },
                        {
                            "message": "invalid_parameter | customer[address][neighborhood] | bairro est\u00e1 faltando"
                        },
                        {
                            "message": "invalid_parameter | customer[address][street] | rua est\u00e1 faltando"
                        },
                        {
                            "message": "invalid_parameter | customer[address][street_number] | n\u00famero da rua est\u00e1 faltando"
                        },
                        {
                            "message": "invalid_parameter | customer[phone][number] | n\u00famero de telefone inv\u00e1lido"
                        },
                        {
                            "message": "invalid_parameter | customer[phone][ddd] | DDD est\u00e1 faltando"
                        }
                    ]
                },

Esse é meu script em PHP

customerController = $client->getCustomers();

    $customer = new \PagarmeCoreApiLib\Models\CreateCustomerRequest();
    $customer->name = $holder_name; // passo params aqui
    $customer->email = "jhony@gmail.com";
    $customer->document_type = "CPF";
    $customer->document = "37537537569";
    $customer->type = "individual";
    $customer->code = "777";

    $customer->address = new \PagarmeCoreApiLib\Models\CreateAddressRequest();
    $customer->address->street = "375, Av. General Justo, Centro";
    $customer->address->line1 = "375, Av. General Justo, Centro";
    $customer->address->zipCode = "04678002";
    $customer->address->neighborhood = "Gopouva";
    $customer->address->number = "77";
    $customer->address->city = "Sao Paulo";
    $customer->address->state = "SP";
    $customer->address->country = "BR";
    $customer->address->metadata = new \PagarmeCoreApiLib\Models\UpdateMetadataRequest();
    $customer->address->metadata->id = "1234";
    

    $customer->phones = new \PagarmeCoreApiLib\Models\CreatePhonesRequest();
    $customer->phones->homePhone = new \PagarmeCoreApiLib\Models\CreatePhoneRequest();
    $customer->phones->homePhone->areaCode = "11";
    $customer->phones->homePhone->countryCode = "55";
    $customer->phones->homePhone->number = "58587070";
    
    $request = new \PagarmeCoreApiLib\Models\CreateCardRequest();
    
    $request->number = str_replace('.','', $cc_number);
    $request->holderName = $holder_name;
    $request->expMonth = (int)$due_date[0];
    $request->expYear = (int)$due_date[1];
    $request->cvv = $cvv;
    $request->holderDocument = "37537537569";
    // Billing Address;
    $request->billingAddress = new \PagarmeCoreApiLib\Models\CreateAddressRequest();
    $request->billingAddress->line1 = "Rua dona Antonia";
    $request->billingAddress->street = "Rua dona Antonia";
    $request->billingAddress->zipCode = "7021000";
    $request->billingAddress->city = "Guarulhos";
    $request->billingAddress->neighborhood = "Gopouva";
    $request->billingAddress->state = "SP";
    $request->billingAddress->country = "BR";
    
    $createdCustomer = $customerController->createCustomer($customer);
    $result = $customerController->createCard($createdCustomer->id, $request);

    $orderController = $client->getOrders();

    $creditCard = new \PagarmeCoreApiLib\Models\CreateCreditCardPaymentRequest();
    $creditCard->capture = true;
    $creditCard->installments = 1;
    $creditCard->card = new \PagarmeCoreApiLib\Models\CreateCardRequest();
    $creditCard->card->number = str_replace('.','', $cc_number);
    $creditCard->card->holderName = $holder_name;
    $creditCard->card->expMonth = (int)$due_date[0];
    $creditCard->card->expYear = (int)$due_date[1];
    $creditCard->card->cvv = $cvv;

    $request = new \PagarmeCoreApiLib\Models\CreateOrderRequest();

    $request->items = [new \PagarmeCoreApiLib\Models\CreateOrderItemRequest()];
    $request->items[0]->description = "teste descriptions";
    $request->items[0]->quantity = 1;
    $request->items[0]->amount = 100 * 1; // this value should be in cents
    $request->items[0]->code = "777"; // this value should be in cents

    $request->payments = [new \PagarmeCoreApiLib\Models\CreatePaymentRequest()];
    $request->payments[0]->paymentMethod = "credit_card";
    $request->payments[0]->creditCard = $creditCard;
    $request->customer = $customer;
    
    $result = $orderController->createOrder($request);
    echo json_encode($result, JSON_PRETTY_PRINT);
@julioccguimaraes
Copy link

Já tive 2 clientes com esse erro de endereço (customer e payment) que está sendo enviado e o pagar.me não reconhece. Depois de quebrar muito a cabeça, o problema era do lado do Pagar.me porque segundo o suporte de homologação:
"Acho que ajustei aqui o que estava dando errado, a versão da API no nosso banco de dados estava diferente da utilizada.". Depois desse ajuste, a integração funcionou. Fica a dica.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants