123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\service\byte_dance;
- use think\Cache;
- use think\Collection;
- class ByteDancePay implements ByteDanceInterface {
- protected $data=[
- 'out_order_no'=>'',
- 'total_amount'=>'',
- 'subject'=>'',
- 'body'=>'',
- 'valid_time'=>86400,
- 'notify_url'=>'',
- 'thirdparty_id'=>''
- ];
- public function __construct()
- {
- }
- /**
- * @param mixed $order_no
- * @param $amount
- * @param $subject
- * @return ByteDancePay
- */
- public static function setInfo($order_no,$amount,$subject)
- {
- $class=new self;
- $class->data['app_id']=ByteDance::appId();
- $class->data['out_order_no'] = $order_no;
- $class->data['total_amount'] = $amount*100;
- $class->data['subject'] = $subject;
- $class->data['body'] = $subject;
- $class->data['notify_url']=request()->domain().'/index/payment/notify_dy/order_no/'.$order_no;
- return $class;
- }
- /**
- * @param mixed $order_no
- * @param $amount
- * @param $subject
- * @return ByteDancePay
- */
- public static function setInfo2($order_no,$amount,$subject)
- {
- $class=new self;
- $class->data['app_id']=ByteDance::appIdTwo();
- $class->data['out_order_no'] = $order_no;
- $class->data['total_amount'] = $amount*100;
- $class->data['subject'] = $subject;
- $class->data['body'] = $subject;
- $class->data['notify_url']=request()->domain().'/index/payment/notify_dy/order_no/'.$order_no;
- return $class;
- }
- public function get()
- {
- $data=$this->data;
- $data['sign']=ByteDance::sign($data);
- $order=ByteDance::httpPost('https://developer.toutiao.com/api/apps/ecpay/v1/create_order',$data);
- $obj=ByteDanceResult::make();
- foreach ($order as $key=>$item){
- $obj->offsetSet($key,$item);
- }
- return $obj;
- }
- }
- /**
- * @property string $order_id
- * @property string $order_token
- * @property string $url
- */
- class ByteDanceResult extends Collection {}
|