How to get the payment methods in magento 2.
All 3 types:
1) All Payment Methods
2) Active/Enabled Payment Methods
3) Payment Methods that have been used while placing orders
Using Dependency Injection (DI)
Here is the code that you need to write in your Block class.
/**
* Order Payment
*
* #var \Magento\Sales\Model\ResourceModel\Order\Payment\Collection
*/
protected $_orderPayment;
/**
* Payment Helper Data
*
* #var \Magento\Payment\Helper\Data
*/
protected $_paymentHelper;
/**
* Payment Model Config
*
* #var \Magento\Payment\Model\Config
*/
protected $_paymentConfig;
/**
* #param \Magento\Backend\Block\Template\Context $context
* #param \Magento\Sales\Model\ResourceModel\Order\Payment\Collection $orderPayment
* #param \Magento\Payment\Helper\Data $paymentHelper
* #param \Magento\Payment\Model\Config $paymentConfig
* #param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Sales\Model\ResourceModel\Order\Payment\Collection $orderPayment,
\Magento\Payment\Helper\Data $paymentHelper,
\Magento\Payment\Model\Config $paymentConfig,
array $data = []
) {
$this->_orderPayment = $orderPayment;
$this->_paymentHelper = $paymentHelper;
$this->_paymentConfig = $paymentConfig;
parent::__construct($context, $data);
}
/**
* Get all payment methods
*
* #return array
*/
public function getAllPaymentMethods()
{
return $this->_paymentHelper->getPaymentMethods();
}
/**
* Get key-value pair of all payment methods
* key = method code & value = method name
*
* #return array
*/
public function getAllPaymentMethodsList()
{
return $this->_paymentHelper->getPaymentMethodList();
}
/**
* Get active/enabled payment methods
*
* #return array
*/
public function getActivePaymentMethods()
{
return $this->_paymentConfig->getActiveMethods();
}
/**
* Get payment methods that have been used for orders
*
* #return array
*/
public function getUsedPaymentMethods()
{
$collection = $this->_orderPayment;
$collection->getSelect()->group('method');
$paymentMethods[] = array('value' => '', 'label' => 'Any');
foreach ($collection as $col) {
$paymentMethods[] = array('value' => $col->getMethod(), 'label' => $col->getAdditionalInformation()['method_title']);
}
return $paymentMethods;
}
Using Object Manager
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$paymentHelper = $objectManager->get('Magento\Payment\Helper\Data');
$allPaymentMethods = $paymentHelper->getPaymentMethods();
$allPaymentMethodsArray = $paymentHelper->getPaymentMethodList();
var_dump($allPaymentMethodsArray);
var_dump($allPaymentMethods);
$paymentConfig = $objectManager->get('Magento\Payment\Model\Config');
$activePaymentMethods = $paymentConfig->getActiveMethods();
var_dump(array_keys($activePaymentMethods));
$orderPaymentCollection = $objectManager->get('\Magento\Sales\Model\ResourceModel\Order\Payment\Collection');
$orderPaymentCollection->getSelect()->group('method');
$paymentMethods[] = array('value' => '', 'label' => 'Any');
foreach ($orderPaymentCollection as $col) {
$paymentMethods[] = array('value' => $col->getMethod(), 'label' => $col->getAdditionalInformation()['method_title']);
}
var_dump($paymentMethods);
Sample Output of getUsedPaymentMethods():
Array
(
[0] => Array
(
[value] =>
[label] => Any
)
[1] => Array
(
[value] => cashondelivery
[label] => Cash On Delivery
)
[2] => Array
(
[value] => checkmo
[label] => Check / Money order
)
)
Sample Output of getAllPaymentMethodsList():
Array
(
[vault] =>
[substitution] =>
[banktransfer] => Bank Transfer Payment
[cashondelivery] => Cash On Delivery
[checkmo] => Check / Money order
[payflowpro] => Credit Card
[payflow_link] => Credit Card
[payflow_advanced] => Credit Card
[braintree] => Credit Card (Braintree)
[authorizenet_directpost] => Credit Card Direct Post (Authorize.net)
[free] => No Payment Information Required
[braintree_paypal] => PayPal (Braintree)
[paypal_billing_agreement] => PayPal Billing Agreement
[payflow_express_bml] => PayPal Credit
[paypal_express_bml] => PayPal Credit
[paypal_express] => PayPal Express Checkout
[payflow_express] => PayPal Express Checkout Payflow Edition
[hosted_pro] => Payment by cards or by PayPal account
[purchaseorder] => Purchase Order
[braintree_cc_vault] => Stored Cards (Braintree)
[payflowpro_cc_vault] => Stored Cards (Payflow Pro)
)
Sample Output of getAllPaymentMethods():
Array
(
[free] => Array
(
[active] => 1
[model] => Magento\Payment\Model\Method\Free
[order_status] => pending
[title] => No Payment Information Required
[allowspecific] => 0
[sort_order] => 1
[group] => offline
)
[substitution] => Array
(
[active] => 0
[model] => Magento\Payment\Model\Method\Substitution
[allowspecific] => 0
)
[vault] => Array
(
[debug] => 1
[model] => Magento\Vault\Model\VaultPaymentInterface
)
[checkmo] => Array
(
[active] => 1
[model] => Magento\OfflinePayments\Model\Checkmo
[order_status] => pending
[title] => Check / Money order
[allowspecific] => 0
[group] => offline
)
[purchaseorder] => Array
(
[active] => 0
[model] => Magento\OfflinePayments\Model\Purchaseorder
[order_status] => pending
[title] => Purchase Order
[allowspecific] => 0
[group] => offline
)
[banktransfer] => Array
(
[active] => 0
[model] => Magento\OfflinePayments\Model\Banktransfer
[order_status] => pending
[title] => Bank Transfer Payment
[allowspecific] => 0
[group] => offline
)
[cashondelivery] => Array
(
[active] => 0
[model] => Magento\OfflinePayments\Model\Cashondelivery
[order_status] => pending
[title] => Cash On Delivery
[allowspecific] => 0
[group] => offline
)
[paypal_express] => Array
(
[model] => Magento\Paypal\Model\Express
[title] => PayPal Express Checkout
[payment_action] => Authorization
[solution_type] => Mark
[line_items_enabled] => 1
[visible_on_cart] => 1
[visible_on_product] => 1
[allow_ba_signup] => never
[group] => paypal
[authorization_honor_period] => 3
[order_valid_period] => 29
[child_authorization_number] => 1
[verify_peer] => 1
[skip_order_review_step] => 1
)
[paypal_express_bml] => Array
(
[model] => Magento\Paypal\Model\Bml
[title] => PayPal Credit
[group] => paypal
)
[payflow_express] => Array
(
[title] => PayPal Express Checkout Payflow Edition
[payment_action] => Authorization
[line_items_enabled] => 1
[visible_on_cart] => 1
[visible_on_product] => 1
[group] => paypal
[verify_peer] => 1
[model] => Magento\Paypal\Model\PayflowExpress
)
[payflow_express_bml] => Array
(
[model] => Magento\Paypal\Model\Payflow\Bml
[title] => PayPal Credit
[group] => paypal
)
[payflowpro] => Array
(
[model] => Magento\Paypal\Model\Payflow\Transparent
[title] => Credit Card
[payment_action] => Authorization
[cctypes] => AE,VI
[useccv] => 1
[tender] => C
[verbosity] => MEDIUM
[user] =>
[pwd] =>
[group] => paypal
[verify_peer] => 1
[date_delim] =>
[ccfields] => csc,expdate,acct
[place_order_url] => paypal/transparent/requestSecureToken
[cgi_url_test_mode] => https://pilot-payflowlink.paypal.com
[cgi_url] => https://payflowlink.paypal.com
[transaction_url_test_mode] => https://pilot-payflowpro.paypal.com
[transaction_url] => https://payflowpro.paypal.com
[avs_street] => 0
[avs_zip] => 0
[avs_international] => 0
[avs_security_code] => 1
[cc_year_length] => 2
[can_authorize_vault] => 1
[can_capture_vault] => 1
)
[payflowpro_cc_vault] => Array
(
[model] => PayflowProCreditCardVaultFacade
[title] => Stored Cards (Payflow Pro)
)
[paypal_billing_agreement] => Array
(
[active] => 1
[allow_billing_agreement_wizard] => 1
[model] => Magento\Paypal\Model\Method\Agreement
[title] => PayPal Billing Agreement
[group] => paypal
[verify_peer] => 1
)
[payflow_link] => Array
(
[model] => Magento\Paypal\Model\Payflowlink
[payment_action] => Authorization
[verbosity] => HIGH
[user] =>
[pwd] =>
[group] => paypal
[title] => Credit Card
[partner] => PayPal
[csc_required] => 1
[csc_editable] => 1
[url_method] => GET
[email_confirmation] => 0
[verify_peer] => 1
[transaction_url_test_mode] => https://pilot-payflowpro.paypal.com
[transaction_url] => https://payflowpro.paypal.com
[cgi_url_test_mode] => https://pilot-payflowlink.paypal.com
[cgi_url] => https://payflowlink.paypal.com
)
[payflow_advanced] => Array
(
[model] => Magento\Paypal\Model\Payflowadvanced
[payment_action] => Authorization
[verbosity] => HIGH
[user] => PayPal
[pwd] =>
[group] => paypal
[title] => Credit Card
[partner] => PayPal
[vendor] => PayPal
[csc_required] => 1
[csc_editable] => 1
[url_method] => GET
[email_confirmation] => 0
[verify_peer] => 1
[transaction_url_test_mode] => https://pilot-payflowpro.paypal.com
[transaction_url] => https://payflowpro.paypal.com
[cgi_url_test_mode] => https://pilot-payflowlink.paypal.com
[cgi_url] => https://payflowlink.paypal.com
)
[hosted_pro] => Array
(
[model] => Magento\Paypal\Model\Hostedpro
[title] => Payment by cards or by PayPal account
[payment_action] => Authorization
[group] => paypal
[display_ec] => 0
[verify_peer] => 1
)
[authorizenet_directpost] => Array
(
[active] => 0
[cctypes] => AE,VI,MC,DI
[debug] => 0
[email_customer] => 0
[login] =>
[merchant_email] =>
[model] => Magento\Authorizenet\Model\Directpost
[order_status] => processing
[payment_action] => authorize
[test] => 1
[title] => Credit Card Direct Post (Authorize.net)
[trans_key] =>
[trans_md5] =>
[allowspecific] => 0
[currency] => USD
[create_order_before] => 1
[date_delim] => /
[ccfields] => x_card_code,x_exp_date,x_card_num
[place_order_url] => authorizenet/directpost_payment/place
[cgi_url_test_mode] => https://test.authorize.net/gateway/transact.dll
[cgi_url] => https://secure.authorize.net/gateway/transact.dll
[cgi_url_td_test_mode] => https://apitest.authorize.net/xml/v1/request.api
[cgi_url_td] => https://api2.authorize.net/xml/v1/request.api
)
[braintree] => Array
(
[model] => BraintreeFacade
[title] => Credit Card (Braintree)
[payment_action] => authorize
[active] => 0
[is_gateway] => 1
[can_use_checkout] => 1
[can_authorize] => 1
[can_capture] => 1
[can_capture_partial] => 1
[can_authorize_vault] => 1
[can_capture_vault] => 1
[can_use_internal] => 1
[can_refund_partial_per_invoice] => 1
[can_refund] => 1
[can_void] => 1
[can_cancel] => 1
[cctypes] => AE,VI,MC,DI,JCB,CUP,DN,MI
[useccv] => 1
[cctypes_braintree_mapper] => {"american-express":"AE","discover":"DI","jcb":"JCB","mastercard":"MC","master-card":"MC","visa":"VI","maestro":"MI","diners-club":"DN","unionpay":"CUP"}
[order_status] => processing
[environment] => sandbox
[allowspecific] => 0
[sdk_url] => https://js.braintreegateway.com/js/braintree-2.17.6.min.js
[public_key] =>
[private_key] =>
[masked_fields] => cvv,number
[privateInfoKeys] => avsPostalCodeResponseCode,avsStreetAddressResponseCode,cvvResponseCode,processorAuthorizationCode,processorResponseCode,processorResponseText,liabilityShifted,liabilityShiftPossible,riskDataId,riskDataDecision
[paymentInfoKeys] => cc_type,cc_number,avsPostalCodeResponseCode,avsStreetAddressResponseCode,cvvResponseCode,processorAuthorizationCode,processorResponseCode,processorResponseText,liabilityShifted,liabilityShiftPossible,riskDataId,riskDataDecision
)
[braintree_paypal] => Array
(
[model] => BraintreePayPalFacade
[title] => PayPal (Braintree)
[active] => 0
[payment_action] => authorize
[allowspecific] => 0
[require_billing_address] => 0
[allow_shipping_address_override] => 1
[display_on_shopping_cart] => 1
[order_status] => processing
[is_gateway] => 1
[can_use_checkout] => 1
[can_authorize] => 1
[can_capture] => 1
[can_capture_partial] => 1
[can_refund] => 1
[can_refund_partial_per_invoice] => 1
[can_void] => 1
[can_cancel] => 1
[privateInfoKeys] => processorResponseCode,processorResponseText,paymentId
[paymentInfoKeys] => processorResponseCode,processorResponseText,paymentId,payerEmail
)
[braintree_cc_vault] => Array
(
[model] => BraintreeCreditCardVaultFacade
[title] => Stored Cards (Braintree)
)
The output array of of getActivePaymentMethods() is very long. So, I have just printed out the keys of the array. Keys of the output array contains active method’s code.
Sample Output of array_keys(getActivePaymentMethods()):
Array
(
[0] => free
[1] => checkmo
[2] => purchaseorder
[3] => cashondelivery
[4] => paypal_billing_agreement
)
Related
Each item contains a list of addons as checkboxes. Every time I check an addon I want to push addon_id into the addons array. It's pushing an addon_id to session but it's not pushing it properly.
This code adds item to cart (Notice: I am creating an empty addons array):
$cart = session()->get('cart', []);
if(isset($cart[$request->item_id])) {
$cart[$request->item_id]['qty']++;
} else {
$cart[$request->item_id] = [
'id' => $request->item_id,
'category_id' => $request->category_id,
'price' => $request->item_price,
'item_name' => $request->item_name,
'qty' => 1,
'addons' => [],
];
}
session()->put('cart', $cart);
And this code pushes addons to items:
if(isset($request->item_id)) {
session()->push('cart.addons', $request->addon_id);
}
$cart = session()->get('cart', []);
return response()->json([
'message' => 'Addon added',
'cart' => $cart,
]);
This is how addons are being pushed now:
Array
(
[59] => Array
(
[id] => 59
[category_id] => 27
[price] => 3.78
[item_name] => Simple Sandwich
[qty] => 1
[addons] => Array
(
)
)
[57] => Array
(
[id] => 57
[category_id] => 27
[price] => 5.99
[item_name] => Cheese Burger
[qty] => 1
[addons] => Array
(
)
)
[addons] => Array
(
[0] => 31
)
[addons] => Array
(
[0] => 61,
[1] => 60,
[2] => 31
)
)
I need them to be pushed like this:
Array
(
[59] => Array
(
[id] => 59
[category_id] => 27
[price] => 3.78
[item_name] => Simple Sandwich
[qty] => 1
[addons] => Array
(
[0] => 31
)
)
[57] => Array
(
[id] => 57
[category_id] => 27
[price] => 5.99
[item_name] => Cheese Burger
[qty] => 1
[addons] => Array
(
[0] => 61,
[1] => 60,
[2] => 31
)
)
)
I tried to find a solution but nothing seems to be working the way I need it.
Help is very much appreciated.
Initially you are making an associative array where item_id is the key, but when you are appending in addons you are not specifying against which item_id the addons array should be updated, so you will have to change
if(isset($request->item_id)) {
session()->push('cart.addons', $request->addon_id);
}
to something like this:
if(isset($request->item_id)) {
$cart = session()->get('cart');
if(isset($cart[$request->item_id]) {
array_push($cart[$request->item_id]['addons'],$request->addon_id);
session()->put('cart',$cart);
}
}
i try add
'buyer_email_address'=>$post['email'],
and then make $transactions_api->charge
affter this i call $transactions_api->retrieveTransaction
and i dont see 'buyer_email_address'
also i try add
'billing_address'=>array(
'address_line_1'=>$post['address'],
'first_name'=>$post['first_name'],
'last_name'=>$post['last_name']
),
and i dont see this values in transaction details
SquareConnect\Model\Transaction Object
(
...
[tenders:protected] => Array
(
[0] => SquareConnect\Model\Tender Object
(
...
[note:protected] => Online Transaction
[amount_money:protected] => SquareConnect\Model\Money Object
(
[amount:protected] => 100
[currency:protected] => USD
)
[processing_fee_money:protected] =>
[customer_id:protected] =>
[type:protected] => CARD
[card_details:protected] => SquareConnect\Model\TenderCardDetails Object
(
[status:protected] => CAPTURED
[card:protected] => SquareConnect\Model\Card Object
(
[id:protected] =>
[card_brand:protected] => VISA
[last_4:protected] => 5858
[exp_month:protected] =>
[exp_year:protected] =>
[cardholder_name:protected] =>
[billing_address:protected] =>
[fingerprint:protected] =>
)
[entry_method:protected] => KEYED
)
[cash_details:protected] =>
)
)
[refunds:protected] =>
[reference_id:protected] =>
[product:protected] => EXTERNAL_API
[client_id:protected] =>
[order:protected] =>
[shipping_address:protected] =>
How add information about client?
If you would like to add customer information to a transaction, you should Create a Customer and then pass the customer_id along to the Charge endpoint.
Cannot reverse output, tried with array_reverse and usort.
I'm trying to import products from an XML to Magento with magmi datapump, works fine but I need the output in reverse order for Magento to link simple products with configurable products,
Any ideas?
$xml = simplexml_load_file("23.xml") or die("Error: Cannot create object");
foreach($xml->wapiitems->record as $book) {
$item = $book->fields->itemno;
if (strlen($item) <= 6) {
$type = "configurable";
$ca = "color,size";}
else {
$type = "simple";
$ca = "";}
$newProductData = array(
'sku' => (string)$book->fields->itemno, // name
'type' => (string)$type, // sku
'color' => (string)$book->subtables->descriptions->record->fields->variant1name, // special price
'size' => (string)$book->subtables->descriptions->record->fields->variant3name, // price
'attribute_set' => 'Default', // attribute_set
'store' => 'admin',
'name' => (string)$book->subtables->descriptions->record->fields->description, // full description
'configurable_attributes' => (string)$ca // short description
);
//$dp->ingest($newProductData);
echo "</br>";
print_r ($newProductData);
$newProductData=null; //clear memory
unset($newProductData); //clear memory
}
unset($xml);
$dp->endImportSession(); // end import
My output is:
Array ( [sku] => 90349 [type] => configurable [color] => [size] => [attribute_set] => Default [store] => admin [name] => [configurable_attributes] => color,size )
Array ( [sku] => 903490101004 [type] => simple [color] => Red [size] => 4 [attribute_set] => Default [store] => admin [name] => Q-Irine Cover [configurable_attributes] => )
Array ( [sku] => 903490101005 [type] => simple [color] => Black [size] => 5 [attribute_set] => Default [store] => admin [name] => Q-Irine Cover [configurable_attributes] => )
Array ( [sku] => 903490101006 [type] => simple [color] => Black [size] => 6 [attribute_set] => Default [store] => admin [name] => Q-Irine Cover [configurable_attributes] => )
But I need this:
Array ( [sku] => 903490101006 [type] => simple [color] => Black [size] => 6 [attribute_set] => Default [store] => admin [name] => Q-Irine Cover [configurable_attributes] => )
Array ( [sku] => 903490101005 [type] => simple [color] => Black [size] => 5 [attribute_set] => Default [store] => admin [name] => Q-Irine Cover [configurable_attributes] => )
Array ( [sku] => 903490101004 [type] => simple [color] => Red [size] => 4 [attribute_set] => Default [store] => admin [name] => Q-Irine Cover [configurable_attributes] => )
Array ( [sku] => 90349 [type] => configurable [color] => [size] => [attribute_set] => Default [store] => admin [name] => [configurable_attributes] => color,size )
Not sure how Magmi Datapump is linking the simple and configurable products based on your example, but assuming that all that is required for your problem is that configurable products get imported after the simple products, you could do something like this:
Create an intermediate array of product records after pulling them out of XML by changing $newProductData = array(...) to $newProductData[] = array(...)
Now use something like this to sort your intermediate array by product type:
usort($newProductData, function($a, $b)
{
if ($a['type'] == 'configurable' && $b['type'] == 'simple') {
return 1;
} else if ($a['type'] == 'simple' && $b['type'] == 'configurable') {
return -1;
} else {
return strnatcmp($a['sku'], $b['sku']);
}
});
Finally, iterate over the sorted array and complete the import:
foreach ($newProductData as $data) {
$dp->ingest($data);
}
I have an object called 'events', that's created via $data['events'] = function (the function pulls information out of an events table and others using active record).
The events object looks like:
Array
(
[0] => stdClass Object
(
[id] => 2
[course_name] => Course 3
[course_description] => Course
[course_price] => 995
[supplier_name] => Supplier 3
[location_country_code] => GB
[location_country] => United Kingdom
[location_city] => London
[venue_name] => Venue 2
[venue_address] => 2 Street
[venue_postcode] => EC2M 7PQ
[venue_city] => London
[venue_county] =>
[venue_country] => United Kingdom
[venue_locality] =>
[event_type] => Materials Only
[event_status] => Confirmed
[course_id] => 2
[event_duration] => 3
[event_start_date] => 2013-09-12
[event_date_added] => 2013-02-26 14:36:06
[event_status_id] => 2
[event_type_id] => 4
[tutor_id] => 0
[tutor_confirmed] => 0
[event_featured] => 0
[event_push] => 0
[event_active] => 0
[invigilator_id] => 0
[event_discount] =>
[event_max_delegates] => 16
[location_id] => 1
[venue_id] => 1
[supplier_id] => 2
)
[1] => stdClass Object
(
[id] => 1
[course_name] => Course Name
[course_description] => Course Description
[course_price] => 995
[supplier_name] => Supplier 1
[location_country_code] => GB
[location_country] => United Kingdom
[location_city] => London
[venue_name] => Venue Name
[venue_address] => Street
[venue_postcode] => EC2M 7PQ
[venue_city] => London
[venue_county] =>
[venue_country] => United Kingdom
[venue_locality] =>
[event_type] => Private Venue
[event_status] => Provisional
[course_id] => 1
[event_duration] => 3
[event_start_date] => 2013-11-13
[event_date_added] => 2013-02-26 09:56:17
[event_status_id] => 1
[event_type_id] => 3
[tutor_id] => 0
[tutor_confirmed] => 0
[event_featured] => 0
[event_push] => 0
[event_active] => 0
[invigilator_id] => 0
[event_discount] => 395
[event_max_delegates] => 16
[location_id] => 1
[venue_id] => 1
[supplier_id] => 1
)
)
I'd like to add a nested object under the key 'delegates' for each row using ActiveRecord, that pulls through the delegates attached to the event using a bridge table 'events_delegates_bridge' by comparing the 'event_id' and 'delegate_id columns in that table.
Essentially so that the object looks like so:
Array
(
[0] => stdClass Object
(
[id] => 2
[course_name] => Course 3
[delegates] => Array
(
[0] => stdClass Object
(
[id] => 1
[name] => Joe Bloggs
)
[1] => stdClass Object
(
[id] => 2
[name] => Joe Smith
)
[3] => stdClass Object
(
[id] => 3
[name] => Jane Doe
)
)
[course_description] => Course
[course_price] => 995
[supplier_name] => Supplier 3
[location_country_code] => GB
[location_country] => United Kingdom
[location_city] => London
[venue_name] => Venue 2
[venue_address] => 2 Street
[venue_postcode] => EC2M 7PQ
[venue_city] => London
[venue_county] =>
[venue_country] => United Kingdom
[venue_locality] =>
[event_type] => Materials Only
[event_status] => Confirmed
[course_id] => 2
[event_duration] => 3
[event_start_date] => 2013-09-12
[event_date_added] => 2013-02-26 14:36:06
[event_status_id] => 2
[event_type_id] => 4
[tutor_id] => 0
[tutor_confirmed] => 0
[event_featured] => 0
[event_push] => 0
[event_active] => 0
[invigilator_id] => 0
[event_discount] =>
[event_max_delegates] => 16
[location_id] => 1
[venue_id] => 1
[supplier_id] => 2
)
)
Any ideas how best to achieve this? Thanks.
Event Model
class Event_Model extends CI_Model {
public function get_events() {
$this->db->select( '*' );
$this->db->from( 'courses' );
$this->db->from( 'suppliers' );
$this->db->from( 'locations' );
$this->db->from( 'venues' );
$this->db->from( 'event_type' );
$this->db->from( 'event_status' );
$this->db->join( 'events', 'events.course_id = courses.id AND events.supplier_id = suppliers.id AND events.location_id = locations.id AND events.venue_id = venues.id AND events.event_type_id = event_type.id AND events.event_status_id = event_status.id', 'inner' );
$this->db->order_by( 'events.event_start_date', 'asc' );
$query = $this->db->get();
return $query->result();
}
}
Dashboard Controller
$data['events'] = $this->event_model->get_events();
Delegates Model
I've created this to get the delegate data. Do you think it can be used to add the correct delegates to the events object?
class Delegate_Model extends CI_Model {
public function get_delegates() {
$this->db->select( '*' );
$this->db->from( 'delegates' );
$this->db->from( 'events_delegates_bridge' );
$this->join( 'delegates', 'delegates.id = events_delegates_bridge.delegate_id', 'inner' );
$query = $this->db->get();
return $query->result();
}
}
Just tested this and it shows a blank page.
You're best off doing it with 2 separate queries.
$events = array();
$result = $this->db->query('SELECT * FROM events WHERE ...');
foreach($result->result_array() as $event) {
$events[$event['id']] = $event;
}
$result = $this->db->query('
SELECT * FROM events_delegates_bridge
JOIN delegates ON (delegate_id = delegates.id)
WHERE ...
');
foreach($result->result_array() as $delegate) {
if (!empty($events[$delegate['event_id']])) {
$events[$delegate['event_id']]['delegates'][] = $delegate
}
}
This bit of code just queries the events and puts them in an array indexed by the event id.
Then, a separate query runs to pull up the delegates, and attaches them to the appropriate event.
use $name=$variable->result_array();var_dump($name); I think This work
I have successfully integrated the Silent Post feature with our system for ARB subscriptions. What I am now trying to do is when we refund a payment via the merchant interface, how do I distinguish a refund from all other transactions? Is the a special variable that is set for a refunded payment?
x_type will be set to "credit"
Here is an actual Silent Post verifying that (sensitive info is removed/changed)
Array
(
[x_response_code] => 1
[x_response_subcode] => 1
[x_response_reason_code] => 1
[x_response_reason_text] => This transaction has been approved.
[x_auth_code] => 056187
[x_avs_code] => P
[x_trans_id] => 2692444422
[x_invoice_num] => 123
[x_description] =>
[x_amount] => 59.90
[x_method] => CC
[x_type] => credit
[x_cust_id] => 1234
[x_first_name] => John
[x_last_name] => Smith
[x_company] =>
[x_address] =>
[x_city] =>
[x_state] =>
[x_zip] =>
[x_country] =>
[x_phone] =>
[x_fax] =>
[x_email] =>
[x_ship_to_first_name] =>
[x_ship_to_last_name] =>
[x_ship_to_company] =>
[x_ship_to_address] =>
[x_ship_to_city] =>
[x_ship_to_state] =>
[x_ship_to_zip] =>
[x_ship_to_country] =>
[x_tax] => 0.0000
[x_duty] => 0.0000
[x_freight] => 0.0000
[x_tax_exempt] => FALSE
[x_po_num] =>
[x_MD5_Hash] => 2A4A7F63DB4390A317E4988430FFA4
[x_cvv2_resp_code] =>
[x_cavv_response] =>
[x_test_request] => false
)