Last active
June 26, 2019 14:10
-
-
Save teohhanhui/1c2ac1d27f948993bf8c4209a8808f39 to your computer and use it in GitHub Desktop.
Using Omnipay with Sylius (example using Stripe)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
"require": { | |
... | |
"omnipay/common": "^3.0@beta", | |
"omnipay/stripe": "^3.0@dev", | |
"payum/omnipay-v3-bridge": "^1.0", | |
... | |
}, | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app: | |
form: | |
gateway_configuration: | |
omnipay_stripe: | |
api_key: API key | |
payum_gateway_factory: | |
omnipay_stripe: Stripe (via Omnipay) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace AppBundle\Form\Type; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | |
use Symfony\Component\Form\Extension\Core\Type\TextType; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Symfony\Component\Validator\Constraints\NotBlank; | |
final class OmnipayStripeGatewayConfigurationType extends AbstractType | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function buildForm(FormBuilderInterface $builder, array $options): void | |
{ | |
parent::buildForm($builder, $options); | |
$builder | |
->add('apiKey', TextType::class, [ | |
'label' => 'app.form.gateway_configuration.omnipay_stripe.api_key', | |
'constraints' => [ | |
new NotBlank([ | |
'message' => 'app.gateway_config.omnipay_stripe.api_key.not_blank', | |
'groups' => 'sylius', | |
]), | |
], | |
]) | |
->add('type', HiddenType::class, [ | |
'data' => 'Stripe', | |
]) | |
; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
AppBundle\Form\Type\OmnipayStripeGatewayConfigurationType: | |
tags: | |
- name: sylius.gateway_configuration_type | |
type: omnipay | |
label: app.payum_gateway_factory.omnipay_stripe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app: | |
gateway_config: | |
omnipay_stripe: | |
api_key: | |
not_blank: Please enter Stripe API key. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment