Giter VIP home page Giter VIP logo

airwallex-payment-demo's Introduction

Airwallex Payment Demo

The purpose of this project is to demonstrate how Airwallex payment element can be integrated with different web frameworks. Demos in each framework demonstrate each of the various payment acceptance methods merchants can use.

Our goal is to make it easy for you (Merchants) to use our platform, as easy as a copy-paste!

Before getting start, check out what the Airwallex Checkout elements look like here: https://demo-pacheckoutdemo.airwallex.com/.

Questions, comments, or suggestions?

Running into issues? Check out some of the common errors and our troubleshooting tips here.

Let us know if you run into problems, or have any comments and suggestions for us. We value your input!

Creating a Payment Intent

Throughout this demo, you will be asked to insert your intent secrets to properly enact a payment checkout, more details can be found in the Airwallex API.

Navigating this project

So far, integrations are done with the following frameworks. You can find the installation and development instructions within its subfolder.

API integration:

Frontend integration:

Other Integrations

For those using Next.js as their web framework, feel free to see the React/React Typescript examples.

Sandboxes

You also can play around with the different web integrations with the sandboxes below:

airwallex-payment-demo's People

Contributors

awx-luke-lu avatar awx-yifan-leng avatar carl-jin-awx avatar chao-ding-awx avatar charlielangcl avatar olivia-wei-awx avatar reshmaserrao-awx avatar royyangs avatar sherry-zhao-awx avatar shirly-chen-awx avatar tjmcewan avatar yifan-leng-awx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

airwallex-payment-demo's Issues

Many problems with react examples

The react example:

  1. is missing dep axios
  2. will not compile because the .eslintrc.js tells prettier to error if not using single quotes, but double quotes are used throughout the example
  3. several variables in Card.jsx aren't declared properly (e.g. onFocus, onBlur)
  4. inputErrorMessage isn't included in useEffect's dep array in SplitCard.jsx

The react-ts example:

  1. won't npm install without --force because the versions of react-scripts & typescript conflict
  2. won't compile with the args passed to redirectToCheckout or createElement; tried to fix this but ended up getting confusion between id & intent_id so I think maybe it's just using an old version of the lib or types?

Return URL not respected for PaymentIntent

Describe the bug
Setting the return_url when creating a payment intent does not redirect the user back to that location after successful payment.

To Reproduce Steps to reproduce the behavior, better to provide the link to reproduce:

  1. Generate a payment link with the demo api
  2. Set the return_url
  3. Complete a payment on the HPP related to the payment link
  4. You are not redirected back to the return_url set in step #2

Expected behavior
You are redirected to the correct page.

Screenshots If applicable, add screenshots to help explain your problem.

Integration information:

  • language

    • angular
    • cdn - npm
    • node
    • react
    • react-ts
    • ReactNative
    • vue
  • element

    • hpp
    • dropIn element
    • card element
    • split card element
    • full featured card element
    • applePay element
    • googlePay element
      Contexts:
  • Integration env (e.g. demo): Demo

  • IntentId:

  • Device (e.g. iPhone12):

  • OS (e.g. iOS8.1):

  • Browser (e.g. stock browser, safari):

  • Language:

Additional context Add any other context about the problem here.

Docs could be improved to indicate how to show order summary

I recently went through the docs for the Hosted Payments Page and after setting up my server to create the Payment Intent, it was confusing why there was no order summary on the left despite the gif in the demo page showing one.

After reading the API docs a bit more for the payment intent, and what I gather is that there is an "order" field that needs to be populated with this information. I think this should be expressed somewhere in these integration docs.

https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/_api_v1_pa_payment_intents_create/post

React Documentation could be clearer

We are currently trying to integrate your React frontend

 const intent_id = "int_hkdmxqfgmgb1vkaeror";
 const client_secret = "GUESSING API KEY";
 const customer_id = "cus_hkdmpnqs7gb1swg8p2g";
 const currency = "AUD";
 const env = "demo";
 const next_triggered_by = "merchant";

Now if I am correct the client_secret is where we put our API key, however we have done that using our demo airwallex account and we get the following error

{
    "message": "Access denied, authentication failed",
    "code": "unauthorized"
}

Now we are localhost testing, but I would not expect that to be the issue in this case.

We have copied and pasted the sample code from
https://codesandbox.io/s/airwallex-payment-demo-react-2m63j?file=/src/components/SplitCardRecurring.jsx

Update

Seems that client_secret is more than just the API key (which by the way needs to be authenticated before it is used in this plugin)

As now I am getting the following error

{
    "code": "validation_error",
    "message": "No 'customer_id' in client secret"
}

So steps to reproduce.

Step 1) take your API key and create session

curl --location --request POST 'https://api-demo.airwallex.com/api/v1/authentication/login' \
--header 'Content-Type: application/json' \
--header 'x-api-key: API KEY' \
--header 'x-client-id: CLIENT-KEY'

Step 2)

