Giter Club home page Giter Club logo

bytedance's Introduction

Bytedance 字节跳动接口

说明

大部分代码是引用了cvoid/bytedance-mini-app这位兄弟的包,有些接口不支持(例如分账),所以用了这位兄弟的包 做扩展,如有侵权,立马下架。

安装(Installation)

composer require zgclives/bytedance

功能(Features)

api 实现 是否完成
getAccessToken login->getAccessToken() ☑️
登录 - code2Session login->code2Session() ☑️
数据缓存 - setUserStorage
数据缓存 - removeUserStorage
创建二维码 - createQRCode tool->createQRCode ☑️
内容安全检测
图片检测 V2
订阅消息推送 tool->sendSubscribedMessage ☑️
服务端预下单 payment->createOrder ☑️
服务端支付回调 payment->notify ☑️
订单查询 payment->queryOrder ☑️
退款 payment->createRefund ☑️
退款回调 payment->refundNotify ☑️
查询退款 payment->queryRefund ☑️
分账 payment->createSettle ☑️
分账回调 payment->settleNotify ☑️
查询分账 payment->querySettle ☑️
服务商进件
分账方进件

使用(Usage)

getApp

require_once __DIR__.'./vendor/autoload.php';

use \Bytedance\BytedanceApp;

$app = new \Bytedance\BytedanceApp('appId', 'secret', 'salt', 'token');

获取 AccessToken

$response = $app->login->accessToken();

$access_token = $response->accessToken;
$expires_in = $response->expiresIn;

登录

$response = $app->login->code2Session($code);

return [
    'session_key' => $response->sessionKey,
    'openid'      => $response->openId,
    'unionid'     => $response->unionId,
];

创建二维码

$access_token = $app->login->accessToken()->accessToken;
return $app->tool->createQRCode($access_token, $app->tool::APP_DOUYIN, 'pages/index/index');

订阅消息推送

$access_token = $app->login->accessToken()->accessToken;
return $app->tool->sendSubscribedMessage($access_token, $tpl_id, $open_id, $data, 'pages/index/index');

服务端预下单

$response = $app->payment->createOrder($out_order_no, $total_amount, $subject, $body, $valid_time, $cp_extra, $notify_url);

return [
    'order_id'    => $response->orderId,
    'order_token' => $response->orderToken
];

订单查询

$response = $app->payment->queryOrder($out_order_no);

return $response;
//[totalFee] => 2
//[orderStatus] => SUCCESS
//[payTime] => 2021-08-26 17:38:49
//[way] => 1
//[channelNo] => 4321001296202108269673188430
//[channelGatewayNo] => 12108260167652952855

退款

$response = $app->payment->createOrder($out_order_no, $total_amount, $subject, $body, $valid_time, $cp_extra, $notify_url);

return [
    'order_id'    => $response->orderId,
    'order_token' => $response->orderToken
];

分账

$response = $app->payment->createSettle($out_settle_no, $out_order_no, $settle_desc, $settle_params, $cp_extra, $notify_url);

return [
    'settle_no'     => $response->settleNo
];

分账查询

$response = $app->payment->querySettle($out_order_no);

return [
    'settle_no'     => $response->settleNo,
    'settle_status' => $response->settleStatus,
    'settle_amount' => $response->settleAmount,
    'settle_detail' => $response->settleDetail,
    'settled_at'    => $response->settleAt,
    'rake'          => $response->rake,
    'commission'    => $response->commission,
    'cp_extra'      => $response->cpExtra,
];

bytedance's People

Contributors

zgclives avatar id0612 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.