Implementing Payment Provider

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Implementing Payment Provider

Post by khizar » 10 Apr 2021, 09:21

Hey aimeos ,
i am using aimeos with laravel.
versions:
"aimeos/aimeos-laravel": "~2020.10",
"laravel/framework": "^8.12",

i am implementing payment provider (Hyper Pay).There are three steps to integrate
1)First, perform a server-to-server POST request to prepare the checkout with the required data, including the order type, amount and currency. The response to a successful request is a JSON string with an id, which is required in the second step to create the payment form.
i have done first step I am posting my code below

Code: Select all

<?php

namespace Aimeos\MShop\Service\Provider\Payment;

class Myprovider
extends \Aimeos\MShop\Service\Provider\Payment\Base
implements \Aimeos\MShop\Service\Provider\Payment\Iface
{
    /**
     * Tries to get an authorization or captures the money immediately for the given
     * order if capturing isn't supported or not configured by the shop owner.
     *
     * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object
     * @param array $params Request parameter if available
     * @return \Aimeos\MShop\Common\Helper\Form\Standard Form object with URL, action
     *  and parameters to redirect to    (e.g. to an external server of the payment
     *  provider or to a local success page)
     */
    public function process(\Aimeos\MShop\Order\Item\Iface $order, array $params = []): ?\Aimeos\MShop\Common\Helper\Form\Iface
    {
        // perform your actions
        $basket = $this->getOrderBase($order->getBaseId());
        $total = $basket->getPrice()->getValue() + $basket->getPrice()->getCosts();

        $url = "https://test.oppwa.com/v1/checkouts";
        $data = "entityId=8a8294174d0595bb014d05d82e5b01d2" .
            "&amount=92.00" .
            "&currency=EUR" .
            "&paymentType=DB";

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Authorization:Bearer OGE4Mjk0MTc0ZDA1OTViYjAxNGQwNWQ4MjllNzAxZDF8OVRuSlBjMm45aA=='
        ));
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // this should be set to true in production
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $responseData = curl_exec($ch);
        if (curl_errno($ch)) {
            return curl_error($ch);
        }
        curl_close($ch);
        info($responseData);

        if( !isset( $params['myprovider.accountno'] ) || $params['myprovider.accountno'] )
    {
        // define the form to collect the payment data from the customer
        $list = [
            'myprovider.accountno' => new \Aimeos\MW\Criteria\Attribute\Standard( [
                'label' => 'Account number',
                'code' => 'myprovider.accountno',
                'internalcode' => 'myprovider.accountno',
                'internaltype' => 'string',
                'type' => 'string',
                'default' => '',
                'public' => true,
            ] ),
        ];

        $selfUrl = $this->getConfigValue( 'payment.url-self' );
        return new \Aimeos\MShop\Common\Helper\Form\Standard( $selfUrl, 'POST', $list ,'<script src="https://test.oppwa.com/v1/paymentWidgets.js?checkoutId=B3A3469794055654BF1910408A4D71E7.uat01-vm-tx02"></script>');
    }
        // return parent::process($order, $params);
    }
}
Now after i have sent an api request i want to make a form and in the api docs the there are some requirements to make a form
1) a script tag( <script src="https://test.oppwa.com/v1/paymentWidget ... "></script>)
2) there are some attributes which are required for a form ( action="{shopperResultUrl}" class="paymentWidgets" data-brands="VISA MASTER AMEX")

now how can i pass script tag,class and data-brands to the form using formhelper please guide me on that

User avatar
aimeos
Administrator
Posts: 7890
Joined: 01 Jan 1970, 00:00

Re: Implementing Payment Provider

Post by aimeos » 11 Apr 2021, 12:13

HyperPay is already supported by the Omnipay OPPWA driver:
https://aimeos.org/docs/latest/manual/services/#oppwa
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: Implementing Payment Provider

Post by khizar » 12 Apr 2021, 09:38

aimeos wrote: 11 Apr 2021, 12:13 HyperPay is already supported by the Omnipay OPPWA driver:
https://aimeos.org/docs/latest/manual/services/#oppwa
i followed the link which you provided and downloaded packages using
composer req aimeos/ai-payments vdbelt/omnipay-oppwa
after that when i open services panel then i found
Image
Image

as you can see above there is no opwa in providers list so i selected Omnipay and added some attributes
Image
after that i placed order and at the end of checkout the form that appears is this
Image

now the api which we bought is hyperpay and i am posting a link below please have a look at that it contains three steps and the form is
Image
HYPER PAY LINK: https://hyperpay.docs.oppwa.com/tutoria ... ion-guide/
now you can see that both the form that appears are different and i really confussed at implementing hyperpay.so can you please guide me how can i use the approach which is given in the documentaion or it will work through omnipay provider.
Also in aimeos docs it is given that userid and password is required but when we asked for the username and password from hyperpay they have said
Please note that the current integration that they using is old and we disable this API Kindly ask them to make the migration using the below link

Please note that we remove the user and password and we replace ut with Access token

https://hyperpay.docs.oppwa.com/tutoria ... tion-guide

User avatar
aimeos
Administrator
Posts: 7890
Joined: 01 Jan 1970, 00:00

Re: Implementing Payment Provider

Post by aimeos » 14 Apr 2021, 08:29

We don't have any experience with HyperPay but the intergration in the docs you are mentioning seems to be a different one. Did you check if the Aimeos payment form for works nevertheless.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: Implementing Payment Provider

Post by khizar » 14 Apr 2021, 08:54

aimeos wrote: 14 Apr 2021, 08:29 We don't have any experience with HyperPay but the intergration in the docs you are mentioning seems to be a different one. Did you check if the Aimeos payment form for works nevertheless.
i added a script tag in the ext\ai-client-html\client\html\templates\checkout\standard\process-body-standard but it didn't worked

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: Implementing Payment Provider

Post by khizar » 14 Apr 2021, 08:58

aimeos wrote: 14 Apr 2021, 08:29 We don't have any experience with HyperPay but the intergration in the docs you are mentioning seems to be a different one. Did you check if the Aimeos payment form for works nevertheless.
ok.actually to show the payment form it needs
1) script tag
2) a specif class and data-brand attribute on the form tag (i.e class="paymentWidgets" data-brands="VISA MASTER AMEX")
can you please show me how can i pass these to form object so that it can be included in the payment form

User avatar
aimeos
Administrator
Posts: 7890
Joined: 01 Jan 1970, 00:00

Re: Implementing Payment Provider

Post by aimeos » 14 Apr 2021, 09:31

I meant, does the payment work with the Aimeos payment form without any change and additional code?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: Implementing Payment Provider

Post by khizar » 14 Apr 2021, 09:33

aimeos wrote: 14 Apr 2021, 09:31 I meant, does the payment work with the Aimeos payment form without any change and additional code?
no it doesn't work

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: Implementing Payment Provider

Post by khizar » 14 Apr 2021, 09:35

i also tried to add return view('paymentform') but it didn't work because as you know it only accepts \Aimeos\MShop\Common\Helper\Form\Standard as a return. so is there any way to return my custom form here

khizar
Posts: 99
Joined: 19 Jan 2021, 09:51

Re: Implementing Payment Provider

Post by khizar » 14 Apr 2021, 09:50

and also please tell me that the three step approach which is given in the api docs, is it possible to implement this in aimeos

Post Reply