Skip to content

Commit

Permalink
Adds code samples for API Reference
Browse files Browse the repository at this point in the history
  • Loading branch information
l0ck3 committed Mar 3, 2015
1 parent a70be3a commit 8668e8a
Show file tree
Hide file tree
Showing 61 changed files with 304 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.idea/
/build/
/vendor
phpunit.xml
phpunit.xml

.DS_Store
2 changes: 2 additions & 0 deletions samples/authentication/authentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$apiKey = '< YOUR_PRIVATE_KEY >';
$request = new Paymill\Request($apiKey);
5 changes: 5 additions & 0 deletions samples/clients/create_new_client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$client = new Paymill\Models\Request\Client();
$client->setEmail('[email protected]')
->setDescription('Lovely Client')

$response = $request->create($client);
1 change: 1 addition & 0 deletions samples/clients/export_clients_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Not implemented yet */
4 changes: 4 additions & 0 deletions samples/clients/get_client_details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$client = new Paymill\Models\Request\Client();
$client->setId('client_88a388d9dd48f86c3136');

$response = $request->getOne($client);
3 changes: 3 additions & 0 deletions samples/clients/list_clients.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$client = new Paymill\Models\Request\Client();

$response = $request->getAll($client);
4 changes: 4 additions & 0 deletions samples/clients/remove_client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$client = new Paymill\Models\Request\Client();
$client->setId('client_88a388d9dd48f86c3136');

$response = $request->delete($client);
6 changes: 6 additions & 0 deletions samples/clients/update_client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$client = new Paymill\Models\Request\Client();
$client->setId('client_88a388d9dd48f86c3136')
->setEmail('[email protected]')
->setDescription('Updated Client');

$response = $request->update($client);
7 changes: 7 additions & 0 deletions samples/offers/create_new_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$offer = new Paymill\Models\Request\Offer();
$offer->setAmount(4200)
->setCurrency('EUR')
->setInterval('1 WEEK')
->setName('Nerd Special');

$response = $request->create($offer);
1 change: 1 addition & 0 deletions samples/offers/export_offers_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Not implemented yet */
4 changes: 4 additions & 0 deletions samples/offers/get_offer_details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$offer = new Paymill\Models\Request\Offer();
$offer->setId('offer_40237e20a7d5a231d99b');

$response = $request->getOne($offer);
3 changes: 3 additions & 0 deletions samples/offers/list_offers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$offer = new Paymill\Models\Request\Offer();

$response = $request->getAll($offer);
5 changes: 5 additions & 0 deletions samples/offers/remove_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$offer = new Paymill\Models\Request\Offer();
$offer->setId('offer_40237e20a7d5a231d99b')
->removeWithSubscriptions(true);

$response = $request->delete($offer)
10 changes: 10 additions & 0 deletions samples/offers/update_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$offer = new Paymill\Models\Request\Offer();
$offer->setId('offer_40237e20a7d5a231d99b')
->setName('Extended Special')
->setInterval('1 MONTH')
->setAmount(3333)
->setCurrency('USD')
->setTrialPeriodDays(33)
->updateSubscriptions(true);

$response = $request->update($offer)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$payment = new Paymill\Models\Request\Payment();
$payment->setToken('098f6bcd4621d373cade4e832627b4f6');

$response = $request->create($payment);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$payment = new Paymill\Models\Request\Payment();
$payment->setToken('098f6bcd4621d373cade4e832627b4f6')
->setClient('client_88a388d9dd48f86c3136');

$response = $request->create($payment);
4 changes: 4 additions & 0 deletions samples/payments/create_new_debit_payment_with_token.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$payment = new Paymill\Models\Request\Payment();
$payment->setToken('12a46bcd462sd3r3care4e8336ssb4f5');

$response = $request->create($payment);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$payment = new Paymill\Models\Request\Payment();
$payment->setToken('12a46bcd462sd3r3care4e8336ssb4f5');
$payment->setClient('client_88a388d9dd48f86c3136');

$response = $request->create($payment);
1 change: 1 addition & 0 deletions samples/payments/export_payments_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Not implemented yet */
4 changes: 4 additions & 0 deletions samples/payments/get_payment_details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$payment = new Paymill\Models\Request\Payment();
$payment->setId('pay_3af44644dd6d25c820a8');

$response = $request->getOne($payment);
3 changes: 3 additions & 0 deletions samples/payments/list_payments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$payment = new Paymill\Models\Request\Payment();

$response = $request->getAll($payment);
4 changes: 4 additions & 0 deletions samples/payments/remove_payment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$payment = new Paymill\Models\Request\Payment();
$payment->setId('pay_3af44644dd6d25c820a8');

$response = $request->delete($payment);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$preAuth = new Paymill\Models\Request\Preauthorization();
$preAuth->setPayment('pay_d43cf0ee969d9847512b')
->setAmount(4200)
->setCurrency('EUR')
->setDescription('description example');

$response = $request->create($preAuth);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$preAuth = new Paymill\Models\Request\Preauthorization();
$preAuth->setToken('098f6bcd4621d373cade4e832627b4f6')
->setAmount(4200)
->setCurrency('EUR')
->setDescription('description example');

$response = $request->create($preAuth);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Not implemented yet */
4 changes: 4 additions & 0 deletions samples/preauthorizations/get_preauthorization_details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$preAuth = new Paymill\Models\Request\Preauthorization();
$preAuth->setId('preauth_31eb90495837447f76b7');

$response = $request->getOne($preAuth);
3 changes: 3 additions & 0 deletions samples/preauthorizations/list_preauthorizations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$preAuth = new Paymill\Models\Request\Preauthorization();

$response = $request->getAll($preAuth);
4 changes: 4 additions & 0 deletions samples/preauthorizations/remove_preauthorization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$preAuth = new Paymill\Models\Request\Preauthorization();
$preAuth->setId('preauth_31eb90495837447f76b7');

$response = $request->delete($preAuth);
6 changes: 6 additions & 0 deletions samples/refunds/create_new_refund.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$refund = new Paymill\Models\Request\Refund();
$refund->setId('tran_023d3b5769321c649435')
->setAmount(4200) // e.g. "4200" for 42.00 EUR
->setDescription('Sample Description');

$response = $request->create($refund);
1 change: 1 addition & 0 deletions samples/refunds/export_refunds_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Not implemented yet */
4 changes: 4 additions & 0 deletions samples/refunds/get_refund_details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$refund = new Paymill\Models\Request\Refund();
$refund->setId('refund_773ab6f9cd03428953c9');

$response = $request->getOne($refund);
3 changes: 3 additions & 0 deletions samples/refunds/list_refunds.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$refund = new Paymill\Models\Request\Refund();

$response = $request->getAll($refund);
5 changes: 5 additions & 0 deletions samples/subscriptions/cancel_subscription.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setRemove(false);

$response = $request->delete($subscription);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setClient('client_81c8ab98a8ac5d69f749')
->setOffer('offer_40237e20a7d5a231d99b');
->setPayment('pay_5e078197cde8a39e4908f8aa');
->setPeriodOfValidity('2 YEAR');
->setStartAt(1400575533);

$response = $request->create($subscription);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setClient('client_81c8ab98a8ac5d69f749')
->setOffer('offer_40237e20a7d5a231d99b');
->setAmount(3000);
->setPayment('pay_5e078197cde8a39e4908f8aa');
->setCurrency('EUR');
->setInterval('1 week,monday');
->setName('Example Subscription');
->setPeriodOfValidity('2 YEAR');
->setStartAt('1400575533');

$response = $request->create($subscription);
11 changes: 11 additions & 0 deletions samples/subscriptions/create_new_subscription_without_an_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setClient('client_81c8ab98a8ac5d69f749')
->setAmount(3000);
->setPayment('pay_5e078197cde8a39e4908f8aa');
->setCurrency('EUR');
->setInterval('1 week,monday');
->setName('Example Subscription');
->setPeriodOfValidity('2 YEAR');
->setStartAt('1400575533');

$response = $request->create($subscription);
5 changes: 5 additions & 0 deletions samples/subscriptions/delete_subscription.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setRemove(true);

$response = $request->delete($subscription);
1 change: 1 addition & 0 deletions samples/subscriptions/export_subscriptions_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Not implemented yet */
4 changes: 4 additions & 0 deletions samples/subscriptions/get_subscription_details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dc180b755d10da324864');

$response = $request->getOne($subscription);
3 changes: 3 additions & 0 deletions samples/subscriptions/list_subscriptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$subscription = new Paymill\Models\Request\Subscription();

$response = $request->getAll($subscription);
5 changes: 5 additions & 0 deletions samples/subscriptions/pause_subscription.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setPause(true);

$response = $request->update($subscription);
13 changes: 13 additions & 0 deletions samples/subscriptions/update_subscription.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setClient('client_81c8ab98a8ac5d69f749')
->setOffer('offer_40237e20a7d5a231d99b');
->setAmount(3000);
->setPayment('pay_95ba26ba2c613ebb0ca8');
->setCurrency('USD');
->setInterval('1 month,friday');
->setName('Changed Subscription');
->setPeriodOfValidity('14 MONTH');
->setTrialEnd(false);

