Skip to content

Commit

Permalink
Fix broken parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
gray-adeyi committed Dec 1, 2023
1 parent bff65e8 commit 3172568
Show file tree
Hide file tree
Showing 28 changed files with 255 additions and 161 deletions.
2 changes: 1 addition & 1 deletion pypaystack2/_metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "pypaystack2"
__version__ = "2.0.1"
__version__ = "2.0.2"
__author__ = ["Gbenga Adeyi <adeyigbenga005@gmail.com>"]
__license__ = "MIT"
__copyright__ = "Copyright 2023."
53 changes: 46 additions & 7 deletions pypaystack2/api/apple_pay.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
from typing import Optional

from pypaystack2.baseapi import BaseAPI, BaseAsyncAPI
from pypaystack2.utils import HTTPMethod, Response
from pypaystack2.utils import HTTPMethod, Response, append_query_params


class ApplePay(BaseAPI):
"""Provides a wrapper for paystack Apple Pay API
The Apple Pay API allows you to register your application's top-level domain or subdomain.
[Visit paystack api doc](https://paystack.com/docs/api/apple-pay/)
see https://paystack.com/docs/api/apple-pay/
Note
This feature is available to businesses in all markets except South Africa.
"""

def register_domain(self, domain_name: str) -> Response:
"""Register a top-level domain or subdomain for your Apple Pay integration.
This method can only be called with one domain or subdomain at a time.
Note
* This method can only be called with one domain or subdomain at a time.
* This feature is available to businesses in all markets except South Africa.
Args:
Expand All @@ -28,21 +35,37 @@ def register_domain(self, domain_name: str) -> Response:
}
return self._handle_request(HTTPMethod.POST, url, payload)

def get_domains(self) -> Response:
def get_domains(
self,
use_cursor: bool = False,
next: Optional[str] = None,
previous: Optional[str] = None,
) -> Response:
"""Fetches all registered domains on your integration.
Returns an empty array if no domains have been added.
Note
* This feature is available to businesses in all markets except South Africa.
Returns:
A named tuple containing the response gotten from paystack's server.
An empty list in the data if no domains have been added.
"""

url = self._parse_url("/apple-pay/domain")
query_params = [
("use_cursor", use_cursor),
("next", next),
("previous", previous),
]
url = append_query_params(query_params, url)
return self._handle_request(HTTPMethod.GET, url)

def unregister_domain(self, domain_name: str) -> Response:
"""Unregister a top-level domain or subdomain previously used for your Apple Pay integration.
Note
* This feature is available to businesses in all markets except South Africa.
Returns:
A named tuple containing the response gotten from paystack's server.
"""
Expand Down Expand Up @@ -83,21 +106,37 @@ async def register_domain(self, domain_name: str) -> Response:
}
return await self._handle_request(HTTPMethod.POST, url, payload)

async def get_domains(self) -> Response:
async def get_domains(
self,
use_cursor: bool = False,
next: Optional[str] = None,
previous: Optional[str] = None,
) -> Response:
"""Fetches all registered domains on your integration.
Returns an empty array if no domains have been added.
Note
* This feature is available to businesses in all markets except South Africa.
Returns:
A named tuple containing the response gotten from paystack's server.
An empty list in the data if no domains have been added.
"""

url = self._parse_url("/apple-pay/domain")
query_params = [
("use_cursor", use_cursor),
("next", next),
("previous", previous),
]
url = append_query_params(query_params, url)
return await self._handle_request(HTTPMethod.GET, url)

async def unregister_domain(self, domain_name: str) -> Response:
"""Unregister a top-level domain or subdomain previously used for your Apple Pay integration.
Note
* This feature is available to businesses in all markets except South Africa.
Returns:
A named tuple containing the response gotten from paystack's server.
"""
Expand Down
4 changes: 2 additions & 2 deletions pypaystack2/api/bulk_charges.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BulkCharge(BaseAPI):
"""Provides a wrapper for paystack Bulk Charge API
The Bulk Charges API allows you to create and manage multiple recurring payments from your customers.
[https://paystack.com/docs/api/bulk-charge/](https://paystack.com/docs/api/bulk-charge/)
https://paystack.com/docs/api/bulk-charge/
"""

def initiate(self, body: list[BulkChargeInstruction]) -> Response:
Expand Down Expand Up @@ -148,7 +148,7 @@ class AsyncBulkCharge(BaseAsyncAPI):
"""Provides a wrapper for paystack Bulk Charge API
The Bulk Charges API allows you to create and manage multiple recurring payments from your customers.
[https://paystack.com/docs/api/bulk-charge/](https://paystack.com/docs/api/bulk-charge/)
https://paystack.com/docs/api/bulk-charge/
"""

async def initiate(self, body: list[BulkChargeInstruction]) -> Response:
Expand Down
18 changes: 10 additions & 8 deletions pypaystack2/api/charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Charge(BaseAPI):
"""Provides a wrapper for paystack Charge API
The Charge API allows you to configure a payment channel of your choice when initiating a payment.
[https://paystack.com/docs/api/charge/](https://paystack.com/docs/api/charge/)
https://paystack.com/docs/api/charge/
"""

Expand All @@ -17,14 +17,14 @@ def charge(
email: str,
amount: int,
bank: Optional[dict] = None,
bank_transfer: Optional[dict] = None,
auth_code: Optional[str] = None,
pin: Optional[str] = None,
metadata: Optional[dict] = None,
reference: Optional[str] = None,
ussd: Optional[dict] = None,
mobile_money: Optional[dict] = None,
device_id: Optional[str] = None,
birthday: Optional[str] = None,
) -> Response:
"""Initiate a payment by integrating the payment channel of your choice.
Expand All @@ -33,6 +33,8 @@ def charge(
amount: Amount should be in kobo if currency is NGN, pesewas, if currency is GHS,
and cents, if currency is ZAR
bank: Bank account to charge (don't send if charging an authorization code)
bank_transfer: Takes the settings for the Pay with Transfer (PwT) channel. Pass in the
account_expires_at param to set the expiry time.
auth_code: An authorization code to charge (don't send if charging a bank account)
pin: 4-digit PIN (send with a non-reusable authorization code)
metadata: A dictionary of data.
Expand All @@ -41,7 +43,6 @@ def charge(
mobile_money: Mobile details (don't send if charging an authorization code, bank or card)
device_id: This is the unique identifier of the device a user uses in making payment. Only -, .\\`,
= and alphanumeric characters allowed.
birthday: Date of birth.
Returns:
A named tuple containing the response gotten from paystack's server.
Expand All @@ -51,14 +52,14 @@ def charge(
payload = {"email": email, "amount": amount}
optional_params = [
("bank", bank),
("bank_transfer", bank_transfer),
("authorization_code", auth_code),
("pin", pin),
("metadata", metadata),
("reference", reference),
("ussd", ussd),
("mobile_money", mobile_money),
("device_id", device_id),
("birthday", birthday),
]
payload = add_to_payload(optional_params, payload)
url = self._parse_url("/charge")
Expand Down Expand Up @@ -177,7 +178,7 @@ class AsyncCharge(BaseAsyncAPI):
"""Provides a wrapper for paystack Charge API
The Charge API allows you to configure a payment channel of your choice when initiating a payment.
[https://paystack.com/docs/api/charge/](https://paystack.com/docs/api/charge/)
https://paystack.com/docs/api/charge/
"""

Expand All @@ -186,14 +187,14 @@ async def charge(
email: str,
amount: int,
bank: Optional[dict] = None,
bank_transfer: Optional[dict] = None,
auth_code: Optional[str] = None,
pin: Optional[str] = None,
metadata: Optional[dict] = None,
reference: Optional[str] = None,
ussd: Optional[dict] = None,
mobile_money: Optional[dict] = None,
device_id: Optional[str] = None,
birthday: Optional[str] = None,
) -> Response:
"""Initiate a payment by integrating the payment channel of your choice.
Expand All @@ -202,6 +203,8 @@ async def charge(
amount: Amount should be in kobo if currency is NGN, pesewas, if currency is GHS,
and cents, if currency is ZAR
bank: Bank account to charge (don't send if charging an authorization code)
bank_transfer: Takes the settings for the Pay with Transfer (PwT) channel. Pass in the
account_expires_at param to set the expiry time.
auth_code: An authorization code to charge (don't send if charging a bank account)
pin: 4-digit PIN (send with a non-reusable authorization code)
metadata: A dictionary of data.
Expand All @@ -210,7 +213,6 @@ async def charge(
mobile_money: Mobile details (don't send if charging an authorization code, bank or card)
device_id: This is the unique identifier of the device a user uses in making payment. Only -, .\\`,
= and alphanumeric characters allowed.
birthday: The birthdate of the customer.
Returns:
A named tuple containing the response gotten from paystack's server.
Expand All @@ -220,14 +222,14 @@ async def charge(
payload = {"email": email, "amount": amount}
optional_params = [
("bank", bank),
("bank_transfer", bank_transfer),
("authorization_code", auth_code),
("pin", pin),
("metadata", metadata),
("reference", reference),
("ussd", ussd),
("mobile_money", mobile_money),
("device_id", device_id),
("birthday", birthday),
]
payload = add_to_payload(optional_params, payload)
url = self._parse_url("/charge")
Expand Down
4 changes: 2 additions & 2 deletions pypaystack2/api/customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Customer(BaseAPI):
"""Provides a wrapper for paystack Customer API
The Customers API allows you to create and manage customers in your integration.
https://paystack.com/docs/api/#customer
https://paystack.com/docs/api/customer/
"""

def create(
Expand Down Expand Up @@ -245,7 +245,7 @@ class AsyncCustomer(BaseAsyncAPI):
"""Provides a wrapper for paystack Customer API
The Customers API allows you to create and manage customers in your integration.
https://paystack.com/docs/api/#customer
https://paystack.com/docs/api/customer/
"""

async def create(
Expand Down
Loading

0 comments on commit 3172568

Please sign in to comment.