johnkhansrc/iaphub-bundle
Composer 安装命令:
composer require johnkhansrc/iaphub-bundle
包简介
An Iaphub integration for symfony application for receive webhooks and manage Iaphub API
README 文档
README
A project initiated by EmprunteMonToutou
An Iaphub integration for symfony application for receive webhooks and manage Iaphub API
Work in progress
Installation
Use Composer to install this bundle:
composer require johnkhansrc/iaphub-bundle
Add the bundle in your application kernel:
// app/AppKernel.php public function registerBundles() { return [ // ... Johnkhansrc\IaphubBundle\IaphubBundle::class => ['dev' => true], // ... ]; }
Add service configuration file
# config/packages/johnkhansrc_iaphub_bundle.yaml johnkhansrc_iaphub: apikey: 'your-iaphub-api-key' webhook_auth_token: 'your-iaphub-webhook-auth-token'
Define your webhook URL
# config/routes/johnkhansrc_iaphub_bundle.yaml _iaphub_bundle: resource: '@IaphubBundle/Ressources/config/routes.xml' prefix: '/iaphub/webhook_entrypoint'
Usage
Webhooks
All webhook emit symfony event
Go webhooks documentation and design your market strategies.
| Webhook | Event alias | Event class |
|---|---|---|
| Purchase | iaphub.webhook.purchase | IaphubPurchaseEvent |
| Refund | iaphub.webhook.refund | IaphubRefundEvent |
| User id update | iaphub.webhook.user_id_update | IaphubUserIdUpdateEvent |
| Subscription renewal | iaphub.webhook.subscription_renewal | IaphubSubscriptionRenewalEvent |
| Subscription renewal retry | iaphub.webhook.subscription_renewal_retry | IaphubSubscriptionRenewalRetryEvent |
| Subscription grace period expire | iaphub.webhook.subscription_grace_period_expire | IaphubSubscriptionGracePeriodExpireEvent |
| Subscription product change | iaphub.webhook.subscription_product_change | IaphubSubscriptionProductChangeEvent |
| Subscription replace | iaphub.webhook.subscription_replace | IaphubSubscriptionReplaceEvent |
| Subscription cancel | iaphub.webhook.subscription_cancel | IaphubSubscriptionCancelEvent |
| Subscription uncancel | iaphub.webhook.subscription_uncancel | IaphubSubscriptionUnCancelEvent |
| Subscription expire | iaphub.webhook.subscription_expire | IaphubSubscriptionExpireEvent |
| Subscription pause | iaphub.webhook.subscription_pause | IaphubSubscriptionPauseEvent |
| Subscription pause enabled | iaphub.webhook.subscription_pause_enabled | IaphubSubscriptionPauseEnabledEvent |
| Subscription pause disabled | iaphub.webhook.subscription_pause_disabled | IaphubSubscriptionPauseDisabledEvent |
eq (for an EventSubscriberInterface)
public static function getSubscribedEvents(): array { return [ IaphubPurchaseEvent::NAME => ['onIaphubPurchaseEvent', 1], IaphubRefundEvent::NAME => ['onIaphubRefundEvent', 1], IaphubUserIdUpdateEvent::NAME => ['onIaphubUserIdUpdateEvent', 1], IaphubSubscriptionRenewalEvent::NAME => ['onIaphubSubscriptionRenewalEvent', 1], IaphubSubscriptionRenewalRetryEvent::NAME => ['onIaphubSubscriptionRenewalRetryEvent', 1], IaphubSubscriptionGracePeriodExpireEvent::NAME => ['onIaphubSubscriptionGracePeriodExpireEvent', 1], IaphubSubscriptionProductChangeEvent::NAME => ['onIaphubSubscriptionProductChangeEvent', 1], IaphubSubscriptionReplaceEvent::NAME => ['onIaphubSubscriptionReplaceEvent', 1], IaphubSubscriptionCancelEvent::NAME => ['onIaphubSubscriptionCancelEvent', 1], IaphubSubscriptionUnCancelEvent::NAME => ['onIaphubSubscriptionUnCancelEvent', 1], IaphubSubscriptionExpireEvent::NAME => ['onIaphubSubscriptionExpireEvent', 1], IaphubSubscriptionPauseEvent::NAME => ['onIaphubSubscriptionPauseEvent', 1], IaphubSubscriptionPauseEnabledEvent::NAME => ['onIaphubSubscriptionPauseEnabledEvent', 1], IaphubSubscriptionPauseDisabledEvent::NAME => ['onIaphubSubscriptionPauseDisabledEvent', 1], ]; }
Iaphub API
All API method is provided from the Johnkhansrc\IaphubBundle\Iaphub public service.
Get the client
eq
public function __construct(Iaphub $iaphub) { $client = $iaphub->apiClient(); $purchaseId = 'XXXX'; $appId = 'ZZZZ'; $client->getSubscription($purchaseId, $appId); }
Methods
/** * https://www.iaphub.com/docs/api/get-user * @throws IaphubApiResponseException * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws Exception */ public function getUser(string $userId, string $appId, ?array $queryParameters = null): GetUserApiResponse /** * https://www.iaphub.com/docs/api/get-user-migrate * @throws IaphubApiResponseException * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface|IaphubBundleBadQueryStringException */ public function getUserMigrate(string $userId, string $appId, ?array $queryParameters = null): string /** * https://www.iaphub.com/docs/api/post-user * @throws TransportExceptionInterface * @throws IaphubBundleBadQueryStringException */ public function postUser(string $userId, array $payloadData, string $appId): void /** * https://www.iaphub.com/docs/api/post-user-receipt * @throws TransportExceptionInterface * @throws IaphubBundleBadQueryStringException * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ public function postUserReceipt(string $userId, array $payloadData, string $appId): PostUserReceiptResponse /** * https://www.iaphub.com/docs/api/get-purchase * @throws IaphubApiResponseException * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws IaphubBundleBadQueryStringException */ public function getPurchase(string $purchaseId, string $appId, ?array $queryParameters = null): Purchase /** * https://www.iaphub.com/docs/api/get-purchases * @throws IaphubApiResponseException * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface|IaphubBundleBadQueryStringException */ public function getPurchases(string $appId, ?array $queryParameters = null): GetPurchases /** * https://www.iaphub.com/docs/api/get-subscription * @throws IaphubApiResponseException * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface|IaphubBundleBadQueryStringException * @throws Exception */ public function getSubscription(string $originalPurchaseId, string $appId, ?array $queryParameters = null): Purchase /** * https://www.iaphub.com/docs/api/get-receipt * @throws IaphubApiResponseException * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws Exception */ public function getReceipt(string $receiptId, string $appId, ?array $queryParameters = null): Receipt
johnkhansrc/iaphub-bundle 适用场景与选型建议
johnkhansrc/iaphub-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 949 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 johnkhansrc/iaphub-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 johnkhansrc/iaphub-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 949
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-03