本文整理汇总了PHP中Payment::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Payment::get方法的具体用法?PHP Payment::get怎么用?PHP Payment::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payment
的用法示例。
在下文中一共展示了Payment::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetGet
function testSetGet()
{
$this->CI->load->model('payment');
$payment = new Payment($this->DBI);
$payment->set('method', Payment::DIRECT);
$this->assertEqual($payment->get('method'), Payment::DIRECT, "Test set and get");
$passed = false;
try {
$payment->set('method', 'kooky');
} catch (Exception $error) {
$this->pass('Method set typing secure');
$passed = true;
}
if (!$passed) {
$this->fail("Failed to catch invalid set");
}
$passed = false;
try {
$payment->set('amount', 'not numeric');
} catch (Exception $error) {
$this->pass('Amount set typing secure');
$passed = true;
}
if (!$passed) {
$this->fail("Failed to catch invalid amount set");
}
}
示例2: handleCheckPaymentPending
/**
* Accepts a list of ids in form of comma separated string via GET parameter. If any of these payments is no longer
* pending, this method returns true, false otherwise.
* @param $gridField
* @param \SS_HTTPRequest|null $request
* @return bool
*/
public function handleCheckPaymentPending($gridField, \SS_HTTPRequest $request = null)
{
if (!$request) {
return false;
}
$ids = preg_split('/[^\\d]+/', $request->getVar('ids'));
return \Payment::get()->filter('ID', $ids)->exclude('Status', array('PendingVoid', 'PendingCapture', 'PendingRefund'))->count() > 0;
}
示例3: complete
public function complete()
{
$paymentID = Session::get('PaymentID');
$payment = Payment::get()->byID($paymentID);
if ($payment && !in_array($payment->Status, array($payment::SUCCESS, $payment::PENDING))) {
$payment->updateStatus(new PaymentGateway_Result($payment::FAILURE));
}
return array('Content' => $this->customise(array('Payment' => $payment))->renderWith('PaymentTestPage'));
}
示例4: testNotifyEndpoint
public function testNotifyEndpoint()
{
$this->setMockHttpResponse('PaymentExpress/Mock/PxPayCompletePurchaseSuccess.txt');
//mock the 'result' get variable into the current request
$this->getHttpRequest()->query->replace(array('result' => 'abc123'));
//mimic a redirect or request from offsite gateway
$response = $this->get("paymentendpoint/UNIQUEHASH23q5123tqasdf/notify");
//redirect works
$this->assertNull($response->getHeader('Location'));
$payment = Payment::get()->filter('Identifier', 'UNIQUEHASH23q5123tqasdf')->first();
$this->assertDOSContains(array(array('ClassName' => 'PurchaseRequest'), array('ClassName' => 'PurchaseRedirectResponse'), array('ClassName' => 'CompletePurchaseRequest'), array('ClassName' => 'PurchasedResponse')), $payment->Messages());
}
开发者ID:helpfulrobot,项目名称:silverstripe-silverstripe-omnipay,代码行数:12,代码来源:PaymentGatewayControllerTest.php
示例5: testPaymentIncomplete
public function testPaymentIncomplete()
{
$this->processor->capture($this->data);
//Test redirect to the gateway
$response = Controller::curr()->getResponse();
$gatewayURL = $this->processor->gateway->gatewayURL;
$queryString = http_build_query(array('Amount' => $this->data['Amount'], 'Currency' => $this->data['Currency'], 'ReturnURL' => $this->processor->gateway->returnURL));
$this->assertEquals($response->getHeader('Location'), '/dummy/external/pay?' . $queryString);
//Test payment completion after redirect from gateway
$queryString = http_build_query(array('Status' => 'Incomplete', 'ErrorMessage' => 'Awaiting Payment Confirmation', 'ErrorCode' => '54321'));
Director::test($this->processor->gateway->returnURL . "?{$queryString}");
$payment = $payment = Payment::get()->byID($this->processor->payment->ID);
$this->assertEquals($payment->Status, Payment::INCOMPLETE);
$error = $payment->Errors()->first();
$this->assertEquals($error->ErrorMessage, 'Awaiting Payment Confirmation');
$this->assertEquals($error->ErrorCode, '54321');
}
示例6: complete
public function complete($request)
{
// Reconstruct the payment object
$this->payment = Payment::get()->byID($request->param('OtherID'));
// Save the payer ID for good measure
$this->payment->PayerID = $request->getVar('PayerID');
$this->payment->write();
// Reconstruct the gateway object
$methodName = $request->param('ID');
$this->gateway = PaymentFactory::get_gateway($methodName);
// Confirm the payment
$data = array('PayerID' => $request->getVar('PayerID'), 'Token' => $request->getVar('token'), 'Amount' => $this->payment->Amount->Amount, 'Currency' => $this->payment->Amount->Currency);
$result = $this->gateway->confirm($data);
$this->payment->updateStatus($result);
// Do redirection
$this->doRedirect();
return;
}
示例7: testDelete
public function testDelete()
{
Config::inst()->update('FlatTaxModifier', 'rate', 0.25);
Config::inst()->update('Order', 'modifiers', array('FlatTaxModifier'));
$order = Order::create();
$shirt = $this->objFromFixture("Product", "tshirt");
$mp3player = $this->objFromFixture("Product", "mp3player");
$order->Items()->add($shirt->createItem(3));
$order->Items()->add($mp3player->createItem(1));
$order->write();
$order->calculate();
$statusLogId = OrderStatusLog::create(array('Title' => 'Test status log', 'OrderID' => $order->ID))->write();
$paymentId = Payment::create(array('OrderID' => $order->ID))->init('Manual', 343.75, 'NZD')->write();
$this->assertEquals(4, $order->Items()->Quantity());
$this->assertEquals(1, $order->Modifiers()->count());
$this->assertEquals(1, $order->OrderStatusLogs()->count());
$this->assertEquals(1, $order->Payments()->count());
$itemIds = Product_OrderItem::get()->filter('OrderID', $order->ID)->column('ID');
$modifierIds = OrderModifier::get()->filter('OrderID', $order->ID)->column('ID');
$order->delete();
// Items should no longer be linked to order
$this->assertEquals(0, $order->Items()->count());
$this->assertEquals(0, $order->Modifiers()->count());
$this->assertEquals(0, $order->OrderStatusLogs()->count());
$this->assertEquals(0, $order->Payments()->count());
// Ensure the order items have been deleted!
$this->assertEquals(0, Product_OrderItem::get()->filter('ID', $itemIds)->count());
$this->assertEquals(0, OrderModifier::get()->filter('ID', $modifierIds)->count());
$this->assertEquals(0, OrderStatusLog::get()->filter('ID', $statusLogId)->count());
// Keep the payment… it might be relevant for book keeping
$this->assertEquals(1, Payment::get()->filter('ID', $paymentId)->count());
}
示例8: getGatewayData
/**
* Map shop data to omnipay fields
*
* @param array $customData Usually user submitted data.
*
* @return array
*/
protected function getGatewayData($customData)
{
$shipping = $this->order->getShippingAddress();
$billing = $this->order->getBillingAddress();
$numPayments = Payment::get()->filter(array('OrderID' => $this->order->ID))->count() - 1;
$transactionId = $this->order->Reference . ($numPayments > 0 ? "-{$numPayments}" : '');
return array_merge($customData, array('transactionId' => $transactionId, 'firstName' => $this->order->FirstName, 'lastName' => $this->order->Surname, 'email' => $this->order->Email, 'company' => $this->order->Company, 'billingAddress1' => $billing->Address, 'billingAddress2' => $billing->AddressLine2, 'billingCity' => $billing->City, 'billingPostcode' => $billing->PostalCode, 'billingState' => $billing->State, 'billingCountry' => $billing->Country, 'billingPhone' => $billing->Phone, 'shippingAddress1' => $shipping->Address, 'shippingAddress2' => $shipping->AddressLine2, 'shippingCity' => $shipping->City, 'shippingPostcode' => $shipping->PostalCode, 'shippingState' => $shipping->State, 'shippingCountry' => $shipping->Country, 'shippingPhone' => $shipping->Phone));
}
示例9: getPartialPayments
/**
* Get partial payments that have this payment as initial payment.
* The list will be sorted from newest to oldest
* @return DataList|null
*/
public function getPartialPayments()
{
if (!$this->isInDB()) {
return null;
}
return Payment::get()->filter('InitialPaymentID', $this->ID)->sort(array('Created' => 'DESC', 'ID' => 'DESC'));
}
示例10: delPayment
/**
* deleting a payment
*
* @param unknown $sender
* @param unknown $param
*
* @throws Exception
*/
public function delPayment($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
if (!isset($param->CallbackParameter->paymentId) || !($payment = Payment::get($param->CallbackParameter->paymentId)) instanceof Payment) {
throw new Exception('System Error: invalid payment provided!');
}
if (!isset($param->CallbackParameter->reason) || ($reason = trim($param->CallbackParameter->reason)) === '') {
throw new Exception('The reason for the deletion is needed!');
}
$comments = 'A payment [Value: ' . StringUtilsAbstract::getCurrency($payment->getValue()) . ', Method: ' . $payment->getMethod()->getName() . '] is DELETED: ' . $reason;
$payment->setActive(false)->addComment($comments, Comments::TYPE_ACCOUNTING)->save();
$entityFor = $payment->getOrder() instanceof Order ? $payment->getOrder() : $payment->getCreditNote();
if ($entityFor instanceof Order || $entityFor instanceof CreditNote) {
$entityFor->addComment($comments, Comments::TYPE_ACCOUNTING);
}
$results['item'] = $payment->getJson();
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
$errors[] = $ex->getMessage();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例11: getGatewayData
/**
* Map shop data to omnipay fields
*
* @param array $customData Usually user submitted data.
*
* @return array
*/
protected function getGatewayData($customData)
{
$shipping = $this->order->getShippingAddress();
$billing = $this->order->getBillingAddress();
$numPayments = Payment::get()->where(array('"OrderID" = ?' => $this->order->ID))->count();
$numPayments--;
$transactionId = strtoupper(i18n::get_lang_from_locale(i18n::get_locale())) . $this->order->Reference . ($numPayments > 0 ? '-' . $numPayments : '');
if (Director::isDev()) {
$transactionId .= Member::currentUser() ? '-' . Member::currentUserID() : '';
}
return array_merge($customData, array('transactionId' => $transactionId, 'firstName' => $this->order->FirstName, 'lastName' => $this->order->Surname, 'email' => $this->order->Email, 'company' => $this->order->Company, 'billingAddress1' => $billing->Address, 'billingAddress2' => $billing->AddressLine2, 'billingCity' => $billing->City, 'billingPostcode' => $billing->PostalCode, 'billingState' => $billing->State, 'billingCountry' => $billing->Country, 'billingPhone' => $billing->Phone, 'shippingAddress1' => $shipping->Address, 'shippingAddress2' => $shipping->AddressLine2, 'shippingCity' => $shipping->City, 'shippingPostcode' => $shipping->PostalCode, 'shippingState' => $shipping->State, 'shippingCountry' => $shipping->Country, 'shippingPhone' => $shipping->Phone));
}
示例12: Payment
public function Payment()
{
return Payment::get()->byID($this->PaymentID);
}
开发者ID:helpfulrobot,项目名称:souldigital-silverstripe-userforms-payments,代码行数:4,代码来源:UserDefinedPaymentForm.php
示例13: testNonExistantGateway
public function testNonExistantGateway()
{
//exception when trying to run functions that require a gateway
$payment = $this->payment;
$service = PurchaseService::create($payment->init("PxPayGateway", 100, "NZD"))->setReturnUrl("complete");
$this->setExpectedException("RuntimeException");
try {
$result = $service->purchase();
} catch (RuntimeException $e) {
$this->markTestIncomplete();
$totalNZD = Payment::get()->filter('MoneyCurrency', "NZD")->sum();
$this->assertEquals(27.23, $totalNZD);
$service->purchase();
$service->completePurchase();
//just to assert that exception is thrown
throw $e;
}
}
示例14: cancel
/**
* Process request from the external gateway, this action is usually triggered if the payment was cancelled
* and the user was redirected to the cancelURL.
*
* @param SS_HTTPResponse $request
*/
public function cancel($request)
{
// Reconstruct the payment object
$this->payment = Payment::get()->byID($request->param('OtherID'));
// Reconstruct the gateway object
$methodName = $request->param('ID');
$this->gateway = PaymentFactory::get_gateway($methodName);
// The payment result was a failure
$this->payment->updateStatus(new PaymentGateway_Failure());
// Do redirection
$this->doRedirect();
}
示例15: getPayment
/**
* Get the the payment according to the identifer given in the url
* @return Payament the payment
*/
private function getPayment()
{
return Payment::get()->filter('Identifier', $this->request->param('Identifier'))->filter('Identifier:not', "")->first();
}