Skip to content

Commit

Permalink
docs: add apple pay transformer usage to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ehrdi committed Aug 22, 2024
1 parent 98c72c4 commit cad0cae
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,23 @@ For most [payment methods](https://docs.payone.com/pcp/commerce-platform-payment
When a client is successfully made a payment via ApplePay it receives a [ApplePayPayment](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment). This structure is accessible as the `ApplePayPayment` class. You can use the `ApplePayTransformer` to map an `ApplePayPayment` to a `MobilePaymentMethodSpecificInput` which can be used for payment executions or order requests. The transformer has a static method `transformApplePayPaymentToMobilePaymentMethodSpecificInput()` which takes an `ApplePayPayment` and returns a `MobilePaymentMethodSpecificInput`. The transformer does not check if the response is complete, if anything is missing the field will be set to `null`.

```python
# TODO
from pcp_serversdk_python.models import ApplePayPayment, MobilePaymentMethodSpecificInput
from pcp_serversdk_python.transformer.ApplepayTransformer import transform_apple_pay_payment_to_mobile_payment_method_specific_input
import json

class App:
def get_json_string_from_request_somehow(self):
# Communicate with the client...
message = ""
return message

def prepare_payment_for_apple_pay_payment(self):
payment_json = self.get_json_string_from_request_somehow()
payment = ApplePayPayment(**json.loads(payment_json))
input = transform_apple_pay_payment_to_mobile_payment_method_specific_input(payment)
# Wrap the input into a larger request and send to the PCP API
# ...
...
```

**[back to top](#table-of-contents)**
Expand Down

0 comments on commit cad0cae

Please sign in to comment.