Skip to content

Commit

Permalink
Merge branch 'master' into fix/attribute_error_when_none
Browse files Browse the repository at this point in the history
* master:
  Fix SyntaxError (non-keyword arg after keyword arg) in samples/offers/create_new_offer.py
  Remove redundant semicolons (they are only needed for compound statements: https://docs.python.org/2/reference/compound_stmts.html)
  Fix creation of a webhook with multiple events.
  • Loading branch information
yalnazov committed Sep 30, 2015
2 parents 37ef979 + 0a59dc2 commit 2f5f499
Show file tree
Hide file tree
Showing 55 changed files with 232 additions and 233 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ We have released version 1.1.0 which is coded directly to the PAYMILL API v2.1 a

Initialize the library by providing your api key:
```python
paymill_context = paymill.PaymillContext('<YOUR PRIVATE API KEY>');
paymill_context = paymill.PaymillContext('<YOUR PRIVATE API KEY>')
```
PaymillContext loads the context of PAYMILL for a single account, by providing a merchants private key. It creates 8 services, which represents the PAYMILL API:
* ClientService
Expand All @@ -53,15 +53,15 @@ In all cases, you'll use the predefined service classes to access the PAYMILL AP

To fetch a service instance, call *service name* accessor from paymill_context, like
```python
client_service = paymill_context.get_client_service();
client_service = paymill_context.get_client_service()
```
Every service instance provides basic methods for CRUD functionality.

### Creating objects

Every service provides instance factory methods for creation. They are very different for every service, because every object can be created in a different way. The common pattern is
```python
xxx_service.create_XXX(params...);
xxx_service.create_XXX(params...)
```
For example: client can be created with two optional parameters: *email* and *description*. So we have four possible methods to create the client:
```python
Expand All @@ -85,15 +85,15 @@ For example: client can be created with two optional parameters: *email* and *de

You can retrieve an object by using the get() method with with the instance itself:
```python
client_service.detail(client);
client_service.detail(client)
```
This method throws an PMError if there is no client under the given id.

### Retrieving lists

To retrieve a list you may simply use the list() method:
```python
clients = client_service.list();
clients = client_service.list()
```
You may provide a filter and order to list method:
```python
Expand All @@ -107,14 +107,14 @@ This will load only clients with email [email protected], order descending

In order to update an object simply call a service's update() method:
```python
client_service.update(client);
client_service.update(client)
```

### Deleting objects

You may delete objects by calling the service's delete() method with an object instance.
```python
client_service.remove(client);
client_service.remove(client)
```

## Changelog
Expand All @@ -128,7 +128,7 @@ You may delete objects by calling the service's delete() method with an object i

### 1.1
* Support for Py3
* FilterList added for filter combination
* FilterList added for filter combination
* Bug fixing & code improvements

### 1.0
Expand Down
9 changes: 4 additions & 5 deletions paymill/services/webhook_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ def create_email(self, email, event_types, active):

@classmethod
def _event_types_to_dict(cls, event_types):
event_types_dict = {}
for e in event_types:
event_types_dict.update(dict({'event_types[]': e}))
return event_types_dict
return {
'event_types[]' : event_types,
}

def detail(self, obj):
"""Returns/refreshes the remote Webhook representation with that obj.id
Expand All @@ -58,4 +57,4 @@ def remove(self, obj):
:param Webhook obj: the Webhook object with an id set
:return Webhook: the removed Webhook object:
"""
return self._remove(obj)
return self._remove(obj)
2 changes: 1 addition & 1 deletion samples/authentication/authentication.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
paymill_context = paymill.PaymillContext('< YOUR_PRIVATE_API_KEY >');
paymill_context = paymill.PaymillContext('< YOUR_PRIVATE_API_KEY >')
4 changes: 2 additions & 2 deletions samples/clients/create_new_client.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
client_service = paymill_context.get_client_service();
client = client_service.create(email='[email protected]');
client_service = paymill_context.get_client_service()
client = client_service.create(email='[email protected]')
2 changes: 1 addition & 1 deletion samples/clients/get_client_details.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
client_service = paymill_context.get_client_service();
client_service = paymill_context.get_client_service()
client_details = client_service.detail(client)
4 changes: 2 additions & 2 deletions samples/clients/list_clients.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
client_service = paymill_context.get_client_service();
clients_list = client_service.list();
client_service = paymill_context.get_client_service()
clients_list = client_service.list()
4 changes: 2 additions & 2 deletions samples/clients/remove_client.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
client_service = paymill_context.get_client_service();
client_service.remove(client);
client_service = paymill_context.get_client_service()
client_service.remove(client)
6 changes: 3 additions & 3 deletions samples/clients/update_client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
client_service = paymill_context.get_client_service();
client.email = '[email protected]';
client_service.update(client);
client_service = paymill_context.get_client_service()
client.email = '[email protected]'
client_service.update(client)
8 changes: 4 additions & 4 deletions samples/offers/create_new_offer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
offer_service = paymill_context.get_offer_service();
offer_service = paymill_context.get_offer_service()
offer = offer_service.create(
amount=4200,
currency='EUR',
interval='1 WEEK',
'Nerd Special',
0
);
name='Nerd Special',
trial_period_days=0
)
4 changes: 2 additions & 2 deletions samples/offers/get_offer_details.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
offer_service = paymill_context.get_offer_service();
offer_details = offer_service.detail(offer);
offer_service = paymill_context.get_offer_service()
offer_details = offer_service.detail(offer)
4 changes: 2 additions & 2 deletions samples/offers/list_offers.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
offer_service = paymill_context.get_offer_service();
offers_list = offer_service.list();
offer_service = paymill_context.get_offer_service()
offers_list = offer_service.list()
4 changes: 2 additions & 2 deletions samples/offers/remove_offer.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
offer_service = paymill_context.get_offer_service();
offer_service.remove(offer);
offer_service = paymill_context.get_offer_service()
offer_service.remove(offer)
14 changes: 7 additions & 7 deletions samples/offers/update_offer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
offer_service = paymill_context.get_offer_service();
offer.name = 'Extended Special';
offer.interval = '1 MONTH';
offer.amount = 3333;
offer.currency = 'USD';
offer.trial_period_days = '33';
offer_service = paymill_context.get_offer_service()
offer.name = 'Extended Special'
offer.interval = '1 MONTH'
offer.amount = 3333
offer.currency = 'USD'
offer.trial_period_days = '33'

