-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85ea4f3
commit 4519077
Showing
6 changed files
with
145 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
namespace AppZap\Payment; | ||
|
||
use AppZap\Payment\Provider\Offline; | ||
use AppZap\Payment\Provider\PaymentProviderInterface; | ||
use AppZap\Payment\Provider\Paypal; | ||
use AppZap\Payment\Provider\Sofortueberweisung; | ||
|
||
class PaymentFactory | ||
{ | ||
|
||
/** | ||
* @param string $paymentProviderName | ||
* @return PaymentProviderInterface | ||
*/ | ||
public function getPaymentProviderObject($paymentProviderName) | ||
{ | ||
// todo: move the supported payment providers to separate composer packages and offer an API to register themselves | ||
$supportedPaymentProviders = array( | ||
Paypal::PROVIDER_NAME => Paypal::class, | ||
Sofortueberweisung::PROVIDER_NAME => Sofortueberweisung::class, | ||
Offline::PROVIDER_NAME => Offline::class, | ||
); | ||
|
||
if (array_key_exists($paymentProviderName, $supportedPaymentProviders)) { | ||
return new $supportedPaymentProviders[$paymentProviderName]; | ||
} else { | ||
throw new \InvalidArgumentException('Payment provider ' . htmlentities($paymentProviderName) . ' is not supported.', 1447533889); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
namespace AppZap\Payment\Provider; | ||
|
||
use AppZap\Payment\Model\OrderInterface; | ||
use AppZap\Payment\Session\SessionHandlerInterface; | ||
|
||
interface PaymentProviderInterface | ||
{ | ||
|
||
const RETURN_TYPE_ABORT = 0; | ||
const RETURN_TYPE_PAID = 1; | ||
const RETURN_TYPE_OFFLINE_PAYMENT = 2; | ||
const RETURN_TYPE_ERROR = 3; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function execute(); | ||
|
||
/** | ||
* When you have configured the payment properly this will give you a URL that you can redirect your visitor to, | ||
* so that he can pay the desired amount. | ||
* | ||
* @param $urlFormat | ||
* @return string | ||
*/ | ||
public function getPaymentUrl($urlFormat); | ||
|
||
/** | ||
* @param string $key | ||
* @return void | ||
*/ | ||
public function setEncryptionKey($key); | ||
|
||
/** | ||
* @param OrderInterface $order | ||
* @return void | ||
*/ | ||
public function setOrder(OrderInterface $order); | ||
|
||
/** | ||
* @param array $paymentProviderAuthConfig | ||
* @return void | ||
*/ | ||
public function setPaymentProviderAuthConfig(array $paymentProviderAuthConfig); | ||
|
||
/** | ||
* @param SessionHandlerInterface $sessionHandler | ||
* @return void | ||
*/ | ||
public function setSessionHandler(SessionHandlerInterface $sessionHandler); | ||
|
||
/** | ||
* @param OrderInterface $order | ||
* @param string $returnToken | ||
* @return int | ||
*/ | ||
public function evaluateReturnToken(OrderInterface $order, $returnToken); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters