You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am pulling my hair out on this issue, after a lot of digging it looks like i need to send an array of items through the purchase and completePurchase functions. I am using Silverstripe Omnipay and SilverShop to handle the shop.
Through a lot of digging i was able to find the file silverstripe-omnipay\src\Service\PurchaseService.php that has several extension hooks that look like they should do this using the method hooks onBeforePurchase, onAfterPurchase, onBeforeCompletePurchase, and onAfterCompletePurchase
I set up some really rough methods in an extension that create an array of the items, and adds it onto the requests, a bit like this:
<?phpnamespaceSilverStripe\Omnipay\Service;
useSilverStripe\Omnipay\Exception\InvalidStateException;
useSilverStripe\Omnipay\Exception\InvalidConfigurationException;
useSilverStripe\Omnipay\Helper\ErrorHandling;
useSilverStripe\Omnipay\Model\Message\AwaitingPurchaseResponse;
useSilverStripe\Omnipay\Model\Message\CompletePurchaseError;
useSilverStripe\Omnipay\Model\Message\CompletePurchaseRequest;
useSilverStripe\Omnipay\Model\Message\PurchasedResponse;
useSilverStripe\Omnipay\Model\Message\PurchaseError;
useSilverStripe\Omnipay\Model\Message\PurchaseRedirectResponse;
useSilverStripe\Omnipay\Model\Message\PurchaseRequest;
class PurchaseService extends PaymentService
{
publicfunctiononAfterPurchase($request){
$bag = array();
// stuff to build the array - it's really ugly so i haven't included it here// I can build and return the array, but it doesn't seem to make it into the requests.$request->setItems($bag);
}
}
This is implemented through the Injector class to extend the original.
Basically i have this function duplicated in onAfterPurchase() and onAfterCompletePurchase();
However, this information never seems to make it through the requests to actually send to paypal, and is an empty PayPalItemBag object in the response.
Please help, after days of digging through code to get this far i am at my wits end.
The text was updated successfully, but these errors were encountered:
I am pulling my hair out on this issue, after a lot of digging it looks like i need to send an array of items through the purchase and completePurchase functions. I am using Silverstripe Omnipay and SilverShop to handle the shop.
Here is a list of articles i used to sort of help me find my 'solution'
thephpleague/omnipay#154
https://stackoverflow.com/questions/25361190/list-multiple-items-through-paypal-express-checkout-using-omnipay-laravel-4
https://stackoverflow.com/questions/29688023/how-to-send-description-of-products-to-paypal-express-omnipay
Through a lot of digging i was able to find the file silverstripe-omnipay\src\Service\PurchaseService.php that has several extension hooks that look like they should do this using the method hooks onBeforePurchase, onAfterPurchase, onBeforeCompletePurchase, and onAfterCompletePurchase
I set up some really rough methods in an extension that create an array of the items, and adds it onto the requests, a bit like this:
This is implemented through the Injector class to extend the original.
Basically i have this function duplicated in onAfterPurchase() and onAfterCompletePurchase();
However, this information never seems to make it through the requests to actually send to paypal, and is an empty PayPalItemBag object in the response.
Please help, after days of digging through code to get this far i am at my wits end.
The text was updated successfully, but these errors were encountered: