combodo / combodopayumstripe Goto Github PK
View Code? Open in Web Editor NEWPayum `SCA compatible` Stripe gateway
License: MIT License
Payum `SCA compatible` Stripe gateway
License: MIT License
Hi,
i have to add "description" field in "payment_intent_data" in method obtainSession to $params var, before session creation request.
Is there any way to do this?
Thanks
As I can see in the code you have given directly the 'done' route to stripe; by doing that, once the payment is done, he doesn't go back through your gateway.
Here is the original way :
// src/Action/Api/ObtainTokenAction.php
private function obtainSession(ObtainToken $request, ArrayObject $model): Session
{
Stripe::setApiKey($this->keys->getSecretKey());
$session = Session::create(
[
'success_url' => $request->getToken()->getAfterUrl(),
'cancel_url' => $request->getToken()->getAfterUrl(),
'payment_method_types' => ['card'],
'submit_type' => Session::SUBMIT_TYPE_PAY,
'line_items' => $model['line_items'],
'payment_intent_data' => [
'metadata' => $model['metadata'] ?? ['payment_id' => $model['id']],
],
'client_reference_id' => $request->getToken()->getHash(),
]
);
return $session;
}
By using the $request->getToken()->getTargetUrl()
method you can get the capture url in order to send the user to this route after the payment.
Here is how I propose to do :
// src/Action/Api/ObtainTokenAction.php
private function obtainSession(ObtainToken $request, ArrayObject $model): Session
{
Stripe::setApiKey($this->keys->getSecretKey());
$session = Session::create(
[
'success_url' => $request->getToken()->getTargetUrl() . '?status=success',
'cancel_url' => $request->getToken()->getTargetUrl() . '?status=canceled',
'payment_method_types' => ['card'],
'submit_type' => Session::SUBMIT_TYPE_PAY,
'line_items' => $model['line_items'],
'payment_intent_data' => [
'metadata' => $model['metadata'] ?? ['payment_id' => $model['id']],
],
'client_reference_id' => $request->getToken()->getHash(),
]
);
return $session;
}
// src/Action/CaptureAction.php
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
$getHttpRequest = new GetHttpRequest();
$this->gateway->execute($getHttpRequest);
if ($getHttpRequest->method == 'GET' && isset($getHttpRequest->query['status'])) {
// @TODO Check payment status
return;
}
if ($model['status']) {
return;
}
if ($model['customer']) {
return;
}
$obtainToken = new ObtainToken($request->getToken());
$obtainToken->setModel($model);
$this->gateway->execute($obtainToken);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.