|
| 1 | +# Welcome to FasterPay Python SDK |
| 2 | + |
| 3 | +FasterPay Python SDK enables you to integrate the FasterPay's Checkout Page seamlessly without having the hassle of integrating everything from Scratch. |
| 4 | +Once your customer is ready to pay, FasterPay will take care of the payment, notify your system about the payment and return the customer back to your Thank You page. |
| 5 | + |
| 6 | +## Downloading the FasterPay Python SDK |
| 7 | + |
| 8 | +```sh |
| 9 | +$ git clone https://github.com/FasterPay/fasterpay-python3.git |
| 10 | +``` |
| 11 | + |
| 12 | +## Installing the FasterPay Python SDK. |
| 13 | +```sh |
| 14 | +$ cd fasterpay-python3 |
| 15 | +$ sudo python setup.py install |
| 16 | +``` |
| 17 | + |
| 18 | +## Initiating Payment Request using Python SDK |
| 19 | + |
| 20 | +```python |
| 21 | +from fasterpay.gateway import Gateway |
| 22 | + |
| 23 | +if __name__ == "__main__": |
| 24 | + |
| 25 | + gateway = Gateway("<your private key>", "<your public key>", True) |
| 26 | + |
| 27 | + parameters = { |
| 28 | + "payload": { |
| 29 | + "description": "Golden Ticket", |
| 30 | + "amount": "0.01", |
| 31 | + "currency": "EUR", |
| 32 | + "merchant_order_id": str(random.randint(1000, 9999)), |
| 33 | + "success_url": "https://4f9f73c1.ngrok.io/success", |
| 34 | + "sign_version": "v2", |
| 35 | + "pingback_url": "https://4f9f73c1.ngrok.io/pingback", |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + paymentForm = gateway.payment_form().build_form(parameters) |
| 40 | + print paymentForm |
| 41 | +``` |
| 42 | + |
| 43 | +For more information on the API Parameters, refer to our entire API Documentation [here](https://docs.fasterpay.com/api#section-custom-integration) |
| 44 | + |
| 45 | +## Handling FasterPay Pingbacks |
| 46 | + |
| 47 | +```python |
| 48 | +from flask import request |
| 49 | +from fasterpay.gateway import FP_Gateway |
| 50 | +gateway = Gateway("<your private key>", "<your public key>", True) |
| 51 | +pingback_data = request.get_data() |
| 52 | +if request.headers.get("X-Fasterpay-Signature-Version") == "v2": |
| 53 | + headers = { |
| 54 | + "X-Fasterpay-Signature": str(request.headers.get("X-Fasterpay-Signature")), |
| 55 | + "X-Fasterpay-Signature-Version": str(request.headers.get("X-Fasterpay-Signature-Version")) |
| 56 | + } |
| 57 | +else: |
| 58 | + headers = { |
| 59 | + "X-ApiKey": str(request.headers.get("X-ApiKey")) |
| 60 | + } |
| 61 | + |
| 62 | +if gateway.pingback().validate(pingback_data, headers) is True: |
| 63 | + return "OK" |
| 64 | +else: |
| 65 | + return "NOK" |
| 66 | +``` |
| 67 | + |
| 68 | +## FasterPay Test Mode |
| 69 | +FasterPay has a Sandbox environment called Test Mode. Test Mode is a virtual testing environment which is an exact replica of the live FasterPay environment. This allows businesses to integrate and test the payment flow without being in the live environment. Businesses can create a FasterPay account, turn on the **Test Mode** and begin to integrate the widget using the test integration keys. |
| 70 | + |
| 71 | +### Initiating FasterPay Gateway in Test-Mode |
| 72 | +```python |
| 73 | +from fasterpay.gateway import Gateway |
| 74 | +gateway = Gateway("<your private key>", "<your public key>", True) |
| 75 | +``` |
| 76 | + |
| 77 | +### Questions? |
| 78 | +* Common questions are covered in the [FAQ](https://www.fasterpay.com/support). |
| 79 | +* For integration and API questions, feel free to reach out Integration Team via [integration@fasterpay.com](mailto:integration@fasterpay.com) |
| 80 | +* For business support, email us at [merchantsupport@fasterpay.com](mailto:merchantsupport@fasterpay.com) |
| 81 | +* To contact sales, email [sales@fasterpay.com](mailto:sales@fasterpay.com). |
0 commit comments