lpwebit/payment-bundle

此包已被废弃且不再维护。未建议替代包。

Symfony2 用于进行支付的Bundle

安装: 43

依赖者: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 1

公开问题: 0

类型:symfony-bundle

0.2.0 2015-12-30 09:14 UTC

This package is auto-updated.

Last update: 2022-05-25 16:00:46 UTC


README

LpWebPaymentBundle 提供了与 Symfony2 和 Twig 的支付网关的简单集成

Latest Stable Version Total Downloads

安装

步骤 1: 下载 LpWebPaymentBundle

使用 vendors 脚本

将以下行添加到您的 deps 文件中

    [LpWebPaymentBundle]
        git=https://github.com/lpwebit/PaymentBundle.git
        target=/bundles/LpWeb/PaymentBundle

现在,运行 vendors 脚本来下载此包

$ php bin/vendors install

使用子模块

如果您更喜欢使用 git 子模块,请运行以下命令

$ git submodule add git://github.com/lpwebit/PaymentBundle.git vendor/bundles/LpWeb/PaymentBundle
$ git submodule update --init

使用 Composer

将以下内容添加到您的 composer.json 文件的 "require" 部分

    "lpwebit/payment-bundle": "dev-master"

您也可以选择一个版本号(标签、提交等)

并更新您的依赖关系

    php composer.phar update

步骤 2: 配置自动加载器

如果您使用 composer,则可以跳过此步骤。

将其添加到您的 autoload.pp 文件中

<?php
...
'LpWeb' => __DIR__.'/../vendor/bundles',

步骤 3: 启用 Bundle

在您的 app/AppKernel.php 文件中注册此 Bundle

<?php
...
public function registerBundles()
{
    $bundles = array(
        ...
        new LpWeb\PaymentBundle\LpWebPaymentBundle(),
        ...
    );
...

步骤 4: 配置 Bundle 并设置目录

将以下配置添加到您的 app/config/config.yml 文件中

- { resource: @LpWebPaymentBundle/Resources/config/config.yml }

lp_web_payment: ~

如果您想使用 PayPal 作为您的支付网关,您必须配置 CLIENT_ID 和 CLIENT_SECRET,请参阅 PayPal 文档以生成这些值

lp_web_payment:
    paypal:
        client_id: YOUR_KEY
        client_secret: YOUR_SECRET

完整配置

lp_web_payment:
    paypal: # for information on mode and loggingLevel please refer to https://github.com/paypal/PayPal-PHP-SDK/wiki/Logging
        client_id: YOUR_KEY
        client_secret: YOUR_SECRET
        mode: sandbox|live
        logLevel: DEBUG|INFO|WARN|ERROR

步骤 5: 添加路由

将以下内容添加到您的 app/config/routing.yml 文件中

lp_web_payment:
    resource: "@LpWebPaymentBundle/Controller/"
    type:     annotation
    prefix:   /

导出所有资产

php app/console assets:install

用法

基础

要使用 WPS 进行支付请求,您只需设置一些信息,然后重定向用户到生成的批准 URL

<?php
...
/** @var PayPalWPS $wpsService */
$wpsService = $this->get('lpweb_payment.paypal.wps');
$wpsService->setAmout(10.0);
$wpsService->setDescription('Transaction Description');
$wpsService->setInvoiceNumber(1);
// set the redirect url to which the user has to be redirected after successfull completion
$wpsService->setRedirectUrl($this->generateUrl('route_name'));

// invoice number, amount and description is compulsory
$wpsService->validateData();

// Specify the checkout experience to present to the user.
$data['cmd'] = '_cart';

// Signify we're passing in a shopping cart from our system.
$data['upload'] = '1';

// The store's PayPal e-mail address
$data['business'] = $wpsService->getBusinessMail();

// The application generating the API request
$data['bn'] = 'LpWebPayment_Bundle_WPS';

// Set the correct character set
$data['charset'] = 'utf-8';

// Do not display a comments prompt at PayPal
$data['no_note'] = '1';

// Do not display a shipping address prompt at PayPal
$data['no_shipping'] = '1';

 // Return to the review page when payment is canceled
$data['cancel_return'] = $wpsService->getCancelUrl($wpsService::paymentMethod);

// Return to the payment redirect page for processing successful payments
$data['return'] = $wpsService->getSuccessUrl($wpsService::paymentMethod);

// The path PayPal should send the IPN to
$data['notify_url'] = $wpsService->getNotifyUrl($wpsService::paymentMethod);

$data['rm'] = '2';

// The type of payment action PayPal should take with this order
$data['paymentaction'] = $wpsService::ACTION;

// Set the currency and language codes
$data['currency_code'] = 'AUD';
$data['lc'] = 'EN';

// Use the timestamp to generate a unique invoice number
$data['invoice'] = $wpsService->getInvoiceNumber();

// Define a single item in the cart representing the whole order
$data['amount_1'] = $wpsService->getAmount()->getTotal();
$data['item_name_1'] = $wpsService->getDescription();

$paypalRequest = new PayPalRequest();
$paypalRequest->setUniqueId($wpsService->getUniqueId());
$paypalRequest->setCmd($data['cmd']);
$paypalRequest->setUpload($data['upload']);
$paypalRequest->setBusiness($data['business']);
$paypalRequest->setBn($data['bn']);
$paypalRequest->setCharset($data['charset']);
$paypalRequest->setNoNote($data['no_note']);
$paypalRequest->setNoShipping($data['no_shipping']);
$paypalRequest->setCancelReturn($data['cancel_return']);
$paypalRequest->setReturnUrl($data['return_url']);
$paypalRequest->setNotifyUrl($data['notify_url']);
$paypalRequest->setRm($data['rm']);
$paypalRequest->setPaymentaction($data['paymentaction']);
$paypalRequest->setCurrencyCode($data['currency_code']);
$paypalRequest->setLc($data['lc']);
$paypalRequest->setInvoice($data['invoice']);
$paypalRequest->setAmount1($data['amount_1']);
$paypalRequest->setItemName1($data['item_name_1']);

$em = $this->container->get('doctrine')->getManager();
$em->persist($paypalRequest);
$em->flush();

return $this->render('LpWebPaymentBundle:Payment:process.html.twig', ['data' => $data]);

要求

LpWebPaymentBundle 无其他要求

支持

如果您想了解发布公告,讨论项目的想法或提出更详细的问题,还有一个您可以订阅的 邮件列表

如果您认为您发现了一个错误,请使用 GitHub 问题跟踪器 进行报告,或者更好的是,分叉库并提交一个拉取请求。

许可证

此软件包采用MIT许可证