I'm using Checkout.com and its PHP SDK to set up payment on a website.
I try to set the Phone and The Shipping Address, but i'm doing wrong i suppose.
The API is not so amazing about this as well (or i don't know how to use it to find what i want)
I did something like this for the phone but doesn't work
$customerPhone = new \Checkout\Models\Phone();
$customerPhone->number = $phone;
$payment->shipping = new \stdClass();
$payment->shipping->phone = $customerPhone;
And i have no idea for the address.
If someone knows ?
Thanks
The correct way of sending shipping data on payments is:
$shipping = new \Checkout\Models\Payments\Shipping($address, $phone);
Where $address is an object of Checkout\Models\Address and $phone is an object of Checkout\Models\Phone.
Related
I have been trying to execute a subscription plan. I have hit a roadblock in the form of the billing agreement. I keep getting the following error when trying to create the agreement.
{"name":"VALIDATION_ERROR","details":[{"field":"plan","issue":"Invalid Fields passed in plan. Pass only a valid plan-id."}],"message":"Invalid request. See details.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR"}
I am unsure where the issue lies, trying to force the agreement's set plan to output the id itself also causes a JSON error and does nothing productive.
If you need more info feel free to ask.
$createdPlan = $startPlan->create($paypal);
$patch = new Patch();
$value = new PayPalModel('{
"state":"ACTIVE"
}');
$patch->setOp('replace')
->setPath('/')
->setValue($value);
$patchRequest = new PatchRequest();
$patchRequest->addPatch($patch);
$createdPlan->update($patchRequest, $paypal);
$plan = Plan::get($createdPlan->getId(), $paypal);
$agreement = new Agreement();
$agreement->setName($product . ' Agreement')
->setDescription('Recurring Payment')
->setStartDate(date(c, time()+4));
$agreement->setPlan($plan);
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$agreement->setPayer($payer);
$agreement->create($paypal);
I was able to fix this by creating a new plan object and only setting the id to the actual plan like so.
$jsonplan = new Plan();
$jsonplan->setId($createdPlan->getId());
$agreement->setPlan($jsonplan);
$createdPlan is the plan variable that you need to pass in the $agreement class
$agreement->setPlan($createdPlan);
This is the essential bit of PHP:
// Add subscription
$subscription = new Recurly_Subscription();
$subscription->plan_code = $planCode;
$subscription->currency = 'USD';
$subscription->quantity = 1;
if ($couponCode != "") { $subscription->coupon_code = $couponCode; }
$subscription->account = new Recurly_Account();
$subscription->account->account_code = $customerID;
$subscription->billing_info = new Recurly_BillingInfo();
$subscription->account->billing_info->token_id = $token;
$subscription->create();
When this code runs, $token has the tokenID created by an earlier call to recurly.token (...) with the billing info.
The account already exists on Recurly -- the account ID, first and last names, but no billing info. This is because we allow people to signup for a complimentary service before subscribing. So I want to create the subscription on the extant account. Initially, following the code examples, the create() call was subscription->account->create(). But that failed because the account existed already.
This sounds like an issue with the old PHP library, which did not support tokenization of billing information. An upgrade to the PHP client library should fix this issue.
hello based on this thread: add tracking number automatically
i have managed to add tracking numbers to orders when button 'ship' is pressed
but the question is can i make somehow check before adding tracking number? cause i want to add tracking number only to specific shipping method (carrier)
how can i do that?
i have tried to add if statement before adding tracking number like this:
public function salesOrderShipmentSaveBefore($observer)
{
$rate = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingRatesCollection();
$method = $rate->getCarrier();
if ($method == 'mycompany_mycarrier'){
$trackNumber='123456789';
$shipment = $observer->getEvent()->getShipment();
$track = Mage::getModel('sales/order_shipment_track')
->setNumber($trackNumber)
->setCarrierCode('mycompany_mycarrier')
->setTitle('My Carrier');
$shipment->addTrack($track);
}
but when i press ship button error says that i am calling undefined method - Mage_Sales_Model_Resource_Quote_Address_Rate_Collection::getCarrier()
maybe there is other way how can i check that it is my carrier and then add tracking number; cause this code adds tracking number but to all orders, all i want is that it add tracking number to my own created shipping method
any help would be great
// After Order Place event
$iOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$oOrder = Mage::getModel('sales/order')->loadByIncrementId($iOrderId);
$oOrder->getShippingDescription();
Does the method even exist?
It tells you that you are missing a piece of code.
solved my problem, the Observer.php:
public function salesOrderShipmentSaveBefore($observer)
{
$trackNumber='987654321';
$shipment = $observer->getEvent()->getShipment();
$order = $shipment->getOrder();
$orderIncrementId=$order->getIncrementId();
$oOrder = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
$shipping = $oOrder->getShippingDescription();
if($shipping =='My Carrier - My Method')
{
$track = Mage::getModel('sales/order_shipment_track')
->setNumber($trackNumber)
->setCarrierCode('mycompnay_mycarrier')
->setTitle('My Carrier');
$shipment->addTrack($track);
}
}
now everything works just like i wanted, the tracking number is added to my shipping carrier only.
Thank you Kingshuk Deb, you were right since the begining, i just didnt understood that.
I'm pulling customer addresses out of magento with
$customers = Mage::getModel('customer/customer')->getCollection();
foreach($customers as $customer){
$primary[$i] = $customer->getPrimaryAddresses();
}
The problem is I never get any addresses from that function. I can get the customers addresses via $customer->getAddresses() or $customer->getAdditionalAddresses(); but no primary addresses. I've also tried the getDefaultShippingAddress / getDefaultBillingAddress functions neither of which return any addresses.
Getting a bit annoyed now I just can't figure out whats going on. In the Magento backend I can see which address is set to default/primary so I know the address has been set.
Just leaving this here for the next guy/girl...
As of 1.8
getPrimaryAddresses calls getPrimaryBillingAddress and getPrimaryShippingAddress which calls get getPrimaryAddress with the attribute code default_shipping or default_billing
So either the address is not set as the default or..
Its also possible that the customer (or admin) placed the order but did not save the address to their account (guest). So the getPrimaryBillingAddress method (called by getPrimaryAddresses) of the customer object will return null as the address is persisted in the order.
Try this
$customers = Mage::getModel('customer/customer')->getCollection();
foreach($customers as $customer){
$addressId = $customer->getDefaultBilling();
if ($addressId){
$address = Mage::getModel('customer/address')->load($customerAddressId);
$htmlAddress = $address->format('html');
}
}
You can find more information here http://www.magentocommerce.com/boards/viewthread/71270/
I'm using Express Checkout PHP-SDK (release 96) in my web app.
I'm trying to prefill my customer's billing details on Paypal.
$address = new AddressType();
$address->CityName = strtoupper_tr( $order['invoice']['address']['city'] );
$address->Name = $order['invoice']['title'];
$address->Street1 = $order['invoice']['address']['address'];
$address->Street2 = $order['invoice']['address']['address-2'];
$address->StateOrProvince = $order['invoice']['address']['province'];
$address->PostalCode = $order['invoice']['address']['postal-code'];
$address->Country = 'TR';
$address->Phone = '5004244244';
...
$set_ec_req_details = new SetExpressCheckoutRequestDetailsType();
$set_ec_req_details->BillingAddress = $address;
This code populate form except Phone Number.
I find that if I change country code to 'US', it works too.
I could not find any information on x.com's forums or documentations. I'll be grateful if someone tell me there is a way to do this or not.
Not familiar with this cart, but Paypals phone codes are very much US centric but I've had good luck using night_phone_b to place the phone number into.
Details are https://www.paypal.com/cgi-bin/webscr?cmd=_pdn_xclick_prepopulate_outside