pay
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
"vue-cropperjs": "^3.0.0",
|
"vue-cropperjs": "^3.0.0",
|
||||||
"vue-i18n": "^8.10.0",
|
"vue-i18n": "^8.10.0",
|
||||||
|
"vue-paypal-checkout": "^3.2.0",
|
||||||
"vue-pdf": "^4.3.0",
|
"vue-pdf": "^4.3.0",
|
||||||
"vue-quill-editor": "^3.0.6",
|
"vue-quill-editor": "^3.0.6",
|
||||||
"vue-router": "^3.0.3",
|
"vue-router": "^3.0.3",
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<paypal-checkout
|
||||||
|
:client="paypalClient"
|
||||||
|
:amount="amount"
|
||||||
|
:currency="currency"
|
||||||
|
@success="onPaymentSuccess"
|
||||||
|
@error="onPaymentError"
|
||||||
|
>
|
||||||
|
<template #default="{ onClick }">
|
||||||
|
<button @click="onClick">Pay with PayPal</button>
|
||||||
|
</template>
|
||||||
|
</paypal-checkout>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import PaypalCheckout from 'vue-paypal-checkout';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'PayPalButton',
|
||||||
|
components: {
|
||||||
|
PaypalCheckout
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// PayPal Client ID
|
||||||
|
paypalClient: {
|
||||||
|
sandbox: 'Ab8SeEuhkLGp6Fts9V3Cti0UcXQhITRWZkiHDM3U1fDY9YrrRc5IOcYHPfV6qROhmh0hvgysqrfOCSUr', // Replace with your sandbox client ID
|
||||||
|
production: 'Ab8SeEuhkLGp6Fts9V3Cti0UcXQhITRWZkiHDM3U1fDY9YrrRc5IOcYHPfV6qROhmh0hvgysqrfOCSUr' // Replace with your production client ID
|
||||||
|
},
|
||||||
|
amount: '10.00', // Amount to be paid
|
||||||
|
currency: 'USD' // Currency
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onPaymentSuccess(payment) {
|
||||||
|
console.log('Payment successful!', payment);
|
||||||
|
// Handle successful payment here
|
||||||
|
this.$emit('payment-success', payment);
|
||||||
|
},
|
||||||
|
onPaymentError(error) {
|
||||||
|
console.error('Payment error:', error);
|
||||||
|
// Handle payment error here
|
||||||
|
this.$emit('payment-error', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
button {
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #0070ba;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
button:hover {
|
||||||
|
background-color: #005b9a;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
<el-table-column prop="status" :label="$t('pendingPayment.Paymentstatus')" width="140"></el-table-column>
|
<el-table-column prop="status" :label="$t('pendingPayment.Paymentstatus')" width="140"></el-table-column>
|
||||||
<el-table-column label="" width="140">
|
<el-table-column label="" width="140">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
|
||||||
|
<PayPalButton @payment-success="handlePaymentSuccess" @payment-error="handlePaymentError" />
|
||||||
|
|
||||||
<el-button @click="payArticle(scope.row)" plain type="danger" size="mini">{{ $t('pendingPayment.payment') }}</el-button>
|
<el-button @click="payArticle(scope.row)" plain type="danger" size="mini">{{ $t('pendingPayment.payment') }}</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -21,7 +24,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import PayPalButton from './PayPalButton.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
PayPalButton
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
list: {
|
list: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -29,11 +37,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {};
|
||||||
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handlePaymentSuccess(payment) {
|
||||||
|
// Handle payment success
|
||||||
|
console.log('Payment successful!', payment);
|
||||||
|
},
|
||||||
|
handlePaymentError(error) {
|
||||||
|
// Handle payment error
|
||||||
|
console.error('Payment error:', error);
|
||||||
|
},
|
||||||
|
|
||||||
formatAmount(amount) {
|
formatAmount(amount) {
|
||||||
return amount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
return amount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user