-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add strong typing in the RecurringPayment related classes
- Loading branch information
Showing
34 changed files
with
995 additions
and
357 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
39 changes: 39 additions & 0 deletions
39
examples/recurring_payment/01-recurring-payment-create.php
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 | ||
|
||
include __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$yaml = new \Symfony\Component\Yaml\Parser(); | ||
$settings = \Symfony\Component\Yaml\Yaml::parse(file_get_contents(__DIR__.'/../config.yml')); | ||
|
||
try { | ||
$http_client = new \GuzzleHttp\Client(); | ||
$client = new \zaporylie\Vipps\Client($settings['client_id'], [ | ||
'http_client' => $http_client, | ||
'vipps_system_name' => 'vipps_zaporylie_example', | ||
'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, | ||
]); | ||
$vipps = new \zaporylie\Vipps\Vipps($client); | ||
$authorization = new \zaporylie\Vipps\Api\Authorization($vipps, $settings['subscription_key']); | ||
$authorization->getToken($settings['client_secret']); | ||
$payment = new \zaporylie\Vipps\Api\v3\RecurringPayment($vipps, $settings['subscription_key'], $settings['merchant_serial_number']); | ||
$result = $payment->createAgreement((new \zaporylie\Vipps\Model\RecurringPayment\v3\RequestCreateAgreement()) | ||
->setPricing((new \zaporylie\Vipps\Model\RecurringPayment\v3\Pricing()) | ||
->setCurrency('NOK') | ||
->setType('FLEXIBLE') | ||
->setAmount(1000)) | ||
->setMerchantRedirectUrl('https://eoncxehuh2o2qyq.m.pipedream.net') | ||
->setMerchantAgreementUrl('https://eoncxehuh2o2qyq.m.pipedream.net') | ||
->setProductName('Recurring Product that is being purchased')); | ||
echo '<pre>'; | ||
var_dump($result); | ||
echo '</pre>'; | ||
|
||
} | ||
catch (\Exception $e) { | ||
echo '<pre>'; | ||
var_dump($e->getMessage()); | ||
var_dump($e->getTraceAsString()); | ||
echo '</pre>'; | ||
} | ||
|
||
?> |
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 | ||
|
||
include __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$yaml = new \Symfony\Component\Yaml\Parser(); | ||
$settings = \Symfony\Component\Yaml\Yaml::parse(file_get_contents(__DIR__.'/../config.yml')); | ||
|
||
try { | ||
$http_client = new \GuzzleHttp\Client(); | ||
$client = new \zaporylie\Vipps\Client($settings['client_id'], [ | ||
'http_client' => $http_client, | ||
'vipps_system_name' => 'vipps_zaporylie_example', | ||
'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, | ||
]); | ||
$vipps = new \zaporylie\Vipps\Vipps($client); | ||
$authorization = new \zaporylie\Vipps\Api\Authorization($vipps, $settings['subscription_key']); | ||
$authorization->getToken($settings['client_secret']); | ||
$payment = new \zaporylie\Vipps\Api\v3\RecurringPayment($vipps, $settings['subscription_key'], $settings['merchant_serial_number']); | ||
$result = $payment->getAgreement('agr_KG6k3X3'); | ||
echo '<pre>'; | ||
var_dump($result); | ||
echo '</pre>'; | ||
|
||
} | ||
catch (\Exception $e) { | ||
echo '<pre>'; | ||
var_dump($e->getMessage()); | ||
var_dump($e->getTraceAsString()); | ||
echo '</pre>'; | ||
} | ||
|
||
?> |
44 changes: 44 additions & 0 deletions
44
examples/recurring_payment/02-recurring-payment-create-charge.php
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,44 @@ | ||
<?php | ||
|
||
include __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$yaml = new \Symfony\Component\Yaml\Parser(); | ||
$settings = \Symfony\Component\Yaml\Yaml::parse(file_get_contents(__DIR__.'/../config.yml')); | ||
|
||
try { | ||
$http_client = new \GuzzleHttp\Client(); | ||
$client = new \zaporylie\Vipps\Client($settings['client_id'], [ | ||
'http_client' => $http_client, | ||
'vipps_system_name' => 'vipps_zaporylie_example', | ||
'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, | ||
]); | ||
$vipps = new \zaporylie\Vipps\Vipps($client); | ||
$authorization = new \zaporylie\Vipps\Api\Authorization($vipps, $settings['subscription_key']); | ||
$authorization->getToken($settings['client_secret']); | ||
$payment = new \zaporylie\Vipps\Api\v3\RecurringPayment($vipps, $settings['subscription_key'], $settings['merchant_serial_number']); | ||
$result = $payment->createCharge('agr_KG6k3X3', (new \zaporylie\Vipps\Model\RecurringPayment\v3\RequestCreateCharge()) | ||
->setAmount(1000) | ||
->setDescription('Ok, that worked') | ||
->setDue(new DateTime('+1 day')) | ||
->setTransactionType('DIRECT_CAPTURE')); | ||
echo '<pre>'; | ||
var_dump($result); | ||
echo '</pre>'; | ||
$result = $payment->createCharge('agr_KG6k3X3', (new \zaporylie\Vipps\Model\RecurringPayment\v3\RequestCreateCharge()) | ||
->setAmount(1100) | ||
->setType('UNSCHEDULED') | ||
->setDescription('Ok, that worked too') | ||
->setTransactionType('DIRECT_CAPTURE')); | ||
echo '<pre>'; | ||
var_dump($result); | ||
echo '</pre>'; | ||
|
||
} | ||
catch (\Exception $e) { | ||
echo '<pre>'; | ||
var_dump($e->getMessage()); | ||
var_dump($e->getTraceAsString()); | ||
echo '</pre>'; | ||
} | ||
|
||
?> |
32 changes: 32 additions & 0 deletions
32
examples/recurring_payment/02-recurring-payment-get-charge.php
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 | ||
|
||
include __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$yaml = new \Symfony\Component\Yaml\Parser(); | ||
$settings = \Symfony\Component\Yaml\Yaml::parse(file_get_contents(__DIR__.'/../config.yml')); | ||
|
||
try { | ||
$http_client = new \GuzzleHttp\Client(); | ||
$client = new \zaporylie\Vipps\Client($settings['client_id'], [ | ||
'http_client' => $http_client, | ||
'vipps_system_name' => 'vipps_zaporylie_example', | ||
'vipps_system_version' => \zaporylie\Vipps\Client::VERSION, | ||
]); | ||
$vipps = new \zaporylie\Vipps\Vipps($client); | ||
$authorization = new \zaporylie\Vipps\Api\Authorization($vipps, $settings['subscription_key']); | ||
$authorization->getToken($settings['client_secret']); | ||
$payment = new \zaporylie\Vipps\Api\v3\RecurringPayment($vipps, $settings['subscription_key'], $settings['merchant_serial_number']); | ||
$result = $payment->getCharge('agr_KG6k3X3','chr-gTHPbNE'); | ||
echo '<pre>'; | ||
var_dump($result); | ||
echo '</pre>'; | ||
|
||
} | ||
catch (\Exception $e) { | ||
echo '<pre>'; | ||
var_dump($e->getMessage()); | ||
var_dump($e->getTraceAsString()); | ||
echo '</pre>'; | ||
} | ||
|
||
?> |
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
Oops, something went wrong.