Page 1 of 1

Change return type of payment provider

Posted: 18 Jun 2021, 07:57
by Kappa.yahyya
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

Re: Change return type of payment provider

Posted: 22 Jun 2021, 07:29
by aimeos
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?

Re: Change return type of payment provider

Posted: 22 Jun 2021, 10:29
by Kappa.yahyya
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.

Re: Change return type of payment provider

Posted: 28 Jun 2021, 12:52
by aimeos
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

Re: Change return type of payment provider

Posted: 13 Jul 2021, 14:40
by Kappa.yahyya
thanks for the solution , but look how deep the data goes . is there any better solution?
Capture3.JPG
Capture3.JPG (61.14 KiB) Viewed 7781 times

Re: Change return type of payment provider

Posted: 15 Jul 2021, 09:08
by aimeos
No, because the structure is defined by the jsonapi.org standard.