Change return type of payment provider
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 11
- Joined: 14 Jun 2021, 05:59
Change return type of payment provider
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
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
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, give us a star
If you like Aimeos, give us a star
-
- Posts: 11
- Joined: 14 Jun 2021, 05:59
Re: Change return type of payment provider
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.
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
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:
Then, it will be available in the "meta" section of the response:
https://github.com/aimeos/ai-client-jso ... #L135-L137
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 );
https://github.com/aimeos/ai-client-jso ... #L135-L137
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 11
- Joined: 14 Jun 2021, 05:59
Re: Change return type of payment provider
thanks for the solution , but look how deep the data goes . is there any better solution?
Re: Change return type of payment provider
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, give us a star
If you like Aimeos, give us a star