本文整理汇总了PHP中Method::getMethodsIdByRef方法的典型用法代码示例。如果您正苦于以下问题:PHP Method::getMethodsIdByRef方法的具体用法?PHP Method::getMethodsIdByRef怎么用?PHP Method::getMethodsIdByRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Method
的用法示例。
在下文中一共展示了Method::getMethodsIdByRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildPayment
private function buildPayment()
{
// check payment variables. default to cc_debit
if (!isset($this->post['ps'])) {
$this->post['ps'] = null;
}
// removing PS and letting the profile functions figure out the payment system
//$this->post['ps'] = (strlen($this->post['ps'])) ? $this->post['ps'] : 'pn';
$this->post['payment_method'] = strlen($this->post['payment_method']) ? $this->post['payment_method'] : 'cc_debit';
if (!isset($this->payment)) {
$this->payment = new Payment();
}
if (!$this->payment->getPkValue()) {
$this->payment->created = $this->payment->updated = 'NOW():sql';
//date("Y-m-d H:i:s");
$this->payment->customer_id = $this->customer->customer_id;
// Check for 'DRY RUN GATEWAY'
if ($this->campaign->profile_id) {
// grab accepted payment methods based on payment system
$profileMethods = new ProfileMethods('ProfileMethod');
$profileMethods->loadId($this->campaign->profile_id, $this->post['ps']);
if (!$profileMethods->isMethodValid($this->post['payment_method'], $this->post['ps'])) {
//is there only available option? if so, assign id to the value
if (count($profileMethods->records) == 1) {
$this->post['payment_method'] = $profileMethods->records[0]->method_ref;
} else {
// multiple ids available. abort
$this->apiError('invalid payment supplied');
}
}
// set payment method id
$this->payment->method_id = $profileMethods->getMethodId($this->post['payment_method'], $this->post['ps']);
} else {
// DRY RUN GATEWAY - let's setup some values
$mid = Method::getMethodsIdByRef($this->post['payment_method']);
$this->payment->method_id = $mid ? $mid : 1;
}
$this->payment->fillFromMethodArray($this->post);
if (!$this->payment->validateByMethodFields()) {
$errors = $this->payment->errors;
$validationErrors = $errors['validation_errors'];
fb($this->payment->getErrors());
$this->apiError('Invalid Payment Information - ');
}
// Is this a cc_debit order? If so, are there any specific CC methods setup for this campaign? DISABLE FOR CRM Orders
// for example, if the CC is a mastercard and we have a mastercard only gateway, then default to it
if ($this->campaign->profile_id && $this->payment->method_id == 1 && $this->wsType != 'x1') {
// check for other CC methods
$ccMethodId = ProfileGateways::getMethodByCC($this->campaign->profile_id, 'cc_' . PaymentSystem::getCardTypeSimple($this->payment->cc_number), $this->post['ps']);
if ($ccMethodId) {
$this->payment->method_id = $ccMethodId;
}
unset($ccMethodId);
}
// is this a new customer? if not, are there any other payment records for this customer that might be the same?
$payments = new Payments('Payment');
$payments->loadPaymentsByCustomer($this->customer->customer_id);
// existing payment ID flag/PK
$pid = 0;
// check to see if the sent over info is duplicate
if (count($payments->records)) {
$pid = $payments->paymentExists($this->payment);
}
if (!$pid) {
// save new payment record
if (!$this->payment->save()) {
$this->apiError('invalid payment record');
}
} else {
$this->payment->fillFromDbPk($pid);
}
unset($payments);
}
}