Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PayPal/gateway line item details #154

Merged
merged 5 commits into from Nov 3, 2013
Merged

Add PayPal/gateway line item details #154

merged 5 commits into from Nov 3, 2013

Conversation

@amacneil
Copy link
Member

@amacneil amacneil commented Oct 26, 2013

I'm working on passing line item details to PayPal (and other gateways which support this - see #32) and looking for feedback on the API.

It currently looks like this:

$request->setItems(array(
    array('name' => 'Food', 'quantity' => 1, 'price' => '40.00'),
    array('name' => 'Drinks', 'quantity' => 2, 'price' => '6.00'),
));

// or

$items = new ItemBag;
$items->add(array('name' => 'Food', 'quantity' => 1, 'price' => '10.00'));
$request->setItems($items);

// or

$items = new ItemBag;
$item = new Item;
$item->setName('Cheese');
$item->setQuantity(1);
$item->setPrice(99.00);
$items->add($item);
$request->setItems($items);

Similar to the CreditCard object, you can either pass an array and have the ItemBag object instantiated for you, or you can pass the actual item and it will be used.

Feedback welcome.

@amacneil amacneil merged commit 551584e into master Nov 3, 2013
1 check passed
1 check passed
@amacneil
default The Travis CI build passed
Details
@amacneil amacneil deleted the line-items branch Nov 3, 2013
@benjam-es
Copy link

@benjam-es benjam-es commented May 17, 2014

Hi Adrian, can you help. I'm unsure where to set items. I see it says request, but I cant find the equivalent in the sagepay in frame code I am using.

@amacneil
Copy link
Member Author

@amacneil amacneil commented May 17, 2014

I don't think line items are supported on the sagepay gateway yet sorry.

@benjam-es
Copy link

@benjam-es benjam-es commented May 18, 2014

Sagepay allow passing line items as basket information. I would have a go at it, but not sure where to start.

@benjam-es
Copy link

@benjam-es benjam-es commented May 18, 2014

I can see that in sagepay abstract request that getItemData would need to cycle through the item bag to produce a 'basket' parameter within $data (i think) to match their example:

4:Pioneer NSDV99 DVD-Surround Sound System:1:424.68:74.32:499.00: 499.00:Donnie Darko Director’s Cut:3:11.91:2.08:13.99:41.97: Finding Nemo:2:11.05:1.94:12.99:25.98: Delivery:---:---:---:---:4.99 

And that I would need to edit the auth request and complete request files to merge that into the data array..

But In my code I would be unsure where to use it. I.e. I instantiate a serverGateway class, but need to call the setItems method on a request class..

Edit:
Sagepay basket example on page 49..... http://www.sagepay.co.uk/file/1161/download-document/SERVERProtocolandIntegrationGuidelinesV3%200.pdf?token=M_AUH61Et9gH6Eer5WLPCq7lJorv9bLlYlKqLDGa9-8

@judgej
Copy link
Member

@judgej judgej commented Aug 10, 2014

I've just raised a ticket concerning the cart item implementation - I cannot see a way to add custom fields, such as the Net and VAT fields in the SagePay example. Not sure if I've raised it against the right repository, so here it is:

thephpleague/omnipay-common#11

@benjam-es I am trying out the basket like this:

$gateway = \Omnipay::create('Gateway_Name');

// "purchase" is an action; could be authorize or some custom action specific to a gateway.
$request = $gateway->purchase($data);

// Create a basket of items.
$basket = new \Omnipay\Common\ItemBag();
$item = new \OmnipayCommon\Item(['name' => 'item name 1', ...]);
$basket->add($item);

// Or just add the data to the basket and let add() turn that into an item.
$basket->add(['name' => 'item name 2', ...]);
$request->setItems($basket);

// Or just pass the data in to the request and let setItems() create the whole basket.
$request->setItems(['name' => 'item name 1', ...], ['name' => 'item name 2', ...], ...);

$response = $request->send();

My problem is that the basket can only consist of name/quantity/price and nothing more, which limits it pretty much to just PayPal.

A gateway could override the Item class to add its own setters and getters, but that defeats the object of having a unified API to learn.

@ericmuigai
Copy link

@ericmuigai ericmuigai commented Aug 28, 2018

How do I view these items on PayPal history?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants