ewertondaniel / picpay-e-commerce-php-sdk
PicPay E-Commerce PHP SDK:PHP 库为开发者提供了一套简单的绑定,帮助您将巴西的支付应用 PicPay E-Commerce API 集成到网站中,并开始接收支付。
v1.0.7
2022-12-04 19:23 UTC
Requires
- php: >=8.1
- echosistema/simple-http-request: >=1.0.1
- guzzlehttp/guzzle: ^7.0.1
Requires (Dev)
- phpunit/phpunit: ^7.5.20 || ^8.5.8 || ^9.3.7
This package is auto-updated.
Last update: 2024-09-12 20:39:27 UTC
README
💚 PicPay E-Commerce API 集成 🇧🇷
此库为开发者提供了一套简单的绑定,帮助您将 PicPay E-Commerce API 集成到网站中,并开始接收支付。
🛠 要求
php >= 8.1
guzzlehttp/guzzle >= 7.0.1
echosistema/simple-http-request" >= 1.0.1
📢 即将推出适用于 PHP versions < 8.1
的包。
💻 安装
是第一次使用 PicPay?如果您还没有,请在 PicPay Studio 中创建您的 PicPay 账户。
如果尚未安装,请下载 Composer
在项目目录中,通过命令行运行 "composer require ewertondaniel/picpay-e-commerce-php-sdk"
以支持 PHP 8.1
;
这就完成了!PicPay E-Commerce 已成功安装!
🧑💻 示例
👤 创建客户/买家到支付订单
use EwertonDaniel\PicPay\Customer; /** * Brazilian CPF and Phone Number can be only numbers or with default mask; * The email and phone number fields are optional; */ $customer = new Customer(); $customer->setFirstName('Anakin') // REQUIRED; ->setLastName('Skywalker') // REQUIRED; ->setEmail('anakin@jediorder.com')) // Optional; ->setPhoneNumber('11987654321')) // Optional; ->setDocument('963.237.510-62'); // REQUIRED, Has a CPF validation rule;
💲 创建支付订单
use EwertonDaniel\PicPay\PicPay; $payment = new PicPay('x_picpay_token'); $payment->setCustomer([ 'first_name' => 'Din', 'last_name' => 'Djarin', 'document' => '963.237.510-62' ]) // REQUIRED, Array or Customer class; ->setReferenceId('MY-ID-0001') //string, call REQUIRED, If you want an auto reference id, please call empty ex.: setReferenceId(); ->setCallbackUrl('https://my-website.com/notification') // REQUIRED, Where PicPay will return with POST notification; ->setValue(100.00) //float, REQUIRED; ->pay();
💲 创建完整支付订单
use EwertonDaniel\PicPay\PicPay; $payment = new PicPay('x_picpay_token'); $payment->setCustomer([ 'first_name' => 'Din', 'last_name' => 'Djarin', 'document' => '963.237.510-62', // It can just be numbers ex.: '96323751062' 'email'=>'din@mandalorian.com', // Optional 'phone_number'=>'11987654321' // Optional, It can just be masked ex.: '(11) 98765-4321, (11) 8765-4321 etc...' ]) // REQUIRED, Array or Customer class; ->setDebug(false) // Optional, (default:false) If you want to debug the request (default false); ->setReferenceId('MY-ID-0002') //string, call REQUIRED, If no value is entered, Reference ID will be created automatically, ex.: setReferenceId(); ->setCallbackUrl('https://my-website.com/notification') // REQUIRED, Where PicPay will return with POST notification; ->setReturnUrl('https://my-website.com/order/MY-ID-0002') // Optional, (default:null) where customer will be redirected from PicPay Payment Page; ->setExpirationDate('2020-09-20') // Optional, (default:null) Format Y-m-d (yyyy-mm-dd); ->setSoftDescriptor('Skywalker light-saber') // Optional, (default:null) The soft descriptor is the dynamic text used to construct the statement descriptor that appears on a payer's card statement; ->setPurchaseMode('online') // Optional, (default: online, available options [online, in-store]); ->setChannel('channel') // Optional, (default:null) If you have another store, take a look in official documentation; ->setAutoCapture(true) // Optional, (default:true) Key that will define that this charge will be of the late capture type; ->setValue(100.00) //float, REQUIRED ->pay()
ℹ 获取特定订单状态
use EwertonDaniel\PicPay\Order; $order = new Order('x_picpay_token','reference_id'); $response = $order->status(); $status = $response['status'];
请求订单状态时可能的状态响应
- ✔ created: 订单已创建;
- ✔ expired: 付款期限已过或订单已取消;
- ✔ analysis: 已付款且正在反欺诈分析过程中;
- ✔ completed: 已付款且金额可用在您的 PicPay 账户中;
- ✔ refunded: 已付款且已退款;
- ✔ chargeback: 已付款且有追回;
❌ 取消特定订单
use EwertonDaniel\PicPay\Order; $order = new Order('x_picpay_token','reference_id'); $response = $order->cancel(); $status = $response['status'];
可能取消状态响应
- ✔ cancelled: 订单已取消;
- ✔ undefined: 未知状态;