curl --location --request POST 'https://api-demo.airwallex.com/api/v1/pa/payment_methods/create' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json, text/plain, */*' \
--header 'Accept-Language: en-AU,en;q=0.9' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Origin: https://checkout-demo.airwallex.com' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15' \
--header 'Referer: https://checkout-demo.airwallex.com/' \
--header 'Content-Length: 197' \
--header 'Connection: keep-alive' \
--header 'Host: pci-api-demo.airwallex.com' \
--header 'client-secret: (AUTH KEY FROM STEP 1)' \
--header 'Priority: u=3, i' \
--header 'x-api-version: 2021-11-25' \
--header 'x-client-ip-source: awx-checkout' \
--header 'Awx-Tracker: 6251a8c0-23cb-47d0-a0da-ce9bc0fcd7fb' \
--data-raw '{"type":"card","card":{"number":"4111111111111111","cvc":"111","expiry_month":"10","expiry_year":"2022"},"customer_id":"cus_hkdmpnqs7gb1swg8p2g","request_id":"3c7541fc-a430-41b7-9a33-fc9b23615d58"}'

However the issue is that because it does not include the customer ID it fails.

How to create client_secret

So we worked out that the react plugin is not a simple include and run system. You still need to do a number of steps before you can use this plugin.

This should be documented clearer on this plugin (note all codes are in postman curl you can convert to node JS easy):

Step 1) Authenticate yourself by running

curl --location --request POST 'https://api-demo.airwallex.com/api/v1/authentication/login' \
--header 'Content-Type: application/json' \
--header 'x-api-key:API KEY' \
--header 'x-client-id: CLIENT KEY'

Step 2) Create the customer if they are not already in your system

curl --location --request POST 'https://api-demo.airwallex.com/api/v1/pa/customers/create' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer KEY FROM RESPONSE FROM STEP 1' \
--data-raw '{ 
  "additional_info": { 

    "registered_via_social_media": false, 
    "registration_date": "2022-06-25" 
  }, 
  "address": { 
    "city": "ADDRESS", 
    "country_code": "AU", 
    "postcode": "POSTCODE", 
    "state": "Western Australia", 
    "street": "STREET ADDRESS" 
  }, 
  "business_name": "INSERT BUSINESS NAME", 
  "email": "THERE EMAIL ", 
  "merchant_customer_id": "USER/CUSTOMER ID", 
  "phone_number": "CUSTOMER PH NUMBER", 
  "request_id": "RANDOM UUIDV4" 
}'

Step 3) Create payment intent

curl --location --request POST 'https://api-demo.airwallex.com/api/v1/pa/payment_intents/create' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer KEY FROM RESPONSE FROM STEP ' \
--data-raw '{ 
  "amount": 200.00, 
  "currency": "AUD", 
  "customer_id": "CUSTOMER ID FROM AIRWALLEX", 
  "descriptor": "DESCRIPTION", 
  "merchant_order_id": "USER/CUSTOMER ID", 
  "order": { 
    "products": [ 
      { 
        "code": "7719", 
        "desc": "DESCRIPTION OF PRODUCT", 
        "name": "NAME OF PRODUCT", 
        "quantity": 1, 
        "type": "virtual_goods", 
        "unit_price": 200.00, 
        "url": "PRODUCT URL" 
      } 
    ], 
    "supplier": { 
      "address": { 
        "city": "CITY", 
        "country_code": "AU", 
        "postcode": "POSTCODE", 
        "state": "STATE", 
        "street": "STREET ADDRESS" 
      }
    }, 
    "type": "virtual_goods" 
  }, 
  "payment_method_options": { 
    "card": { 
      "risk_control": { 
        "skip_risk_processing": true, 
        "three_domain_secure_action": "FORCE_3DS", 
        "three_ds_action": "FORCE_3DS" 
      }, 
      "three_ds_action": "FORCE_3DS" 
    } 
  }, 
  "request_id": "RANDOM UUID", 
  "return_url": "URL", 
  "risk_control_options": { 
    "skip_risk_processing": false
  } 
}'

Once you have done all those steps you should be able to get the response from that query and use it to create the card payment - However while I was able to accessfully do it via the postman, when I tried to do it by the embedded form I got the following which I don't fully understand.

{
    "code": "invalid_status_for_operation",
    "message": "The PaymentIntent status SUCCEEDED is invalid for operation confirm."
}

can't confirm payment intent when adding payment_consent_id

Describe the bug I am trying to make a payment transaction using the customer's existing payment method using consent. I can't confirm payment intent if I add a payment_consent_id instead of element but the confirmPaymentElement() method still looking for the element eventhough I use a payment_consent_id

To Reproduce

  1. On triggerConfirm() function, update the confirmPaymentIntent to:

confirmPaymentIntent({
payment_consent_id: 'your_payment_consent_id'
id: intent_id,
client_secret,
},
})

Expected behavior This should confirm the paymentIntent

Screenshots
image

Integration information:

  • language

    • angular
    • cdn
    • node
    • react
    • react-ts
    • ReactNative
    • vue
  • element

    • hpp
    • dropIn element
    • card element
    • split card element
    • full featured card element
    • applePay element
    • googlePay element
      Contexts:
  • Browser (e.g. stock browser, safari):

  • Language:

'onChange' listener not working and 'onReady' was triggered even the dropIn iframe not shown on the screen.

I am using vue to integrated dropIn element, while im trying to add listeners, I found that only 'onReady', 'onError', 'onSuccess' works fine. Nothing happened when im trying 'onChange' if i'd like to know if user type in any information via card method of dropIn element.
Btw, after init the dropIn element, onReady method told me the mount is finished and rendered, but I found that onReady will show me a positive response even the dropIn iframe not shown on the screen.
Please advice, thanks in advance.

This question is related to:

  • language

    • vue
  • element

    • dropIn element

3ds popup

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior, better to provide the link to reproduce:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Integration information:

  • language

    • angular
    • cdn
    • node
    • [ x] react
    • react-ts
    • ReactNative
    • vue
  • element

    • hpp
    • dropIn element
    • [ร— ] card element
    • split card element
    • full featured card element
    • applePay element
    • googlePay element
      Contexts:
  • Integration env (e.g. demo):demo

  • IntentId:

  • Device (e.g. iPhone12):

  • OS (e.g. iOS8.1):

  • Browser (e.g. stock browser, safari):

  • Language:

Additional context Add any other context about the problem here.

There is an error when adding 3ds card and making a transaction when the transaction is successful, the white screen will show after transaction is successfull and no transaction results are returned. test card: 4012000300000062

PHP integration

Hi I see that you have PHP integration as a coming-soon - is the intention to make an Omnipay or Payum module that we can use?

I'm considering using your payment gateway for my custom ecommerce platform (on https://www.sanchia.com.au ) but wanting to know how far away your PHP integration is or whether I'm better to write something myself.

If I write something myself I'm more than happy to release as open source so other PHP projects can use it.

Subscription payments

Is there away to handle subscriptions via this plugin?

This question is related to:

  • language

    • [x ] react-ts
  • element

    • hpp
    • [ x] dropIn element
    • card element
    • split card element
    • full featured card element
    • applePay element
    • googlePay element

Airwallex.RedirectToCheckout produces "undefined" error on Hosted Payment Page

Version
Using https://checkout.airwallex.com/assets/elements.bundle.min.js as import is failing, refer to #75

Issue

Our call looks like the below:

          Airwallex.redirectToCheckout({
            env: 'demo', // Which env('staging' | 'demo' | 'prod') you would like to integrate with
            intent_id: data.id,
            client_secret: data.client_secret,
            currency: 'AUD',
          });

RedirectToCheckout produces a blank airwallex page: https://checkout-demo.airwallex.com/#/standalone/checkout/undefined?currency=AUD&from=http://localhost:3000&sessionId=bfbdec2c-ad2c-4766-a178-de22f13e7627

Screenshot 2023-04-03 at 5 37 31 pm

Notes

Sidenote: attempting to use versioned hosted bundles that are versioned, e.g. https://checkout.airwallex.com/assets/bundle.0.2.103.min.js - does not appear to work as expected as this serves a HTML page, not the library.

payment_method.type must be provided

Hello

I create a Paymen Intent as follows
{ "amount": 100.01, "currency": "USD", "merchant_order_id": "126", "payment_method_options": { "card": { "risk_control": { "skip_risk_processing": false, "three_domain_secure_action": "FORCE_3DS", "three_ds_action": "FORCE_3DS" }, "three_ds_action": "FORCE_3DS" } }, "request_id": "126", "return_url": "http://www.example.com" }
Then I make the confirm API call
The return I get is:
{ "code": "validation_error", "source": "payment_method.type", "message": "payment_method.type must be provided" }
In the API description I don't see the parameter payment_method description!!!
Please tell me why and how to fix it

Error: Forbidden

"Error: Forbidden
Your client does not have permission to get URL /assets/elements.bundle.min.js from this server."

This error is showing in Japan when accessing https://checkout.airwallex.com/assets/elements.bundle.min.js.

My Japanese customers are not able to make payment on my website using Airwallex because script is not accessible so it is showing error.
Screenshot_247

Failed to chage the return_url when using Split Card payment elements

Describe the bug
I have started to integrate the Split Card from airwallex-payment-elements,
but failed to change the return_url when 3DS is triggered.

I am testing with https://api-demo.airwallex.com.

To Reproduce

  1. Create the payment intent with https://api-demo.airwallex.com/api/v1/pa/payment_intents/create
{
    "amount": 10,
    "currency": "HKD",
    "merchant_order_id": "TEST-ID",
    "request_id": "REQUEST_ID",
    "payment_method_options": {
        "card": {
            "three_ds_action": "FORCE_3DS"
        }
    },
    "return_url": "http://www.example.com"
}
  1. Enter the Card Number, Expiry Date, CVC to the split card element
  2. Confirm the payment intent with
await confirmPaymentIntent({
                    element: cardNumElement,
                    id: "INTENT_ID",
                    client_secret: "CLIENT_SECRET",
                    payment_method_options: {
                        card: {
                            auto_capture: true,
                            three_ds: {
                                return_url: 'http://www.example.com'
                            }
                        },
                    }
                })
  1. User is not redirected to http://www.example.com after confirming the payment intent

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Integration information:

  • language

    • vue
  • element

    • split card element

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.