Change return type of payment provider

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Kappa.yahyya
Posts: 9
Joined: 14 Jun 2021, 05:59

Change return type of payment provider

Post by Kappa.yahyya » 18 Jun 2021, 07:57

Hi


Iam working on aimeos/laravel version (on php 7.4)

I’ve created an extension to handle our custom methods , and in this case working on custom payment method for Stripe paymentIntent.



My problem is on “process” function of the payment provider , I need to return a json value ( which is returned form stipe paymentIntent api(Secret_key) ) using Response() method of laravel. 




But the process function has a return type of “…\Helper\Form\Iface” and I can not change it from anywhere .



I used ‘ print “”; and exit; ‘ for my solution but I know its not a good way.


I am wondering is there any function that i can use to return a json ( so I don’t need to change the return type ) ?


BTW just thinking maybe there is an extension done and not need to spend time for it .

PS : i've attached my code here : https://ibb.co/fq69NRB

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

Re: Change return type of payment provider

Post by aimeos » 22 Jun 2021, 07:29

Is the reason you want to return a JSON answer that you are using the JSON REST API for communication between the client and the server?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Kappa.yahyya
Posts: 9
Joined: 14 Jun 2021, 05:59

Re: Change return type of payment provider

Post by Kappa.yahyya » 22 Jun 2021, 10:29

Yes, we use JSON REST API .
ps : because stripe Reactjs library needs a key (secret key) that returns from a request in Backend to stripe api , so i need to receive this key from process method in json method.

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

Re: Change return type of payment provider

Post by aimeos » 28 Jun 2021, 12:52

The best way would be to add this as key/attribute pair to the form object:
https://github.com/aimeos/aimeos-core/b ... d.php#L171

The code in your process() method would be something like this:

Code: Select all

$list = [
	'stripekey' => new \Aimeos\MW\Criteria\Attribute\Standard( [
		'code' => 'stripekey',
		'internalcode' => 'stripekey',
		'label' => 'Striple token',
		'type' => 'string',
		'internaltype' => 'string',
		'default' => '<stripe publisable key>'
	]
] );
return new \Aimeos\MShop\Common\Helper\Form\Standard( $url, 'POST', $list );
Then, it will be available in the "meta" section of the response:
https://github.com/aimeos/ai-client-jso ... #L135-L137
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Kappa.yahyya
Posts: 9
Joined: 14 Jun 2021, 05:59

Re: Change return type of payment provider

Post by Kappa.yahyya » 13 Jul 2021, 14:40

thanks for the solution , but look how deep the data goes . is there any better solution?
Capture3.JPG
Capture3.JPG (61.14 KiB) Viewed 2965 times

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

Re: Change return type of payment provider

Post by aimeos » 15 Jul 2021, 09:08

No, because the structure is defined by the jsonapi.org standard.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply