juriansluiman / SlmIdealPayment

Payment module for Dutch iDEAL payments
Other
9 stars 5 forks source link

Selected lists of iDeal banks for the visitors ... #19

Closed nickurt closed 10 years ago

nickurt commented 10 years ago

It is not possible to have a selection list of banks?, now you are define the bank already in the code ...

Or I have to use SlmIdealPayment\Client\StandardClient and not SlmIdealPayment\Client\Standard\Rabobank?

juriansluiman commented 10 years ago

@nickurt can you elaborate please? I cannot understand your question completely.

There is an SlmIdealPayment\Client\StandardClient class and the service locator provides SlmIdealPayment\Client\Standard\* services which are pre-configured with the correct bank configuration options and certificates.

If you connect via the Rabobank, you can require SlmIdealPayment\Client\Standard\Rabobank and all is already set up. Copy the slmidealpayment.local.php.dist and only set the variables there.

nickurt commented 10 years ago

Well, I'm using now SlmIdealPayment\Client\Standard\Rabobank and going directly to Rabobank, that's correct.

But what I want is, that the visitors can select the bank (ING/Rabo (.e.g)) and then they will be redirected to the bank ...

juriansluiman commented 10 years ago

@nickurt what is the code you've written you are directly redirected to the Rabobank? Usually iDEAL has three steps: you request the available issuers and then the user selects one of them. You request a transaction request, which returns a redirect url you point the client's browser to. Finally when the payment process is completed you've a status request to request the status of the payment.

nickurt commented 10 years ago
// ServiceLocator
$sl             =   $this->getServiceLocator();
$client         =   $sl->get('SlmIdealPayment\Client\Standard\Rabobank');

// Set up the issuer
$issuer = new Model\Issuer;
$issuer->setId('RABONL2U');

[...]

$this->redirect()->toUrl($response->getAuthenticationUrl());

The SlmIdealPayment\Response\DirectoryResponse gives me 9 banks ...


Well, seems I understand it now, I have to first to foreach the banks, and then step 2 with the issuerID it will be redirected to the bank?

juriansluiman commented 10 years ago

@nickurt iDEAL is based on three steps:

  1. The Directory request which gives you all the issues. Put them in a <select>, render them as <a> elements; whatever you like in your design. Mind to cache the issuers list as they don't change very often.
  2. A Transaction request is performed when the user selected the issuer and you've got the id back on your server (with the click on the link or the form submit). Redirect the user to the redirect url, which depends on the selected issuer.
  3. When the user is redirected back you can perform status requests as long as the status is not a "final" status (failure, cancel, success etc)>
nickurt commented 10 years ago

Ok, well then we have to update the example or to fix the code ...

The Directory request gives (your example in readme) me ..

SlmIdealPayment\Response\DirectoryResponse::getContries() in [...]

object(SlmIdealPayment\Response\DirectoryResponse)#407 (2) {
  ["countries":protected]=>
  array(1) {
    [0]=>
    object(SlmIdealPayment\Model\Country)#415 (2) {
      ["name":protected]=>
      string(9) "Nederland"
      ["issuers":protected]=>
      array(9) {
        [0]=>
        object(SlmIdealPayment\Model\Issuer)#416 (2) {
          ["id":protected]=>
          string(8) "ABNANL2A"
          ["name":protected]=>
          string(8) "ABN Amro"
        }
        [1]=>
        object(SlmIdealPayment\Model\Issuer)#414 (2) {
          ["id":protected]=>
          string(8) "INGBNL2A"
          ["name":protected]=>
          string(3) "ING"
        }

[..]
juriansluiman commented 10 years ago

@nickurt that is exactly what you can print with this php code:

foreach ($response->getContries() as $country) {
    echo sprintf("Country: %s\n", $country->getName());

    foreach ($country->getIssuers() as $issuer) {
        echo sprintf("%s: %s\n", $issuer->getId(), $issuer->getName());
    }
}

You var_dump() the DirectoryResponse object, which have the method getCountry() and that returns an array of Country models with the methods getName() and getIssuers(). The issuers method returns an array of Issuer models.

nickurt commented 10 years ago

Your example gives me ...

Fatal error: Call to undefined method SlmIdealPayment\Response\DirectoryResponse::getContries()
juriansluiman commented 10 years ago

@nickurt Ah I reckon the mistake; there is a typo in the README which calls getContries() instead of getCountries(). If you correct that, all should work fine.

nickurt commented 10 years ago

Ah, working, thanks :+1: