AmazonPayClient


NameAmazonPayClient JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://github.com/wangrunbo/amazon-pay-api-sdk-python
SummaryA non-official Amazon Pay Python SDK
upload_time2023-01-03 09:33:28
maintainer
docs_urlNone
authorWang Runbo
requires_python
licenseApache License version 2.0, January 2004
keywords amazon payments python api sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Amazon Pay API SDK (Python)

Amazon Pay Integration.

Please note this is a **Non-Official** Amazon Pay Python SDK and can only be used for API calls to the
**_pay-api.amazon.com|eu|jp_** endpoint.

For more details about the api, please check
the [Official Documentation for developers](https://developer.amazon.com/docs/amazon-pay/intro.html).

## Requirements

* Python 3.x
* requests >= 2.28.1
* pycryptodome >= 3.16.0

## SDK Installation

Use PyPI to install the latest release of the SDK:

```
pip install AmazonPayClient
```

## Configuration

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='jp',
    sandbox=True
)
```

If you have created environment specific keys (i.e. Public Key Starts with LIVE or SANDBOX) in Seller Central, then use
those PublicKeyId & PrivateKey. In this case, there is no need to pass the sandbox parameter to the configuration.

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='jp',
)
```

# Versioning

The pay-api.amazon.com|eu|jp endpoint uses versioning to allow future updates. The major version of this SDK will stay
aligned with the API version of the endpoint.

If you have downloaded version 2.x.y of this SDK, the API version would be "v2".

If you need to use a "v1" version of Amazon Pay API,
seek [Official Documentation](https://developer.amazon.com/docs/amazon-pay/intro.html) for help.

# Convenience Functions (Overview)

Make use of the built-in convenience functions to easily make API calls. Scroll down further to see example code
snippets.

When using the convenience functions, the request payload will be signed using the provided private key, and a HTTPS
request is made to the correct regional endpoint.

## Alexa Delivery Trackers API

[Delivery Trackers API Guide](https://developer.amazon.com/docs/amazon-pay-api-v2/delivery-tracker.html)

* Create Delivery Tracker - **create_delivery_tracker**(body: dict)

## Amazon Checkout v2 API

[API Integration Guide](https://amazonpaycheckoutintegrationguide.s3.amazonaws.com/amazon-pay-api-v2/introduction.html)

### Buyer

[Buyer API Guide](https://developer.amazon.com/docs/amazon-pay-api-v2/buyer.html)

* Get Buyer - **get_buyer**(buyer_token: str)

### Checkout Session

[Checkout Session API Guide](https://developer.amazon.com/docs/amazon-pay-api-v2/checkout-session.html)

* Create Checkout Session - **create_checkout_session**(body: dict)
* Get Checkout Session - **get_checkout_session**(checkout_session_id: str)
* Update Checkout Session - **update_checkout_session**(checkout_session_id: str, body: dict)
* Complete Checkout Session - **complete_checkout_session**(checkout_session_id: str, body: dict)

### Charge Permission

[Charge Permission API Guide](https://developer.amazon.com/docs/amazon-pay-api-v2/charge-permission.html)

* Get Charge Permission - **get_charge_permission**(charge_permission_id: str)
* Update Charge Permission - **update_charge_permission**(charge_permission_id: str, body: dict)
* Close Charge Permission - **close_charge_permission**(charge_permission_id: str, body: dict)

### Charge

* Create Charge - **create_charge**(body: dict)
* Get Charge - **get_charge**(charge_id: str)
* Capture - **capture_charge**(charge_id: str, body: dict)
* Cancel Charge - **cancel_charge**(charge_id: str, body: dict)

### Refund

* Create Refund - **create_refund**(body: dict)
* Get Refund - **get_refund**(refund_id: str)

# Convenience Functions Code Samples

## Alexa Delivery Notifications

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=False
)

body = {
    'amazonOrderReferenceId': 'P00-0000000-0000000',
    'deliveryDetails': [
        {
            'carrierCode': 'UPS',
            'trackingNumber': '1Z999AA10123456784'
        }
    ]
}

response = client.create_delivery_tracker(body)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Create Checkout Session

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

body = {
    'webCheckoutDetails': {
        'checkoutReviewReturnUrl': 'https://localhost/store/checkout_review',
        'checkoutResultReturnUrl': 'https://localhost/store/checkout_result'
    },
    'storeId': 'YOUR_STORE_ID'
}

response = client.create_checkout_session(body)

if response.status_code == 201:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Get Checkout Session

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

checkout_session_id = '00000000-0000-0000-0000-000000000000'

response = client.get_checkout_session(checkout_session_id)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Update Checkout Session

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

checkout_session_id = '00000000-0000-0000-0000-000000000000'
body = {
    'paymentDetails': {
        'chargeAmount': {
            'amount': '100',
            'currencyCode': 'JPY'
        }
    }
}

response = client.update_checkout_session(checkout_session_id, body)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Complete Checkout Session

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

checkout_session_id = '00000000-0000-0000-0000-000000000000'
body = {
    'chargeAmount': {
        'amount': '100',
        'currencyCode': 'JPY'
    }
}

response = client.complete_checkout_session(checkout_session_id, body)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Get Charge Permission

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

charge_permission_id = 'S00-0000000-0000000'

response = client.get_charge_permission(charge_permission_id)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Update Charge Permission

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

charge_permission_id = 'S00-0000000-0000000'
body = {
    'merchantMetadata': {
        'merchantReferenceId': '00-00-000000-00',
        'merchantStoreName': 'Test Store',
        'noteToBuyer': 'Some Note to buyer',
        'customInformation': 'Custom Information'
    }
}

response = client.update_charge_permission(charge_permission_id, body)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Close Charge Permission

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

charge_permission_id = 'S00-0000000-0000000'
body = {
    'closureReason': 'No more charges required',
    'cancelPendingCharges': False
}

response = client.close_charge_permission(charge_permission_id, body)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Create Charge

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

body = {
    'chargePermissionId': 'S00-0000000-0000000',
    'chargeAmount': {
        'amount': '100',
        'currencyCode': 'JPY'
    },
    'captureNow': True
}

response = client.create_charge(body)

if response.status_code == 201:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Get Charge

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

charge_id = 'S00-0000000-0000000-C000000'

response = client.get_charge(charge_id)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Capture Charge

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

charge_id = 'S00-0000000-0000000-C000000'
body = {
    'captureAmount': {
        'amount': '100',
        'currencyCode': 'JPY'
    }
}

response = client.capture_charge(charge_id, body)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Cancel Charge

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

charge_id = 'S00-0000000-0000000-C000000'
body = {
    'cancellationReason': 'REASON DESCRIPTION'
}

response = client.cancel_charge(charge_id, body)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Create Refund

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

body = {
    'chargeId': 'S00-0000000-0000000-C000000',
    'refundAmount': {
        'amount': '100',
        'currencyCode': 'JPY'
    },
}

response = client.create_refund(body)

if response.status_code == 201:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

## Amazon Checkout v2 - Get Refund

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

refund_id = 'S00-0000000-0000000-R000000'

response = client.get_refund(refund_id)

if response.status_code == 200:
    # success
    result = response.json()
    print(result)
else:
    # check the error
    print('Status Code: ' + str(response.status_code) + '\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\n')
```

# Generate Button Signature (helper function)

The signatures generated by this helper function are only valid for the Checkout v2 front-end buttons. Unlike API
signing, no timestamps are involved, so the result of this function can be considered a static signature that can safely
be placed in your website JS source files and used repeatedly (as long as your payload does not change).

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

payload = '{"webCheckoutDetails": {"checkoutResultReturnUrl": "https://localhost/store/checkout_result", "checkoutMode": "ProcessOrder"}, "chargePermissionType": "OneTime", "paymentDetails": {"paymentIntent": "Confirm", "chargeAmount": {"amount": "100", "currencyCode": "JPY"}}, "storeId": "YOUR_STORE_ID"}'

signature = client.generate_button_signature(payload)
```

You can also use a _dict_ as your payload. But make sure the `json.dumps(payload)` result matches the one you are using
in your button, such as spaces etc.

```python
from AmazonPay import Client

client = Client(
    public_key_id='YOUR_PUBLIC_KEY_ID',
    private_key='keys/private.pem',
    region='us',
    sandbox=True
)

payload = {
    'webCheckoutDetails': {
        'checkoutResultReturnUrl': 'https://localhost/store/checkout_result',
        'checkoutMode': 'ProcessOrder'
    },
    'chargePermissionType': 'OneTime',
    'paymentDetails': {
        'paymentIntent': 'Confirm',
        'chargeAmount': {
            'amount': '100',
            'currencyCode': 'JPY'
        }
    },
    'storeId': 'YOUR_STORE_ID'
}

signature = client.generate_button_signature(payload)
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wangrunbo/amazon-pay-api-sdk-python",
    "name": "AmazonPayClient",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Amazon,Payments,Python,API,SDK",
    "author": "Wang Runbo",
    "author_email": "wangrunbo921@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/69/af/0e3942fb050404a9d62e47d3efcc4a5196aac99834260ee5950676878944/AmazonPayClient-2.0.1.tar.gz",
    "platform": null,
    "description": "# Amazon Pay API SDK (Python)\n\nAmazon Pay Integration.\n\nPlease note this is a **Non-Official** Amazon Pay Python SDK and can only be used for API calls to the\n**_pay-api.amazon.com|eu|jp_** endpoint.\n\nFor more details about the api, please check\nthe [Official Documentation for developers](https://developer.amazon.com/docs/amazon-pay/intro.html).\n\n## Requirements\n\n* Python 3.x\n* requests >= 2.28.1\n* pycryptodome >= 3.16.0\n\n## SDK Installation\n\nUse PyPI to install the latest release of the SDK:\n\n```\npip install AmazonPayClient\n```\n\n## Configuration\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='jp',\n    sandbox=True\n)\n```\n\nIf you have created environment specific keys (i.e. Public Key Starts with LIVE or SANDBOX) in Seller Central, then use\nthose PublicKeyId & PrivateKey. In this case, there is no need to pass the sandbox parameter to the configuration.\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='jp',\n)\n```\n\n# Versioning\n\nThe pay-api.amazon.com|eu|jp endpoint uses versioning to allow future updates. The major version of this SDK will stay\naligned with the API version of the endpoint.\n\nIf you have downloaded version 2.x.y of this SDK, the API version would be \"v2\".\n\nIf you need to use a \"v1\" version of Amazon Pay API,\nseek [Official Documentation](https://developer.amazon.com/docs/amazon-pay/intro.html) for help.\n\n# Convenience Functions (Overview)\n\nMake use of the built-in convenience functions to easily make API calls. Scroll down further to see example code\nsnippets.\n\nWhen using the convenience functions, the request payload will be signed using the provided private key, and a HTTPS\nrequest is made to the correct regional endpoint.\n\n## Alexa Delivery Trackers API\n\n[Delivery Trackers API Guide](https://developer.amazon.com/docs/amazon-pay-api-v2/delivery-tracker.html)\n\n* Create Delivery Tracker - **create_delivery_tracker**(body: dict)\n\n## Amazon Checkout v2 API\n\n[API Integration Guide](https://amazonpaycheckoutintegrationguide.s3.amazonaws.com/amazon-pay-api-v2/introduction.html)\n\n### Buyer\n\n[Buyer API Guide](https://developer.amazon.com/docs/amazon-pay-api-v2/buyer.html)\n\n* Get Buyer - **get_buyer**(buyer_token: str)\n\n### Checkout Session\n\n[Checkout Session API Guide](https://developer.amazon.com/docs/amazon-pay-api-v2/checkout-session.html)\n\n* Create Checkout Session - **create_checkout_session**(body: dict)\n* Get Checkout Session - **get_checkout_session**(checkout_session_id: str)\n* Update Checkout Session - **update_checkout_session**(checkout_session_id: str, body: dict)\n* Complete Checkout Session - **complete_checkout_session**(checkout_session_id: str, body: dict)\n\n### Charge Permission\n\n[Charge Permission API Guide](https://developer.amazon.com/docs/amazon-pay-api-v2/charge-permission.html)\n\n* Get Charge Permission - **get_charge_permission**(charge_permission_id: str)\n* Update Charge Permission - **update_charge_permission**(charge_permission_id: str, body: dict)\n* Close Charge Permission - **close_charge_permission**(charge_permission_id: str, body: dict)\n\n### Charge\n\n* Create Charge - **create_charge**(body: dict)\n* Get Charge - **get_charge**(charge_id: str)\n* Capture - **capture_charge**(charge_id: str, body: dict)\n* Cancel Charge - **cancel_charge**(charge_id: str, body: dict)\n\n### Refund\n\n* Create Refund - **create_refund**(body: dict)\n* Get Refund - **get_refund**(refund_id: str)\n\n# Convenience Functions Code Samples\n\n## Alexa Delivery Notifications\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=False\n)\n\nbody = {\n    'amazonOrderReferenceId': 'P00-0000000-0000000',\n    'deliveryDetails': [\n        {\n            'carrierCode': 'UPS',\n            'trackingNumber': '1Z999AA10123456784'\n        }\n    ]\n}\n\nresponse = client.create_delivery_tracker(body)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Create Checkout Session\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\nbody = {\n    'webCheckoutDetails': {\n        'checkoutReviewReturnUrl': 'https://localhost/store/checkout_review',\n        'checkoutResultReturnUrl': 'https://localhost/store/checkout_result'\n    },\n    'storeId': 'YOUR_STORE_ID'\n}\n\nresponse = client.create_checkout_session(body)\n\nif response.status_code == 201:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Get Checkout Session\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncheckout_session_id = '00000000-0000-0000-0000-000000000000'\n\nresponse = client.get_checkout_session(checkout_session_id)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Update Checkout Session\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncheckout_session_id = '00000000-0000-0000-0000-000000000000'\nbody = {\n    'paymentDetails': {\n        'chargeAmount': {\n            'amount': '100',\n            'currencyCode': 'JPY'\n        }\n    }\n}\n\nresponse = client.update_checkout_session(checkout_session_id, body)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Complete Checkout Session\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncheckout_session_id = '00000000-0000-0000-0000-000000000000'\nbody = {\n    'chargeAmount': {\n        'amount': '100',\n        'currencyCode': 'JPY'\n    }\n}\n\nresponse = client.complete_checkout_session(checkout_session_id, body)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Get Charge Permission\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncharge_permission_id = 'S00-0000000-0000000'\n\nresponse = client.get_charge_permission(charge_permission_id)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Update Charge Permission\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncharge_permission_id = 'S00-0000000-0000000'\nbody = {\n    'merchantMetadata': {\n        'merchantReferenceId': '00-00-000000-00',\n        'merchantStoreName': 'Test Store',\n        'noteToBuyer': 'Some Note to buyer',\n        'customInformation': 'Custom Information'\n    }\n}\n\nresponse = client.update_charge_permission(charge_permission_id, body)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Close Charge Permission\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncharge_permission_id = 'S00-0000000-0000000'\nbody = {\n    'closureReason': 'No more charges required',\n    'cancelPendingCharges': False\n}\n\nresponse = client.close_charge_permission(charge_permission_id, body)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Create Charge\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\nbody = {\n    'chargePermissionId': 'S00-0000000-0000000',\n    'chargeAmount': {\n        'amount': '100',\n        'currencyCode': 'JPY'\n    },\n    'captureNow': True\n}\n\nresponse = client.create_charge(body)\n\nif response.status_code == 201:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Get Charge\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncharge_id = 'S00-0000000-0000000-C000000'\n\nresponse = client.get_charge(charge_id)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Capture Charge\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncharge_id = 'S00-0000000-0000000-C000000'\nbody = {\n    'captureAmount': {\n        'amount': '100',\n        'currencyCode': 'JPY'\n    }\n}\n\nresponse = client.capture_charge(charge_id, body)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Cancel Charge\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\ncharge_id = 'S00-0000000-0000000-C000000'\nbody = {\n    'cancellationReason': 'REASON DESCRIPTION'\n}\n\nresponse = client.cancel_charge(charge_id, body)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Create Refund\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\nbody = {\n    'chargeId': 'S00-0000000-0000000-C000000',\n    'refundAmount': {\n        'amount': '100',\n        'currencyCode': 'JPY'\n    },\n}\n\nresponse = client.create_refund(body)\n\nif response.status_code == 201:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n## Amazon Checkout v2 - Get Refund\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\nrefund_id = 'S00-0000000-0000000-R000000'\n\nresponse = client.get_refund(refund_id)\n\nif response.status_code == 200:\n    # success\n    result = response.json()\n    print(result)\nelse:\n    # check the error\n    print('Status Code: ' + str(response.status_code) + '\\n' + 'Content: ' + response.content.decode(encoding='utf-8') + '\\n')\n```\n\n# Generate Button Signature (helper function)\n\nThe signatures generated by this helper function are only valid for the Checkout v2 front-end buttons. Unlike API\nsigning, no timestamps are involved, so the result of this function can be considered a static signature that can safely\nbe placed in your website JS source files and used repeatedly (as long as your payload does not change).\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\npayload = '{\"webCheckoutDetails\": {\"checkoutResultReturnUrl\": \"https://localhost/store/checkout_result\", \"checkoutMode\": \"ProcessOrder\"}, \"chargePermissionType\": \"OneTime\", \"paymentDetails\": {\"paymentIntent\": \"Confirm\", \"chargeAmount\": {\"amount\": \"100\", \"currencyCode\": \"JPY\"}}, \"storeId\": \"YOUR_STORE_ID\"}'\n\nsignature = client.generate_button_signature(payload)\n```\n\nYou can also use a _dict_ as your payload. But make sure the `json.dumps(payload)` result matches the one you are using\nin your button, such as spaces etc.\n\n```python\nfrom AmazonPay import Client\n\nclient = Client(\n    public_key_id='YOUR_PUBLIC_KEY_ID',\n    private_key='keys/private.pem',\n    region='us',\n    sandbox=True\n)\n\npayload = {\n    'webCheckoutDetails': {\n        'checkoutResultReturnUrl': 'https://localhost/store/checkout_result',\n        'checkoutMode': 'ProcessOrder'\n    },\n    'chargePermissionType': 'OneTime',\n    'paymentDetails': {\n        'paymentIntent': 'Confirm',\n        'chargeAmount': {\n            'amount': '100',\n            'currencyCode': 'JPY'\n        }\n    },\n    'storeId': 'YOUR_STORE_ID'\n}\n\nsignature = client.generate_button_signature(payload)\n```\n\n",
    "bugtrack_url": null,
    "license": "Apache License version 2.0, January 2004",
    "summary": "A non-official Amazon Pay Python SDK",
    "version": "2.0.1",
    "split_keywords": [
        "amazon",
        "payments",
        "python",
        "api",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2c9c6684027e19aef74685fb6ad8a51f5501f12371364121044ccb0d6a0da37",
                "md5": "dda832af68419d26f2dc1556227bb65d",
                "sha256": "35d1ad420beab032788b919e344e7ce003129b0cd36afd625f9d23386bff4c0f"
            },
            "downloads": -1,
            "filename": "AmazonPayClient-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dda832af68419d26f2dc1556227bb65d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13346,
            "upload_time": "2023-01-03T09:33:27",
            "upload_time_iso_8601": "2023-01-03T09:33:27.201713Z",
            "url": "https://files.pythonhosted.org/packages/f2/c9/c6684027e19aef74685fb6ad8a51f5501f12371364121044ccb0d6a0da37/AmazonPayClient-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69af0e3942fb050404a9d62e47d3efcc4a5196aac99834260ee5950676878944",
                "md5": "2800b16db29a5d490a9d02c53c32bc4d",
                "sha256": "d902d4f51706dfe7028cfe5c3cbfda843da2d5e6e471825049cc4de8de61d73c"
            },
            "downloads": -1,
            "filename": "AmazonPayClient-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2800b16db29a5d490a9d02c53c32bc4d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15402,
            "upload_time": "2023-01-03T09:33:28",
            "upload_time_iso_8601": "2023-01-03T09:33:28.959298Z",
            "url": "https://files.pythonhosted.org/packages/69/af/0e3942fb050404a9d62e47d3efcc4a5196aac99834260ee5950676878944/AmazonPayClient-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-03 09:33:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "wangrunbo",
    "github_project": "amazon-pay-api-sdk-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "amazonpayclient"
}
        
Elapsed time: 0.09470s