From 0ebf36e423f99129809749a017de0778114e4a0c Mon Sep 17 00:00:00 2001 From: Magnus Flor Johansen Date: Tue, 6 Feb 2018 16:20:28 +0100 Subject: [PATCH] WILL-189 - Adding url to purchase through login --- src/Repositories/PurchaseManagerRepository.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Repositories/PurchaseManagerRepository.php b/src/Repositories/PurchaseManagerRepository.php index 30110a8..17e05c1 100644 --- a/src/Repositories/PurchaseManagerRepository.php +++ b/src/Repositories/PurchaseManagerRepository.php @@ -70,6 +70,24 @@ public function getPaymentUrl($productId, $callbackUrl = false, $paymentPreviewA return $url; } + + public function getLoginPaymentUrl($productId, $callbackUrl = false, $paymentPreviewAttributes) + { + $purchaseUri = sprintf( + '%s?product_id=%s&callback=%s&payment_attributes=%s', + urlencode(WpPurchase::instance()->getRoutes()->getPurchaseUri()), + urlencode($productId), + urlencode($callbackUrl), + urlencode(json_encode($paymentPreviewAttributes)) + ); + + $loginUri = sprintf( + '%s?redirect_uri=%s', + WpOAuth::instance()->getRoutes()->getURI(Routes::LOGIN_ROUTE), + urlencode($purchaseUri) + ); + return $loginUri; + } public function paymentPreviewParameters($paymentArticlePreviewAttributes) {