Problem between PagSeguro and number of plots

5

I made the implementation of a custom virtual store in the PHP language and as a checkout I am using PagSeguro .

In the implementation, the transparent checkout was used and was functioning correctly, but the client requested that the option of installment of the order be added. When trying to perform the request of parcels using Javascript API , the answer is always the same:

  

{"errors": {"Invalid SESSION:   d4d905b585ec4d4d8056e380df70e4a5. ":" 10005 "}," error ": true}

To make this request I am using the following Javascript method:

PagSeguroDirectPayment.getInstallments

I would like a help to solve, as I said before the checkout was working correctly and the only change was the addition of the installment.

Methods used

Return from getSessionId

  

{"result": true, "data": "b099c6f4beff41e0a08a4912f7ce9554"}

Search for the banner of the card

PagSeguroDirectPayment.getBrand({
    cardBin: $scope.pagamento.cartao,
    success: function(response) {
        if (response && response.brand && response.brand.name) {
            $scope.bandeira = response.brand.name;
            $scope.getParcelasCartao();
        }
    },
    error: function(response) {
        console.log(response);
    }
});

Search for means of payment

PagSeguroDirectPayment.getInstallments({
    amount: valor,
    maxInstallmentNoInterest: 2,
    brand: $scope.bandeira,
    success: function(response) {
        console.log(response);
        if (response.error == false) {
            $scope.parcelamento = response.installments[$scope.bandeira];
        }
    },
    error: function(response) {
        console.log(response);
        $scope.parcelamento = new Array();
    },
    complete: function(response) {

    }
});

Parameters that are sent in the request to seek the installment

  

sessionId: b099c6f4beff41e0a08a4912f7ce9554

     

amount: 49.90

     

creditCardBrand: visa

     

maxInstallmentNoInterest: 2

Return search:

  

{"errors": {"Invalid SESSION: b099c6f4beff41e0a08a4912f7ce9554.": "10005"}, "error": true}

    
asked by anonymous 22.04.2015 / 14:23

1 answer

6

I recently did an integration with Transparent PagSeguro, and I came across this and other difficulties.

Assuming you are using their official library in PHP ( link ), follow the problems found below and how they have been resolved, starting with what I believe to be the cause of your problem (of course to be sure there is a need to see the PHP code):

maxInstallmentNoInterest

  

A common mistake is to send a field to PS by JS and not do the same for PHP. The problem is that in the specific case of this field, the library does not have its own attribute to send it, making use of addParameter , like this: $psRequest->addParameter('noInterestInstallmentQuantity', 2);

Bank Name

  

For payments via Online Debit (EFT), there is a need to inform the name of the bank, something that is not clear in the manual. To do this, use the setOnlineDebit method, like this: $psRequest->setOnlineDebit(array("bankName" => 'nome do banco');

EFT vs. ONLINE_DEBIT

  

The JS getPaymentMethods method returns a JSON whose online payment naming is ONLINE_DEBIT . However, in the PHP library this nomenclature changes to EFT . The PHP class where this is found is PagSeguroDirectPaymentMethods, and one way to correct this conflict is to add the following line in the $ methodsList attribute declaration: "ONLINE_DEBIT" => "eft",

I hope these suggestions can help you finalize your project.

    
11.05.2015 / 14:03