-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added one-time charge functionality to tool kit (#11)
- Loading branch information
1 parent
ea14b05
commit 5fd88d1
Showing
2 changed files
with
217 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
<?php | ||
|
||
namespace BoldApps\ShopifyToolkit\Models; | ||
|
||
use BoldApps\ShopifyToolkit\Contracts\Serializeable; | ||
|
||
/** | ||
* Class ApplicationCharge | ||
* @package BoldApps\ShopifyToolkit\Models | ||
*/ | ||
class ApplicationCharge implements Serializeable | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $id; | ||
/** | ||
* @var string | ||
*/ | ||
protected $confirmationUrl; | ||
/** | ||
* @var string | ||
*/ | ||
protected $createdAt; | ||
/** | ||
* @var string | ||
*/ | ||
protected $name; | ||
/** | ||
* @var float | ||
*/ | ||
protected $price; | ||
/** | ||
* @var string | ||
*/ | ||
protected $returnUrl; | ||
/** | ||
* @var string | ||
*/ | ||
protected $status; | ||
/** | ||
* @var boolean | ||
*/ | ||
protected $test; | ||
/** | ||
* @var string | ||
*/ | ||
protected $updatedAt; | ||
/** | ||
* @var int | ||
*/ | ||
protected $apiClientId; | ||
/** | ||
* @var string | ||
*/ | ||
protected $decoratedReturnUrl; | ||
|
||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getConfirmationUrl() | ||
{ | ||
return $this->confirmationUrl; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCreatedAt() | ||
{ | ||
return $this->createdAt; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param $name | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getPrice() | ||
{ | ||
return $this->price; | ||
} | ||
|
||
/** | ||
* @param $price | ||
*/ | ||
public function setPrice($price) | ||
{ | ||
$this->price = $price; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getReturnUrl() | ||
{ | ||
return $this->returnUrl; | ||
} | ||
|
||
/** | ||
* @param $returnUrl | ||
*/ | ||
public function setReturnUrl($returnUrl) | ||
{ | ||
$this->returnUrl = $returnUrl; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getStatus() | ||
{ | ||
return $this->status; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function getTest() | ||
{ | ||
return $this->test; | ||
} | ||
|
||
/** | ||
* @param $test | ||
*/ | ||
public function setTest($test) | ||
{ | ||
$this->test = $test; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUpdatedAt() | ||
{ | ||
return $this->updatedAt; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getApiClientId() | ||
{ | ||
return $this->apiClientId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getDecoratedReturnUrl() | ||
{ | ||
return $this->decoratedReturnUrl; | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
|
||
namespace BoldApps\ShopifyToolkit\Services; | ||
|
||
use BoldApps\ShopifyToolkit\Models\ApplicationCharge as ShopifyApplicationCharge; | ||
|
||
/** | ||
* Class ApplicationCharge | ||
* @package BoldApps\ShopifyToolkit\Services | ||
*/ | ||
class ApplicationCharge extends Base | ||
{ | ||
|
||
/** | ||
* @param ShopifyApplicationCharge $applicationCharge | ||
* | ||
* @return ShopifyApplicationCharge \ object | ||
*/ | ||
public function create(ShopifyApplicationCharge $applicationCharge) | ||
{ | ||
$serializedModel = ['application_charge' => $this->serializeModel($applicationCharge)]; | ||
|
||
$raw = $this->client->post('admin/application_charges.json', [], $serializedModel); | ||
|
||
return $this->unserializeModel($raw['application_charge'], ShopifyApplicationCharge::class); | ||
} | ||
|
||
/** | ||
* @param $id | ||
* | ||
* @return ShopifyApplicationCharge \ object | ||
*/ | ||
public function getById($id) | ||
{ | ||
$charge = $this->client->get("admin/application_charges/$id.json"); | ||
|
||
return $this->unserializeModel($charge['application_charge'], ShopifyApplicationCharge::class); | ||
} | ||
} |