hypejunction / hypestripepayments
此软件包已被废弃且不再维护。未建议替代软件包。
Stripe 客户端用于 Elgg
1.3.1
2018-11-12 10:31 UTC
Requires
- php: >=7.0
- composer/installers: ~1.0
- stripe/stripe-php: ^6.4
README
Stripe PHP SDK 的包装器
Webhooks
配置您的 Stripe 应用程序,将 webhook 发送到 https://<your-elgg-site>/payments/stripe/webhooks
要解析 webhook,请注册插件钩子处理程序
elgg_register_plugin_hook_handler('customer.subscription.deleted', 'stripe', HandleExpiredSubscription::class); class HandleExpiredSubscription { public function __invoke(\Elgg\Hook $hook) { $stripe_event = $hook->getParam('event'); /* @var $stripe_event \Stripe\Event */ $subscription = $stripe_event->data->object; // ... do stuff return $result; // Result will be reported back to stripe } }
卡输入
要显示卡输入
// Card number, expiry and CVC echo elgg_view_field([ '#type' => 'stripe/card', '#label' => 'Credit or Debit Card', 'required' => true, ]); // Cardholder name echo elgg_view_field([ '#type' => 'stripe/cardholder', '#label' => 'Cardholder', 'required' => true, ]); // Billing address // Requires hypeCountries plugin echo elgg_view_field([ '#type' => 'stripe/address', '#label' => 'Billing address', 'required' => true, ]);
然后您可以在操作中检索 Stripe 令牌的值
$payment_method = get_input('payment_method'); list($gateway, $source_id) = explode('::', $payment_method); if ($gateway == 'stripe' && $source_id) { // Use $source_id to create a charge } else { $token = get_input('stripe_token'); $address = get_input('address'); $name = get_input('cardholder'); // Use stripe API to create a new card object // or use the token as the source of the payment }