GithubHelp home page GithubHelp logo

yii2-alipay's Introduction

The Alipay Composer Package

a Alipay Composer Package

Description

This is for alipay app pay purpose.

Based on Alipay-SDK-PHP-4.9.0

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require davidxu/yii2-alipay "*"

or add

"davidxu/yii2-alipay": "*"

to the require section of your composer.json file.

Usage Example for App Pay Order Generation Request

use davidxu\alipay\Alipay;
use davidxu\alipay\request\AlipayTradeAppPayRequest;

$notifyUrl = 'https://<your_domain>/alipay/notify';

$alipay = new Alipay();

$alipay->gatewayUrl = "https://openapi.alipay.com/gateway.do";
$alipay->appId = "<app_id>";
$alipay->rsaPrivateKey = '<private_key_in_one_line>' ;
$alipay->format = "json";
$alipay->charset = "UTF-8";
$alipay->signType = "RSA2";
$alipay->alipayrsaPublicKey = '<alipay_public_key_NOT_DEVELOPER_PUBLIC_KEY>';

$request = new AlipayTradeAppPayRequest();

$bizcontent = json_encode([
                  'body' => 'Body of test data',
                  'subject' => 'App Pay Test',
                  'out_trade_no' => '2020012511013510000',
                  'timeout_express' => '30m',
                  'total_amount' => '0.01',
                  'product_code' => 'QUICK_MSECURITY_PAY',
              ]);
              
$request->setNotifyUrl($notifyUrl);
$request->setBizContent($bizcontent);

$orderString = $alipay->sdkExecute($request);

// Client side can use this string for orderString directly.
echo $orderString;

Usage Example for App Pay Async Notification


Http Method: POST
Request URL: https://<your_domain>/alipay/notify  <notifyUrl>

use davidxu\alipay\Alipay;

$alipay = new Alipay();
$alipay->alipayrsaPublicKey = <alipay_public_key_NOT_DEVELOPER_PUBLIC_KEY>;

$flag = $alipay->rsaCheckV1($request, null, 'RSA2');

// Other code such as deal with business logic and etc

// Response ali post request
echo 'success';

Contact

If anything please contact at [email protected]

Have fun.

yii2-alipay's People

Contributors

davidxuuts avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.