123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <template>
- <div>
- <h2>申泽智能</h2>
- <button @click="redirectHpp()">Redirect to HPP</button>
- </div>
- </template>
- <script>
- import { redirectToCheckout, loadAirwallex } from 'airwallex-payment-elements';
- import { useRoute } from "vue-router";
- export default {
- name: 'Hpp',
-
- setup() {
- const mode = 'payment';
- const route = useRoute();
- // const router = useRouter();
- console.log(route.query.intent_id)
- const redirectHppForCheckout = () => {
- redirectToCheckout({
- env: 'demo',
- mode,
- currency: route.query.currency,
- intent_id: route.query.intent_id,
- client_secret: route.query.client_secret,
- //主题
- theme: {
- fonts: [
- {
- src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',
- family: 'AxLLCircular',
- weight: 400,
- },
- ],
- },
- // successUrl: 'https://www.baidu.com', // 支付成功跳转页面
- // failUrl: 'https://www.baidu.com', // 支付失败跳转页面
- logoUrl: '', //支付页面展示商户LOGO
- });
- };
- const redirectHppForRecurring = () => {
- redirectToCheckout({
- env: 'demo',
- // mode,
- // currency,
- // client_secret,
- recurringOptions: {
- card: {
- next_triggered_by: 'customer',
- merchant_trigger_reason: 'scheduled',
- // currency,
- },
- },
- theme: {
- fonts: [
- {
- src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',
- family: 'AxLLCircular',
- weight: 400,
- },
- ],
- },
- // successUrl: 'https://www.google.com',
- // failUrl: 'https://www.google.com',
- });
- };
- loadAirwallex({
- env: 'demo', // Can choose other production environments, 'staging | 'demo' | 'prod'
- });
- const redirectHpp = async () => {
- try {
- await loadAirwallex({
- env: 'demo',
- });
- if (mode === 'payment') {
- redirectHppForCheckout();
- } else if (mode === 'recurring') {
- redirectHppForRecurring();
- }
- } catch (error) {
- window.alert('There was an error with HPP redirection', error);
- }
- };
- return {
- redirectHpp,
- redirectHppForCheckout,
- redirectHppForRecurring
- };
- }
- };
- /* const intent_id = this.$route.query.intent_id;
- const client_secret = 'replace-with-your-client-secret';
- const currency = 'replace-with-your-currency';
- const mode = 'payment';
- // console.log(this.intent_id);
- const redirectHppForCheckout = () => {
- redirectToCheckout({
- env: 'demo',
- mode,
- currency,
- intent_id,
- client_secret,
- //主题
- theme: {
- fonts: [
- {
- src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',
- family: 'AxLLCircular',
- weight: 400,
- },
- ],
- },
- successUrl: 'https://www.baidu.com', // 支付成功跳转页面
- failUrl: 'https://www.baidu.com', // 支付失败跳转页面
- logoUrl: '', //支付页面展示商户LOGO
- });
- };
- const redirectHppForRecurring = () => {
- redirectToCheckout({
- env: 'demo',
- mode,
- currency,
- client_secret,
- recurringOptions: {
- card: {
- next_triggered_by: 'customer',
- merchant_trigger_reason: 'scheduled',
- currency,
- },
- },
- theme: {
- fonts: [
- {
- src: 'https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2',
- family: 'AxLLCircular',
- weight: 400,
- },
- ],
- },
- successUrl: 'https://www.google.com',
- failUrl: 'https://www.google.com',
- });
- };
- loadAirwallex({
- env: 'demo', // Can choose other production environments, 'staging | 'demo' | 'prod'
- });
- const redirectHpp = async () => {
- try {
- await loadAirwallex({
- env: 'demo',
- });
- if (mode === 'payment') {
- redirectHppForCheckout();
- } else if (mode === 'recurring') {
- redirectHppForRecurring();
- }
- } catch (error) {
- window.alert('There was an error with HPP redirection', error);
- }
- };
- export default {
- name: 'Hpp',
- data() {
- return {
- redirectHpp,
- msg: this.$route.query.intent_id,
- intent_id: this.$route.query.intent_id,
- client_secret: this.$route.query.client_secret,
- currency: this.$route.query.currency
- };
- },
- }; */
- </script>
|