offer_service.update(offer, true);
offer_service.update(offer, true)
4 changes: 2 additions & 2 deletions samples/payments/create_new_credit_card_payment_with_token.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
payment_service = paymill_context.get_payment_service();
payment_with_token = payment_service.create(token='098f6bcd4621d373cade4e832627b4f6');
payment_service = paymill_context.get_payment_service()
payment_with_token = payment_service.create(token='098f6bcd4621d373cade4e832627b4f6')
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
payment_service = paymill_context.get_payment_service();
payment_service = paymill_context.get_payment_service()
payment_with_token_and_client = payment_service.create(
token='098f6bcd4621d373cade4e832627b4f6',
client_id='client_33baaf3ee3251b083420'
);
)
4 changes: 2 additions & 2 deletions samples/payments/create_new_debit_payment_with_token.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
payment_service = paymill_context.get_payment_service();
payment_with_token = payment_service.create(token='12a46bcd462sd3r3care4e8336ssb4f5');
payment_service = paymill_context.get_payment_service()
payment_with_token = payment_service.create(token='12a46bcd462sd3r3care4e8336ssb4f5')
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
payment_service = paymill_context.get_payment_service();
payment_service = paymill_context.get_payment_service()
payment_with_token_and_client = payment_service.create(
token='12a46bcd462sd3r3care4e8336ssb4f5',
client_id='client_33baaf3ee3251b083420'
);
)
4 changes: 2 additions & 2 deletions samples/payments/get_payment_details.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
payment_service = paymill_context.get_payment_service();
payment_details = payment_service.detail(payment_with_token);
payment_service = paymill_context.get_payment_service()
payment_details = payment_service.detail(payment_with_token)
4 changes: 2 additions & 2 deletions samples/payments/list_payments.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
payment_service = paymill_context.get_payment_service();
payments_list = payment_service.list();
payment_service = paymill_context.get_payment_service()
payments_list = payment_service.list()
4 changes: 2 additions & 2 deletions samples/payments/remove_payment.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
payment_service = paymill_context.get_payment_service();
paymentService.remove(payment_with_token);
payment_service = paymill_context.get_payment_service()
paymentService.remove(payment_with_token)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
preauthorization_service = paymill_context.get_preauthorization_service();
preauthorization_service = paymill_context.get_preauthorization_service()
preauthorization_with_payment = preauthorization_service.create_with_payment_id(
payment_id ='pay_3af44644dd6d25c820a9',
amount=4200,
currency='EUR',
description='description example'
);
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
preauthorization_service = paymill_context.get_preauthorization_service();
preauthorization_service = paymill_context.get_preauthorization_service()
preauthorization_with_token = preauthorization_service.create_with_token(
token='098f6bcd4621d373cade4e832627b4f6',
amount=4200,
currency='EUR',
description='description example'
);
)
4 changes: 2 additions & 2 deletions samples/preauthorizations/get_preauthorization_details.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
preauthorization_service = paymill_context.get_preauthorization_service();
preauthorization_details = preauthorization_service.detail(preauthorization_with_token);
preauthorization_service = paymill_context.get_preauthorization_service()
preauthorization_details = preauthorization_service.detail(preauthorization_with_token)
4 changes: 2 additions & 2 deletions samples/preauthorizations/list_preauthorizations.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
preauthorization_service = paymill_context.get_preauthorization_service();
preauthorizations_list = preauthorization_service.list();
preauthorization_service = paymill_context.get_preauthorization_service()
preauthorizations_list = preauthorization_service.list()
4 changes: 2 additions & 2 deletions samples/preauthorizations/remove_preauthorization.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
preauthorization_service = paymill_context.get_preauthorization_service();
preauthorization_service.remove(preauthorization_with_token);
preauthorization_service = paymill_context.get_preauthorization_service()
preauthorization_service.remove(preauthorization_with_token)
4 changes: 2 additions & 2 deletions samples/refunds/create_new_refund.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
refund_service = paymill_context.get_refund_service();
refund_service = paymill_context.get_refund_service()
refund_transaction = refund_service.refund_transaction(
transaction_id='tran_ca3e7d41fb16d0157a99',
amount=4200
);
)
2 changes: 1 addition & 1 deletion samples/refunds/get_refund_details.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
refund_service = paymill_context.get_refund_service();
refund_service = paymill_context.get_refund_service()
refund_details = refund_service.detail(refund_transaction)
4 changes: 2 additions & 2 deletions samples/refunds/list_refunds.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
refund_service = paymill_context.get_refund_service();
refunds_list = refund_service.list();
refund_service = paymill_context.get_refund_service()
refunds_list = refund_service.list()
4 changes: 2 additions & 2 deletions samples/subscriptions/cancel_subscription.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
subscription_service = paymill_context.get_subscription_service();
subscription_service.cancel(subscription_without_offer);
subscription_service = paymill_context.get_subscription_service()
subscription_service.cancel(subscription_without_offer)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
subscription_service = paymill_context.get_subscription_service();
subscription_service = paymill_context.get_subscription_service()
subscription_with_an_offer = subscription_service.create_with_offer_id(
payment_id='pay_3af44644dd6d25c820a9',
offer_id='offer_bb33ea77b942f570997b'
);
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
subscription_service = paymill_context.get_subscription_service();
subscription_service = paymill_context.get_subscription_service()
subscription_with_offer_and_different_values = subscription_service.create_with_offer_id(
payment_id='pay_5e078197cde8a39e4908f8aa',
offer_id='offer_b33253c73ae0dae84ff4',
name='Example Subscription',
period_of_validity='2 YEAR',
start_at=1400575533
);
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
subscription_service = paymill_context.get_subscription_service();
subscription_service = paymill_context.get_subscription_service()
subscription_without_offer = subscription_service.create_with_amount(
payment_id='pay_5e078197cde8a39e4908f8aa',
amount=3OOO,
currency='EUR',
interval='1 WEEK,MONDAY'
);
)
4 changes: 2 additions & 2 deletions samples/subscriptions/delete_subscription.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
subscription_service = paymill_context.get_subscription_service();
subscription_service.remove(subscription_without_offer);
subscription_service = paymill_context.get_subscription_service()
subscription_service.remove(subscription_without_offer)
2 changes: 1 addition & 1 deletion samples/subscriptions/get_subscription_details.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
subscription_service = paymill_context.get_subscription_service();
subscription_service = paymill_context.get_subscription_service()
subscription_details = subscription_service.detail(subscription_without_offer)
4 changes: 2 additions & 2 deletions samples/subscriptions/list_subscriptions.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
subscription_service = paymill_context.get_subscription_service();
subscription_list = subscription_service.list();
subscription_service = paymill_context.get_subscription_service()
subscription_list = subscription_service.list()
8 changes: 4 additions & 4 deletions samples/subscriptions/pause_subscription.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pause
subscription_service = paymill_context.get_subscription_service();
subscription_service.pause(subscription_without_offer);
subscription_service = paymill_context.get_subscription_service()
subscription_service.pause(subscription_without_offer)
# unpause
subscription_service = paymill_context.get_subscription_service();
subscription_service.unpause(subscription_without_offer);
subscription_service = paymill_context.get_subscription_service()
subscription_service.unpause(subscription_without_offer)
6 changes: 3 additions & 3 deletions samples/subscriptions/update_subscription.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
subscription_service = paymill_context.get_subscription_service();
subscription_without_offer.name = 'Updated Subscription';
subscription_service.update(subscription_without_offer);
subscription_service = paymill_context.get_subscription_service()
subscription_without_offer.name = 'Updated Subscription'
subscription_service.update(subscription_without_offer)
6 changes: 3 additions & 3 deletions samples/subscriptions/update_subscription_amount.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
subscription_service = paymill_context.get_subscription_service();
subscription_without_offer.amount = 1234;
subscription_service.update_with_amount(subscription_without_offer, amount_change_type=1);
subscription_service = paymill_context.get_subscription_service()
subscription_without_offer.amount = 1234
subscription_service.update_with_amount(subscription_without_offer, amount_change_type=1)
6 changes: 3 additions & 3 deletions samples/subscriptions/update_subscription_offer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
subscription_service = paymill_context.get_subscription_service();
subscription_with_an_offer.offer_id='offer_40237e20a7d5a231d99b';
subscription_service = paymill_context.get_subscription_service()
subscription_with_an_offer.offer_id='offer_40237e20a7d5a231d99b'
subscription_service.update_with_offer_id(
subscription_with_an_offer,
offer_change_type=2
);
)
4 changes: 2 additions & 2 deletions samples/transactions/create_new_transaction_with_app_fee.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
transaction_service = paymill_context.get_transaction_service();
transaction_service = paymill_context.get_transaction_service()
transaction_with_token = transaction_service.create_with_token(
token='098f6bcd4621d373cade4e832627b4f6',
amount=4200, currency='EUR',
description='Test Transaction',
fee_amount=4200,
fee_payment_id='pay_3af44644dd6d25c820a8',
fee_currency='EUR'
);
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
transaction_service = paymill_context.get_transaction_service();
transaction_service = paymill_context.get_transaction_service()
transaction_with_client_and_payment = transaction_service.create_with_payment_id(
payment_id='pay_3af44644dd6d25c820a9',
amount=4200, currency='EUR',
description='Test Transaction',
client_id='client_33baaf3ee3251b083420'
);
)
4 changes: 2 additions & 2 deletions samples/transactions/create_new_transaction_with_payment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
transaction_service = paymill_context.get_transaction_service();
transaction_service = paymill_context.get_transaction_service()
transaction_with_payment = transaction_service.create_with_payment_id(
payment_id='pay_3af44644dd6d25c820a9',
amount=4200,
currency='EUR',
description='Test Transaction'
);
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
transaction_service = paymill_context.get_transaction_service();
transaction_service = paymill_context.get_transaction_service()
transaction_with_preauthorization = transaction_service.create_with_preauthorization_id(
preauthorization_id='preauth_ec54f67e52e92051bd65',
amount=4200, currency='EUR',
description='Test Transaction'
);
)
4 changes: 2 additions & 2 deletions samples/transactions/create_new_transaction_with_token.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
transaction_service = paymill_context.get_transaction_service();
transaction_service = paymill_context.get_transaction_service()
transaction_with_token = transaction_service.create_with_token(
token='098f6bcd4621d373cade4e832627b4f6',
amount=4200,
currency='EUR',
description='Test Transaction'
);
)
4 changes: 2 additions & 2 deletions samples/transactions/get_transaction_details_by_id.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
transaction_service = paymill_context.get_transaction_service();
transaction_details = transaction_service.detail(transaction_with_token);
transaction_service = paymill_context.get_transaction_service()
transaction_details = transaction_service.detail(transaction_with_token)
Loading

0 comments on commit 2f5f499

Please sign in to comment.