我正在尝试使用 Eloquent 在 Laravel 4.1 中保存 de Payment 详细信息。我试图创建我的模型,如文档 payum 所说,但它对我不起作用。我的代码:
payum/payum-laravel-package/config.php:
<?php
use Payum\Core\Storage\FilesystemStorage;
use Payum\Paypal\ExpressCheckout\Nvp\Api;
use Payum\Paypal\ExpressCheckout\Nvp\PaymentFactory as PaypalPaymentFactory;
$detailsClass = 'Payum\Core\Model\ArrayObject';
$tokenClass = 'Payum\Core\Model\Token';
$paypalPayment = PaypalPaymentFactory::create(new Api(array(
'username' => 'MY_USER_NAME',
'password' => 'MY_PASS',
'signature' => 'MY_SIGN',
'sandbox' => true
)));
return array(
'token_storage' => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $tokenClass, 'hash'),
'payments' => array(
'paypal_es' => $paypalPayment,
),
'storages' => array(
$detailsClass => new FilesystemStorage(__DIR__.'/../../../../storage/payments', $detailsClass),
)
);
控制器/PaypalController.php
<?php
use Payum\Paypal\ExpressCheckout\Nvp\Api;
class PaypalController extends BaseController
{
public function prepareExpressCheckout()
{
$paymentName = 'paypal_es';
$storage = \App::make('payum')->getStorage('Payum\Core\Model\ArrayObject');
/** @var $paymentDetails PaymentDetails */
$paymentDetails = $storage->createModel();
$paymentDetails['PAYMENTREQUEST_0_CURRENCYCODE'] = 'EUR';
$paymentDetails['PAYMENTREQUEST_0_AMT'] = '1.21';
$paymentDetails['NOSHIPPING'] = Api::NOSHIPPING_NOT_DISPLAY_ADDRESS;
$paymentDetails['REQCONFIRMSHIPPING'] = Api::REQCONFIRMSHIPPING_NOT_REQUIRED;
$paymentDetails['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = Api::PAYMENTREQUEST_ITERMCATEGORY_DIGITAL;
$paymentDetails['L_PAYMENTREQUEST_0_AMT0'] = '1.21';
$paymentDetails['L_PAYMENTREQUEST_0_QTY0'] = '1';
$paymentDetails['L_PAYMENTREQUEST_0_NAME0'] = 'Modulo 1';
$paymentDetails['L_PAYMENTREQUEST_0_DESC0'] = 'Descripción Módulo 1';
$storage->updateModel($paymentDetails);
$captureToken = \App::make('payum.security.token_factory')->createCaptureToken($paymentName, $paymentDetails, 'payment_done');
$paymentDetails['RETURNURL'] = $captureToken->getTargetUrl();
$paymentDetails['CANCELURL'] = $captureToken->getTargetUrl();
// $paymentDetails['INVNUM'] = $paymentDetails->getId();
$storage->updateModel($paymentDetails);
return \Redirect::to($captureToken->getTargetUrl());
}
/**
* @return \Payum\Core\Security\GenericTokenFactoryInterface
*/
protected function getTokenFactory()
{
return \App::make('payum.security.token_factory');
}
}
这段代码运行良好,但我想使用 Eloquent 而不是 FilesystemStorage 创建我自己的模型。我已尝试遵循 Payum 文档,但对我不起作用:
<?php
namespace App\Model;
use Payum\Core\Model\ArrayObject;
class PaymentDetails extends ArrayObject
{
protected $id;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
}
和
use Payum\Core\Model\Token;
class PaymentSecurityToken extends Token
{
}
我该怎么做?任何帮助将不胜感激,因为我没有想法。