$response = $request->update($subscription);
6 changes: 6 additions & 0 deletions samples/subscriptions/update_subscription_amount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setAmount(1234);
->setAmountChangeType(0);

$response = $request->update($subscription);
6 changes: 6 additions & 0 deletions samples/subscriptions/update_subscription_offer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$subscription = new Paymill\Models\Request\Subscription();
$subscription->setId('sub_dea86e5c65b2087202e3');
->setOffer('offer_d7e9813a25e89c5b78bd');
->setOfferChangeType(2);

$response = $request->update($subscription);
10 changes: 10 additions & 0 deletions samples/transactions/create_new_transaction_with_app_fee.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
->setCurrency('EUR')
->setToken('098f6bcd4621d373cade4e832627b4f6')
->setDescription('Test Transaction')
->setFeeAmount(420)
->setFeePayment('pay_3af44644dd6d25c820a8')
->setFeeCurrency('EUR');

$response = $request->create($transaction);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
->setCurrency('EUR')
->setClient('client_c781b1d2f7f0f664b4d9')
->setPayment('pay_2f82a672574647cd911d')
->setDescription('Test Transaction');

$response = $request->create($transaction);
7 changes: 7 additions & 0 deletions samples/transactions/create_new_transaction_with_payment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
->setCurrency('EUR')
->setPayment('pay_2f82a672574647cd911d')
->setDescription('Test Transaction');

$response = $request->create($transaction);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
->setCurrency('EUR')
->setPreauthorization('preauth_ec54f67e52e92051bd65')
->setDescription('Test Transaction');

$response = $request->create($transaction);
7 changes: 7 additions & 0 deletions samples/transactions/create_new_transaction_with_token.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setAmount(4200) // e.g. "4200" for 42.00 EUR
->setCurrency('EUR')
->setToken('098f6bcd4621d373cade4e832627b4f6')
->setDescription('Test Transaction');

$response = $request->create($transaction);
1 change: 1 addition & 0 deletions samples/transactions/export_transactions_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Not implemented yet */
4 changes: 4 additions & 0 deletions samples/transactions/get_transaction_details_by_id.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setId('tran_023d3b5769321c649435');

$response = $request->getOne($transaction);
4 changes: 4 additions & 0 deletions samples/transactions/get_transaction_details_by_slv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setId('slv_4125875679');

$response = $request->getOne($transaction);
3 changes: 3 additions & 0 deletions samples/transactions/list_transactions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$transaction = new Paymill\Models\Request\Transaction();

$response = $request->getAll($transaction);
5 changes: 5 additions & 0 deletions samples/transactions/upate_transaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setId('tran_023d3b5769321c649435')
->setDescription('My updated transaction description');

$response = $request->update($transaction);
8 changes: 8 additions & 0 deletions samples/webhooks/create_new_email_webhook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$webhook = new Paymill\Models\Request\Webhook();
$webhook->setEmail('<your-webhook-email>')
->setEventTypes(array(
'transaction.succeeded',
'transaction.failed'
));

$response = $request->create($webhook);
8 changes: 8 additions & 0 deletions samples/webhooks/create_new_url_webhook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$webhook = new Paymill\Models\Request\Webhook();
$webhook->setUrl('<your-webhook-url>')
->setEventTypes(array(
'transaction.succeeded',
'transaction.failed'
));

$response = $request->create($webhook);
1 change: 1 addition & 0 deletions samples/webhooks/export_webhooks_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Not implemented yet */
4 changes: 4 additions & 0 deletions samples/webhooks/get_webhook_details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$webhook = new Paymill\Models\Request\Webhook();
$webhook->setId('hook_40237e20a7d5a231d99b');

$response = $request->getOne($webhook);
7 changes: 7 additions & 0 deletions samples/webhooks/list_webhooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$webhook = new Paymill\Models\Request\Webhook();
$webhook->setFilter(array(
'count' => 2,
'offset' => 0
));

$response = $request->getAll($webhook);
4 changes: 4 additions & 0 deletions samples/webhooks/remove_webhook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$webhook = new Paymill\Models\Request\Webhook();
$webhook->setId('hook_40237e20a7d5a231d99b');

$response = $request->delete($webhook);
9 changes: 9 additions & 0 deletions samples/webhooks/update_webhook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$webhook = new Paymill\Models\Request\Webhook();
$webhook->setId('hook_40237e20a7d5a231d99b')
->setUrl('<your-webhook-url>')
->setEventTypes(array(
'transaction.failed',
'subscription.failed'
));

$response = $request->update($webhook);

0 comments on commit 8668e8a

Please sign in to comment.