| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace Webkul\BagistoApi\Models;
- use ApiPlatform\Metadata\ApiProperty;
- use ApiPlatform\Metadata\ApiResource;
- use ApiPlatform\Metadata\GraphQl\Mutation;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Webkul\BagistoApi\Dto\PaymentCallbackInput;
- use Webkul\BagistoApi\State\PaymentCallbackProcessor;
- /**
- * paymentCallbackCreate — Frontend invokes this after the gateway
- * redirect lands back on the storefront. `status` drives the branch:
- *
- * - success: captures the gateway order (PayPal) and, for express
- * flows, fills the order's shipping/billing addresses with the data
- * forwarded from the gateway.
- * - cancel / failure: leaves the order in PENDING so the user can
- * decide to either retry (paymentReplay) or cancel (cancelOrder).
- */
- #[ApiResource(
- routePrefix: '/api/shop',
- shortName: 'PaymentCallback',
- operations: [],
- graphQlOperations: [
- new Mutation(
- name: 'create',
- input: PaymentCallbackInput::class,
- output: self::class,
- processor: PaymentCallbackProcessor::class,
- denormalizationContext: [
- 'allow_extra_attributes' => true,
- 'groups' => ['mutation'],
- ],
- normalizationContext: [
- 'groups' => ['mutation'],
- ],
- description: 'Handle gateway return (success/cancel/failure). Captures the gateway order on success and fills express addresses if forwarded.',
- ),
- ]
- )]
- class PaymentCallback
- {
- #[ApiProperty(identifier: true, readable: true, writable: false)]
- #[Groups(['mutation'])]
- public ?int $id = null;
- #[ApiProperty(readable: true, writable: false)]
- #[Groups(['mutation'])]
- public bool $success = false;
- #[ApiProperty(readable: true, writable: false)]
- #[Groups(['mutation'])]
- public string $message = '';
- #[ApiProperty(readable: true, writable: false)]
- #[Groups(['mutation'])]
- public ?string $orderId = null;
- #[ApiProperty(readable: true, writable: false)]
- #[Groups(['mutation'])]
- public ?string $status = null;
- #[ApiProperty(readable: true, writable: false)]
- #[Groups(['mutation'])]
- public ?string $orderStatus = null;
- #[ApiProperty(readable: true, writable: false)]
- #[Groups(['mutation'])]
- public ?string $gatewayStatus = null;
- }
|