pagarme / pagarme-java

Pagar.me's Java API
The Unlicense
46 stars 29 forks source link

Java 11 Compatibility #132

Open LucasHaddad opened 4 years ago

LucasHaddad commented 4 years ago

Is there a Pagar.me Java API java > 8 compatible version release date?

evaporei commented 4 years ago

I'm not sure, but I think the compatibility of this SDK is locked on the source code, it might work by removing this part of the code.

Take a look at this: https://github.com/pagarme/pagarme-java/pull/120/files

LucasHaddad commented 4 years ago

Thanks, something was still going wrong while trying to build the jar [error 1] (Solved). But the solution was found here. Still, the mvn clean package gives me unitary tests errors. Is there any environment building process that should be executed before it [error 2]? (Solved)

Environment:

openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T12:06:16-03:00)
Maven home: ~/lib/apache-maven-3.6.2
Default locale: pt_BR, platform encoding: UTF-8
OS name: "linux", version: "5.0.0-20-generic", arch: "amd64", family: "unix"

[error 1] Exception log:

[ERROR] Source option 5 is no longer supported. Use 6 or later.

Solution: Adding some properties to the pom.xml file resolved it (just registering it here to help anyone who encounters the same difficulties).

# inside properties
<maven.compiler.source>1.6</maven.compiler.source>    
<maven.compiler.target>1.6</maven.compiler.target>

# inside plugins
<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.6.1</version>
      <configuration>
            <source>1.6</source>
            <target>1.6</target>
      </configuration>
</plugin>

[error 2] It was a proxy problem, but the error said about connecting timeout without specifing it as a proxy problem.

I've changed the source version to use Java 11 and the RestClient to use HttpsURLConnection and to accept java 11. Have also changed PagarmeCalendar to accept 1 and 2 digit versions and use proxy too.

It's almost working now though I had to add proxy settings to the java code 'cause the company I work for uses proxy. Almost all tests are OK, 82 from 83 but the TransactionTestApiV3::testCreditCardTransactionApiV3 that is getting refused instead of paid, whe using IntelliJ test task.

@otaviopace are there any tips for helping me? Already recreated the request using postman and the returning transaction status is refused. URL: https://api.pagar.me/1/transactions?api_key=MY_TEST_API_KEY Headers:

Content-Type:application/json
X-PagarMe-User-Agent:PagarMe-Java/1.5.8
User-Agent:PagarMe-Java/1.5.8
Accept:application/json
X-PagarMe-Version:2017-08-28
Cache-Control:no-cache

Body:

{
    "amount": 21000,
    "card_number": "4111111111111111",
    "card_cvv": "123",
    "card_expiration_date": "0922",
    "card_holder_name": "Morpheus Fishburne",
    "customer": {
      "external_id": "#3311",
      "name": "Morpheus Fishburne",
      "type": "individual",
      "country": "br",
      "email": "mopheus@nabucodonozor.com",
      "documents": [
        {
          "type": "cpf",
          "number": "00000000000"
        }
      ],
      "phone_numbers": ["+5511999998888", "+5511888889999"],
      "birthday": "1965-01-01"
    },
    "billing": {
      "name": "Trinity Moss",
      "address": {
        "country": "br",
        "state": "sp",
        "city": "Cotia",
        "neighborhood": "Rio Cotia",
        "street": "Rua Matrix",
        "street_number": "9999",
        "zipcode": "06714360"
      }
    },
    "shipping": {
      "name": "Neo Reeves",
      "fee": 1000,
      "delivery_date": "2000-12-21",
      "expedited": true,
      "address": {
        "country": "br",
        "state": "sp",
        "city": "Cotia",
        "neighborhood": "Rio Cotia",
        "street": "Rua Matrix",
        "street_number": "9999",
        "zipcode": "06714360"
      }
    },
    "items": [
      {
        "id": "r123",
        "title": "Red pill",
        "unit_price": 10000,
        "quantity": 1,
        "tangible": true
      },
      {
        "id": "b123",
        "title": "Blue pill",
        "unit_price": 10000,
        "quantity": 1,
        "tangible": true
      }
    ]
}

Response:

