Skip to content

Commit

Permalink
headdless integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Oct 12, 2018
1 parent ea480af commit 4e096bd
Show file tree
Hide file tree
Showing 12 changed files with 417 additions and 432 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
"issues" : "https://github.com/luyadev/luya-module-payment/issues"
},
"require" : {
"paypal/rest-api-sdk-php" : "~1.7.0",
"luyadev/luya-core" : "~1.0.0",
"luyadev/luya-module-admin" : "dev-master",
"stripe/stripe-php": "^6.19"
"luyadev/luya-headless" : "dev-master",
"stripe/stripe-php": "^6.19",
"paypal/rest-api-sdk-php" : "~1.7.0"
},
"require-dev" : {
"luyadev/luya-testsuite" : "dev-master",
Expand Down
123 changes: 113 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions src/Pay.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

namespace luya\payment;

use Yii;
use luya\helpers\Url;
use luya\web\Controller;
use luya\payment\frontend\Module;
use luya\payment\base\PayModel;
use luya\payment\models\ProcessItem;
use luya\payment\base\PayItemModel; // Rename to PayArticle?
/**
* Create new Payment.
*
* @author Basil Suter <basil@nadar.io>
* @since 1.0.0
*/
class Pay
{
const STATE_PENDING = 0;
Expand Down Expand Up @@ -107,6 +114,13 @@ protected function getCreateModel()
throw new PaymentException("Error while creating the pay model by the integratort.");
}

/**
* Get the current payment pay model id.
*
* You can store this information in the estore logic of your project.
*
* @return integer The id from the pay process.
*/
public function getId()
{
return $this->getCreateModel()->id;
Expand All @@ -127,6 +141,12 @@ public function dispatch(Controller $controller)
$controller->redirect($this->getCreateModel()->getTransactionGatewayCreateLink());
}

/**
* Find the model by an id.
*
* @param integer $id
* @return PayModel
*/
public static function findById($id)
{
$integrator = Module::getInstance()->getIntegrator();
Expand All @@ -135,6 +155,13 @@ public static function findById($id)
return $model;
}

/**
* Close the current payment for a given id with a state message (success, error, abort).
*
* @param integer $id
* @param integer $state
* @return PayModel
*/
public static function close($id, $state)
{
$model = self::findById($id);
Expand Down

0 comments on commit 4e096bd

Please sign in to comment.