2017 © Pedro Peláez
 

library omnipay-hipay

Integrate Hipay in omnipay

image

bankette/omnipay-hipay

Integrate Hipay in omnipay

  • Tuesday, June 28, 2016
  • by bankette
  • Repository
  • 1 Watchers
  • 0 Stars
  • 40 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Omnipay - Hipay gateway

Omnipay gateway for hipay., (*1)

This code needs amelioration but is a good base to integrate hipay in your omnipay. Please feel free to fork and do PR to improve this library., (*2)

Purchase

Here is a code example for symfony to send a purchase request to hipay., (*3)

use Bankette\OmnipayHipay\Gateway;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;

/**
 * Payment by hipay Action.
 *
 * @return Response
 */
    public function hipayPaymentAction(SymfonyRequest $request)
    {
        $data = [
            'orderid' => 'my-order-id',
            'amount' => 10,
            'currency' => 'EUR',
            'card' => [
                'number' => '4000000000000002',
                'expiryMonth' => '10',
                'expiryYear' => '2020',
                'cvv' => '123',
            ],
            'cardtype' => 'visa',
            'description' => 'description',
        ];

        $gateway = new Gateway();
        $gateway->setClientId($this->username);
        $gateway->setSecret($this->password);
        $gateway->setTestMode(true);
        $purchaseResponse = $gateway->purchase($data)->send();

        if (!$purchaseResponse->isSuccessful() && !$purchaseResponse->isRedirect()) {
            throw new BadRequestHttpException($purchaseResponse->getError());
        }

        if ($purchaseResponse->isSuccessful()) {
            // Payment validated
        }

        if ($purchaseResponse->isRedirect() && $purchaseResponse->getRedirectUrl()) {
            // Payment waiting for 3D secure validation
        }
        // ...
    }

Notify

After a purchase request, hipay will send notifications on the 'notification URL' defined in hipay back-office. The below controller will be called directly by hipay API on your API., (*4)

    /**
     * @return Response
     *
     * @Route("/hipay/notify")
     *
     * @Method("POST")
     *
     * @View()
     *
     * @throws NotFoundHttpException
     */
    public function hipayNotifyAction(SymfonyRequest $request)
    {
        $gateway = new Gateway();

        $response = $gateway->completePurchase();

        switch ($response->getStatus()) {
            // Status "Cardholder Enrolled"
            case '103':
            // Status "Cardholder Not Enrolled"
            case '104':
            // Status "Authorized"
            case '116':
            // Status "Capture Requested"
            case '117':
                // do something
                break;

            // Status "Captured"
            case '118':
                // do something
                break;

            // Status "Could Not Authenticate"
            case '108':
            // Status "Authentication Failed"
            case '109':
            // Status "Refused"
            case '113':
            // Status "Expired"
            case '114':
                // do something
                break;

            default:
                // do something
                break;
        }

        return new Response();
    }

The Versions

28/06 2016

dev-master

9999999-dev

Integrate Hipay in omnipay

  Sources   Download

The Requires

 

payment pay gateway merchant purchase omnipay hipay

28/06 2016

v1.0

1.0.0.0

Integrate Hipay in omnipay

  Sources   Download

The Requires

 

payment pay gateway merchant purchase omnipay hipay