eximiaweb/payment

多网关支付模块,抽象了每个私有API的独特性,通过一个通用接口简化了多个支付网关的实施

v1.0.4 2020-06-17 01:14 UTC

This package is auto-updated.

Last update: 2024-09-17 10:26:22 UTC


README

多网关支付模块,抽象了每个私有API的独特性,通过一个通用接口简化了多个支付网关的实施

支持的支付方式

  • PagSeguro
  • PayPal

使用方式

实现接口

  • 在可支付的产品中实现 \Payment\Generic\ProductInterface 接口
  • 在您的客户类中实现 \Payment\Generic\Payer 接口

支付方式配置

$config = array(
    // PagSeguro
    'pagseguro_email' => 'email_assigned_to_your_account',
    'pagseguro_token' => 'your_app_token',
    'pagseguro_environment' => 'sandbox', // or production


    // Paypal
    'paypal_cancelUrl'  =>  'url_to_redirect_on_cancel_button_clicked',
    'paypal_CliendID' => 'your_client_id',
    'paypal_ClientSecret' => 'your_client_secret',
    'paypal_environment' => 'sandbox', // or production

    // General
    'redirectUrl' => 'url_to_redirect_after_payment',
    'notificationUrl' => 'url_to_notify_payment_status_changes',
    'nome' => 'your_app_name',
    'version' => 'your_app_version',
);

调用支付方法

$paymentfactory = new \Payment\Factory\PaymentFactory($config);
$gateway = $paymentfactory->createPaymentWrapper(\Payment\Adapter\AdapterType::PAYPAL);

// repetir esta linha para todos os produtos
$gateway->addProduct($produto, 'BRL');

// Define o cliente
$gateway->setPayer($cliente);

// Chama o método de pagamento
$paymentUrl = $gateway->pay();

pay() 方法返回的将是用户需要跳转以进行支付的支付URL。