{
    "object": "transaction",
    "status": "refused",
    "refuse_reason": "antifraud",
    "status_reason": "antifraud",
    "acquirer_response_code": "0000",
    "acquirer_name": "pagarme",
    "acquirer_id": "5bb3cb809cf0bbd27730ca53",
    "authorization_code": "229470",
    "soft_descriptor": null,
    "tid": 7337672,
    "nsu": 7337672,
    "date_created": "2019-11-19T00:08:29.646Z",
    "date_updated": "2019-11-19T00:08:30.121Z",
    "amount": 21000,
    "authorized_amount": 21000,
    "paid_amount": 0,
    "refunded_amount": 0,
    "installments": 1,
    "id": 7337672,
    "cost": 0,
    "card_holder_name": "Morpheus Fishburne",
    "card_last_digits": "1111",
    "card_first_digits": "411111",
    "card_brand": "visa",
    "card_pin_mode": null,
    "card_magstripe_fallback": false,
    "cvm_pin": false,
    "postback_url": null,
    "payment_method": "credit_card",
    "capture_method": "ecommerce",
    "antifraud_score": null,
    "boleto_url": null,
    "boleto_barcode": null,
    "boleto_expiration_date": null,
    "referer": "api_key",
    "ip": "187.111.19.98",
    "subscription_id": null,
    "phone": null,
    "address": null,
    "customer": {
        "object": "customer",
        "id": 2466257,
        "external_id": "#3311",
        "type": "individual",
        "country": "br",
        "document_number": null,
        "document_type": "cpf",
        "name": "Morpheus Fishburne",
        "email": "mopheus@nabucodonozor.com",
        "phone_numbers": [
            "+5511999998888",
            "+5511888889999"
        ],
        "born_at": null,
        "birthday": "1965-01-01",
        "gender": null,
        "date_created": "2019-11-19T00:08:29.557Z",
        "documents": [
            {
                "object": "document",
                "id": "doc_ck353nt6o0bimqu6foctkwvcu",
                "type": "cpf",
                "number": "00000000000"
            }
        ]
    },
    "billing": {
        "object": "billing",
        "id": 1103665,
        "name": "Trinity Moss",
        "address": {
            "object": "address",
            "street": "Rua Matrix",
            "complementary": null,
            "street_number": "9999",
            "neighborhood": "Rio Cotia",
            "city": "Cotia",
            "state": "sp",
            "zipcode": "06714360",
            "country": "br",
            "id": 2493357
        }
    },
    "shipping": {
        "object": "shipping",
        "id": 904952,
        "name": "Neo Reeves",
        "fee": 1000,
        "delivery_date": "2000-12-21",
        "expedited": true,
        "address": {
            "object": "address",
            "street": "Rua Matrix",
            "complementary": null,
            "street_number": "9999",
            "neighborhood": "Rio Cotia",
            "city": "Cotia",
            "state": "sp",
            "zipcode": "06714360",
            "country": "br",
            "id": 2493358
        }
    },
    "items": [
        {
            "object": "item",
            "id": "b123",
            "title": "Blue pill",
            "unit_price": 10000,
            "quantity": 1,
            "category": null,
            "tangible": true,
            "venue": null,
            "date": null
        },
        {
            "object": "item",
            "id": "r123",
            "title": "Red pill",
            "unit_price": 10000,
            "quantity": 1,
            "category": null,
            "tangible": true,
            "venue": null,
            "date": null
        }
    ],
    "card": {
        "object": "card",
        "id": "card_ck353nt8a0binqu6f7hev906x",
        "date_created": "2019-11-19T00:08:29.627Z",
        "date_updated": "2019-11-19T00:08:30.179Z",
        "brand": "visa",
        "holder_name": "Morpheus Fishburne",
        "first_digits": "411111",
        "last_digits": "1111",
        "country": "UNITED STATES",
        "fingerprint": "cj5bw4cio00000j23jx5l60cq",
        "valid": false,
        "expiration_date": "0922"
    },
    "split_rules": null,
    "metadata": {},
    "antifraud_metadata": {},
    "reference_key": null,
    "device": null,
    "local_transaction_id": null,
    "local_time": null,
    "fraud_covered": false,
    "order_id": null,
    "risk_level": "unknown",
    "receipt_url": null,
    "payment": null,
    "addition": null,
    "discount": null,
    "private_label": null
}

But the 79 tests ran by the mvn clean package works fine, I was able to build the jar.