### Authorization As described in [Getting started with the Shop Pay Wallet](/docs/api/shop-pay-wallet/getting-started), the flow starts by asking the buyer to [authorize your app](/docs/api/shop-pay-wallet/getting-started#authorize-your-app-with-shop-pay-wallet) to access their wallet. Completing this flow will provide you with an OAuth 2.0 Access Token unique to you and the buyer. This token is required to place an order. ### Wallet requests With that `access_token` you can [fetch the buyer's wallet](/docs/api/shop-pay-wallet/reference#get-a-users-wallet-information). The wallet can contain the last four digits, the network (VISA, Mastercard, ...), and the type (credit or debit) of the buyer's credit card as well as the buyer's shipping address, depending on the requested scopes. Note that the wallet does not contain the _billing address_ of the buyer's credit card. ### Retrieve payment details You can then [confirm the order and retrieve payment information](/docs/api/shop-pay-wallet/getting-started#confirm-an-order-and-retrieve-payment-information) with your internal partner order IDs, as well as the `tokenization_type` `PAYMENT_CREDENTIAL` or `SESSION`. As mentioned in the [scopes guide](/docs/api/shop-pay-wallet/scopes), for Shopify merchants you must ask for `SESSION` whereas for non-Shopify merchants you must ask for `PAYMENT_CREDENTIAL`. The latter requires that you are PCI-compliant. If you ask for `PAYMENT_CREDENTIAL`, you will receive the buyer's billing address and encrypted PAN. If the credit card supports network tokenization, you will receive a network token along with a cryptogram in place of the PAN. You can use those to process the payment on your own platform. If you ask for `SESSION`, you will receive the buyer's billing address and a Session ID. You can use those to process the payment on the Shopify platform. Refer to this fragment of a [successful response](/docs/api/shop-pay-wallet/reference#for-tokenization_type-session) to see the billing address and the Session ID `west-a1584d23a51970fb8065ec71c34d25db`: ```JSON { ... "card": { ... "billingAddress": { # the Billing Address "addressLine": [ "123 High Street" ], "city": "Mont Royal", "country": "CA", "dependentLocality": "", "organization": "", "phone": "+15145551212", "postalCode": "123456", "recipient": "Jane Doe", "region": "QC", "sortingCode": "" }, ... }, "payment": { "paymentSessionId": "west-a1584d23a51970fb8065ec71c34d25db" # the Session ID }, ... } ``` ### Create checkout and payment You can use the billing address you received in the previous step, along with the buyer's email address or phone number, to [create a checkout](/docs/api/admin-rest/latest/resources/checkout.html). This will give you a checkout token. Use this checkout token, together with the Session ID `west-a1584d23a51970fb8065ec71c34d25db` that you received from the [confirm the order API](/docs/api/shop-pay-wallet/getting-started#confirm-an-order-and-retrieve-payment-information), to [create a payment](/docs/api/admin-rest/latest/resources/payment.html). Note that you can use this Session ID at most once and the Session ID is valid for at most 1 hour. This summarizes the above flow: ![Shop pay diagram](/assets/api/shop-pay/shop-pay-in-shopify-eco.png) ## Related resources - [Getting Started with the Shop Pay Wallet API](/docs/api/shop-pay-wallet/getting-started) - [Authorization](/docs/api/shop-pay-wallet/authorization) - [Shop Pay Wallet API reference](/docs/api/shop-pay-wallet/reference/index) - [Testing the integration](/docs/api/shop-pay-wallet/testing) - REST Admin API's [`Checkout`](/docs/api/admin-rest/latest/resources/checkout) resource. - REST Admin API's [`Payment`](/docs/api/admin-rest/latest/resources/payment) resource. - REST Admin API's [`Order`](/docs/api/admin-rest/latest/resources/order) resource.