FoxSecrets
Active member
In getPurchaseObject method, the returnUrl and cancelUrl are added to purchase object which the user is redirected after the payment process.
I'd like to manipulate this return.. I got 2 questions
1) How to update status field of some table according to the return url?
2) How to directly add a popup message according to the return url, is there any attribute to buildLink?
I'd like to manipulate this return.. I got 2 questions
1) How to update status field of some table according to the return url?
2) How to directly add a popup message according to the return url, is there any attribute to buildLink?
Code:
public function getPurchaseFromRequest(\XF\Http\Request $request, \XF\Entity\User $purchaser, &$error = null)
{
$profileId = $request->filter('payment_profile_id', 'uint');
.........
/** @var \MyAddon\Service\Purchase\Create $creator */
$creator = \XF::service('MyAddon:Purchase\Create', $item);
$purchase = $creator->save();
return $this->getPurchaseObject($paymentProfile, $purchase, $purchaser);
}
..............
public function getPurchaseObject(\XF\Entity\PaymentProfile $paymentProfile, $purchasable, \XF\Entity\User $purchaser)
{
$purchase = new Purchase();
$purchase->description = "xxxxxxxxxxx";
$purchase->title = "xxxxxxxxxxx";
...........
$router = \XF::app()->router('public');
$purchase->returnUrl = $router->buildLink('canonical:success-url/' . $purchasable->item_id);
$purchase->cancelUrl = $router->buildLink('canonical:fail-url/' . $purchasable->item_id);
return $purchase;
}