-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create recurring monthly & yearly subscriptions
- Loading branch information
Showing
4 changed files
with
60 additions
and
4 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
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,54 @@ | ||
<?php | ||
|
||
namespace Srmklive\PayPal\Traits; | ||
|
||
use Carbon\Carbon; | ||
|
||
trait RecurringProfiles | ||
{ | ||
/** | ||
* Create recurring subscription on monthly basis. | ||
* | ||
* @param string $token | ||
* @param float $amount | ||
* @param string $description | ||
* | ||
* @return array | ||
*/ | ||
public function createMonthlySubscription($token, $amount, $description) | ||
{ | ||
$data = [ | ||
'PROFILESTARTDATE' => Carbon::now()->toAtomString(), | ||
'DESC' => $description, | ||
'BILLINGPERIOD' => 'Month', | ||
'BILLINGFREQUENCY' => 1, | ||
'AMT' => $amount, | ||
'CURRENCYCODE' => $this->currency, | ||
]; | ||
|
||
return $this->createRecurringPaymentsProfile($data, $token); | ||
} | ||
|
||
/** | ||
* Create recurring subscription on yearly basis. | ||
* | ||
* @param string $token | ||
* @param float $amount | ||
* @param string $description | ||
* | ||
* @return array | ||
*/ | ||
public function createYearlySubscription($token, $amount, $description) | ||
{ | ||
$data = [ | ||
'PROFILESTARTDATE' => Carbon::now()->toAtomString(), | ||
'DESC' => $description, | ||
'BILLINGPERIOD' => 'Year', | ||
'BILLINGFREQUENCY' => 1, | ||
'AMT' => $amount, | ||
'CURRENCYCODE' => $this->currency, | ||
]; | ||
|
||
return $this->createRecurringPaymentsProfile($data, $token); | ||
} | ||
} |