-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SetupIntent without charging an amount #8
Comments
Hi @zspine, For The array to build will required this kind of data : // @see https://github.com/FLUX-SE/PayumStripe/blob/master/src/Action/ConvertPaymentAction.php#L24-L37
// ^-- Replace those lines with the code bellow
$details = [
'payment_method_types' => ['card'],
'mode' => 'setup',
// even if this field is empty, it's required by this lib but not by Stripe
// @see https://github.com/FLUX-SE/PayumStripe/blob/master/src/Action/CaptureAction.php#L107-L109
'setup_intent_data' => [],
];
$request->setResult($details); For I don't test it but you could create a JsCaptureSetupIntentAction base on <?php
declare(strict_types=1);
namespace FluxSE\PayumStripe\Action;
use FluxSE\PayumStripe\Request\Api\Pay;
use LogicException;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Request\Capture;
use Payum\Core\Security\TokenInterface;
use Stripe\ApiResource;
use Stripe\SetupIntent;
class JsCaptureSetupIntentAction extends CaptureAction
{
protected function createCaptureResource(ArrayObject $model, Capture $request): ApiResource
{
// This class CreateSetupIntent should be created by you, it will be the same class as :
// @see \FluxSE\PayumStripe\Request\Api\Resource\CreatePaymentIntent
// /!\ The related action have to be also created :
// @see \FluxSE\PayumStripe\Action\Api\Resource\CreatePaymentIntentAction
$createSetupIntent = new CreateSetupIntent($model->getArrayCopy());
$this->gateway->execute($createSetupIntent);
return $createSetupIntent->getApiResource();
}
protected function renderCapture(ApiResource $captureResource, Capture $request): void
{
if (false === $captureResource instanceof SetupIntent) {
throw new LogicException(sprintf('The $captureResource should be a "%s" !', SetupIntent::class));
}
$token = $this->getRequestToken($request);
$actionUrl = $token->getTargetUrl();
$pay = new Pay($captureResource, $actionUrl);
$this->gateway->execute($pay);
}
public function embedOnModeData(ArrayObject $model, TokenInterface $token, string $modeDataKey): void
{
// not need for this on Stripe JS
}
} You will also have to make your own After this action the Finally PS: Because the |
@Prometee Hi Thank you very much taking the time to explain this in detail. Now I understand how the whole thing works. Amazing!!! I have spent several hours digging the source code to have an understanding of the whole functionality and flow. Thanks again for this awesome library and symfony bundle, it saves lots of time and hassle. |
I know Payum is not easy too at first sight... @zspine Thank you very much for your support ! Don't forget to get back to me if you succeed, it would be very interesting to add setup intent capabilities to the |
PS: I edited my first comment (small corrections and add) |
@Prometee Definitely, I will give it a try and will share the final code if it's successful. |
Hi @zspine ! With @syjust we succeeded making a
If you have an other behaviour, you can share it with us, it will help making a generic gateway 😉 |
Hi @Prometee Perfect timing :) almost like miracle! Thanks a million for the update! I was on leave for 2 months due to some personal issues. I just started to work and was referring through the code base to refresh the memories. Definitely will try it this week and will give you an update! Thank you @syjust |
Hi @zspine, I wanted to give you some update on the evolution of this library, I added I know this isn't exactly what you needed, but now you can easily add a new I will let this issue opened because |
Hi!
I am using this library (stripe_js) in a production setup and am in the process of migrating all the payments to SCA ready.
I am trying to use the Create Setup Intent API to save a card before charge the customer. But I couldn't find any examples or documentation to understand the implementation steps.
Any suggestions greatly appreciated, Thank you
The text was updated successfully, but these errors were encountered: