Swedbank-SPP / swedbank-payment-portal

Swedbank Payment Portal API library for PHP
Other
36 stars 21 forks source link

HCC card payment #16

Closed lkallas closed 7 years ago

lkallas commented 7 years ago

HCC documentation is poor, therefore I need some help.

I have the following code for HCC card payment:


use SwedbankPaymentPortal\SwedbankPaymentPortal;
use SwedbankPaymentPortal\Options\ServiceOptions;
use SwedbankPaymentPortal\SharedEntity\Authentication;
use SwedbankPaymentPortal\Options\CommunicationOptions;
use SwedbankPaymentPortal\SwedbankPaymentPortal;
use SwedbankPaymentPortal\SharedEntity\Amount;
use SwedbankPaymentPortal\CC\HCCCommunicationEntity\SetupRequest\SetupRequest as HCCSetupRequest;
use SwedbankPaymentPortal\CC\HCCCommunicationEntity\SetupRequest\Transaction as HCCTransaction;
use SwedbankPaymentPortal\SharedEntity\Authentication;
use SwedbankPaymentPortal\UrlCallback;

// SPP options
$options = new ServiceOptions(
        new CommunicationOptions('url'), new Authentication('username', 'password'));

// SPP object
$spp = new SwedbankPaymentPortal($options);

$txnDetails = new HCCTransaction\TxnDetails(new Amount('100.00'), '1234567890');
$hpsTxn = new HCCTransaction\HPSTxn(
        'https://www.domain.com/spp/hcc/expired/1234567890', 
        'https://www.domain.com/spp/hcc/success/1234567890', 
        'https://www.domain.com/spp/hcc/failed/1234567890', 
        168, 
        new HCCTransaction\DynamicData(
            null, 
            'https://www.domain.com/shop'
        )
);

$transaction = new HCCTransaction($txnDetails, $hpsTxn);
$setupRequest = new HCCSetupRequest($transaction);
$callbackUrl = 'https://www.domain.com/spp/callback/1234567890';

$response = $spp->getPaymentCardHostedCardCaptureGateway()->initPayment(
        $setupRequest, UrlCallback::create($callbackUrl)
);

// Redirect URL
$url = $response->getCustomerRedirectUrl();

Payment is finalized after SUCCESS like this:

 $spp->getPaymentCardHostedCardCaptureGateway()->hccQuery('1234567890');

Please advise if this is correctly set up. Currently UrlCallback is never called altough payment is success (I am using TEST environment and credentials if that matters). UrlCallbacks work fine for all the other SPP payment methods.

Swedbank-SPP commented 7 years ago

Hi Ikallas,

To help you I need to understand more what you trying to achieve and why you using HCC instead HPS Please write me to spptechsupport@swedbank.com

lkallas commented 7 years ago

I'am using HCC for no specific reason. Just wanted to see how this is done using SPP library. HPS is more comfortable to use than HCC.

Just followed the diagram in readme file and did some research on HPS/HCC card payments and solved it. I was missing few steps after hccQuery.