雪跑逃逸 / picpay-php-sdk
PicPay PHP SDK
1.0.0
2024-04-11 01:06 UTC
README
这是一个用于与 PicPay API 交互的 PHP SDK。它允许您轻松创建 HTTP 请求以执行创建支付偏好、查询交易等操作。
安装
您可以通过 Composer 安装此 SDK。运行以下命令
composer require snowrunescape/picpay-php-sdk
使用示例
$picpay = new \PicPay\PicPay("x-picpay-token", "x-seller-token"); $preference = $picpay->create_preference([ "referenceId" => "PICPAY00001REFERENCE", "callbackUrl" => "https://example.com/api/notification", "returnUrl" => "https://example.com/order/success", "items" => [ [ "id" => 1, "quantity" => 1 ] ], "value" => 30.00, "expiresAt" => (new \DateTime("+1 hour"))->format("Y-m-d\TH:i:s.000-04:00"), "buyer" => [ "firstName" => "Bruno", "lastName" => "Caitano", "document" => "123.456.789-10", "email" => "snowrunescape@snowdev.com.br", "phone" => "+55 11 9 9999-9999" ] ]); $url = $preference["response"]["paymentUrl"];
验证支付是否已完成
$picpay = new \PicPay\PicPay("x-picpay-token", "x-seller-token"); $data = json_decode(file_get_contents("php://input"), true); $payment = $picpay->get_preference($data["referenceId"]);
贡献
如果您发现问题或有任何改进建议,请随时提交 issue 或发送 pull request。
许可协议
本项目采用 MIT 许可协议。有关更多详细信息,请参阅 LICENSE 文件。