Skip to content

Commit

Permalink
Merge pull request #4 from BenjaminMedia/WILL-189/purchase-url
Browse files Browse the repository at this point in the history
WILL-189 - Adding url to purchase through login
  • Loading branch information
Frozire authored Feb 6, 2018
2 parents 0d6b63f + 0ebf36e commit 19e51c6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Repositories/PurchaseManagerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 19e51c6

Please sign in to comment.