Przeglądaj źródła

fix: [AE-会员端] 修改问题

bill 2 tygodni temu
rodzic
commit
620ec393ea

+ 1 - 2
src/ui-refactor/components/PaymentMethods.vue

@@ -74,8 +74,7 @@
             Pay <strong>{{ money(summary.amount) }}</strong> through Paystack's secure checkout.
           </p>
           <p>
-            Submit the form to continue — you will confirm your email and be taken to the Paystack
-            payment page.
+            Submit the form to continue to the Paystack payment page.
           </p>
         </template>
         <p v-else>Continue with {{ selected.title }} when you place this order.</p>

+ 1 - 33
src/ui-refactor/components/PaystackPaymentDialog.vue

@@ -11,22 +11,6 @@
     v-on="$listeners"
   >
     <p class="ng-paystack-payment-note">{{ note }}</p>
-    <el-form
-      v-loading="loading"
-      class="ng-paystack-payment-form"
-      label-position="top"
-      :disabled="loading"
-      @submit.native.prevent
-    >
-      <el-form-item label="Email" for="ng-paystack-payment-email">
-        <el-input
-          id="ng-paystack-payment-email"
-          :value="email"
-          :readonly="readonlyEmail"
-          @input="$emit('update:email', $event)"
-        />
-      </el-form-item>
-    </el-form>
     <div class="ng-paystack-payment-amount">
       <span>Amount</span>
       <strong>{{ currency }} {{ amount | toThousandFilter }}</strong>
@@ -59,13 +43,11 @@ export default {
     title: { type: String, default: 'Paystack Payment' },
     note: {
       type: String,
-      default: 'Confirm your email to continue to the Paystack secure checkout.'
+      default: 'Continue to the Paystack secure checkout.'
     },
     continueLabel: { type: String, default: 'Continue to Paystack' },
-    email: { type: String, default: '' },
     amount: { type: [Number, String], default: 0 },
     currency: { type: String, default: '' },
-    readonlyEmail: { type: Boolean, default: false },
     loading: { type: Boolean, default: false }
   }
 }
@@ -110,20 +92,6 @@ export default {
   word-break: normal;
   overflow-wrap: break-word;
 }
-.ng-paystack-payment-form ::v-deep .el-form-item {
-  margin-bottom: 0;
-}
-.ng-paystack-payment-form ::v-deep .el-form-item__label {
-  padding-bottom: 8px;
-  color: #25292c;
-  line-height: 1.5;
-}
-.ng-paystack-payment-form ::v-deep .el-input__inner {
-  height: 54px;
-  border-radius: 8px;
-  font-size: 16px;
-  line-height: 54px;
-}
 .ng-paystack-payment-amount {
   display: flex;
   align-items: center;

+ 2 - 2
src/ui-refactor/components/README.md

@@ -27,9 +27,9 @@
 
 三个属性分别为显示状态、原商品对象和币种;关闭通过 `update:visible` 通知调用方。图片及明细用 Element UI `el-row/el-col` 排版,七项字段由 `el-descriptions` 展示,窄屏自动改为单列。商品查询、状态和业务事件继续由页面维护。
 
-## Paystack 邮箱确认
+## Paystack 支付确认
 
-`PaystackPaymentDialog.vue` 提取注册页原有的邮箱、金额条及 Continue to Paystack 展示,注册和会员购买共用现有 `UiDialog` 外壳。调用方传入 `visible`、`email`、`amount`、`currency`、`loading`;会员通过 `email.sync` 保留邮箱编辑,游客注册通过 `readonly-email` 保留只读。`before-close` 继续由页面处理,`continue` 事件调用页面自己的 Paystack SDK。
+`PaystackPaymentDialog.vue` 展示金额条及 Continue to Paystack 操作,注册、会员购买和游客购物共用现有 `UiDialog` 外壳。调用方传入 `visible`、`amount`、`currency`、`loading`,支付弹窗不再展示或编辑邮箱。`before-close` 继续由页面处理,`continue` 事件调用页面自己的 Paystack SDK。SDK 仍使用注册资料、会员资料或游客下单响应提供的邮箱。
 
 SDK 放在默认插槽内隐藏挂载;公共组件不查询接口、不创建或取消订单,也不转换支付金额。游客仍使用 GuestPaystack 的 accessCode,会员仍使用原 SDK、金额 ×100、metadata、reference、channels 和各自成功/取消回调。会员原有提交校验及支付密码步骤保持。
 

+ 20 - 6
src/ui-refactor/views/guest-shop/GuestPurchaseFlow.vue

@@ -34,6 +34,10 @@
         :disabled="locked || loading"
         @current-change="changePage"
       />
+      <p class="ng-guest-signup">
+        Want member pricing and BV rewards?
+        <router-link :to="{ path: '/signup', query: $route.query }">Create an account</router-link>
+      </p>
       <el-badge :value="count" :hidden="!count" class="ng-guest-fab">
         <el-button
           type="primary"
@@ -154,21 +158,18 @@
     </template>
     <paystack-payment-dialog
       :visible="emailVisible"
-      :email="form.email"
-      :readonly-email="!!pending"
       :amount="pending ? pending.amount : totals.total"
       :currency="pending ? pending.currency : currency"
       :loading="submitting || sdkActive"
-      :title="payType === 'pay_stack' ? 'Paystack Payment' : 'Confirm your email'"
+      :title="payType === 'pay_stack' ? 'Paystack Payment' : 'Confirm your order'"
       :note="
         payType === 'pay_stack'
-          ? 'Confirm your email to continue to the Paystack secure checkout.'
-          : 'Confirm your email to place your order.'
+          ? 'Continue to the Paystack secure checkout.'
+          : 'Continue to place your order.'
       "
       :continue-label="payType === 'pay_stack' ? 'Continue to Paystack' : 'Place order'"
       :before-close="closePayment"
       :close-on-press-escape="false"
-      @update:email="changeForm({ email: $event })"
       @continue="continuePayment"
     >
       <order-paystack
@@ -260,6 +261,19 @@ export default {
   font-size: 14px;
   line-height: 1.6;
 }
+.ng-guest-signup {
+  margin: 32px 0 0;
+  color: #707780;
+  font-size: 14px;
+  line-height: 1.6;
+  text-align: center;
+}
+.ng-guest-signup a {
+  color: #202259;
+  font-weight: 700;
+  text-decoration: underline;
+  text-underline-offset: 2px;
+}
 .ng-guest-alert {
   margin-bottom: 16px;
 }

+ 1 - 1
src/ui-refactor/views/guest-shop/GuestShopPage.vue

@@ -26,7 +26,7 @@ export default {
       const flow = this.$refs.flow
       if (flow && !flow.completed && (flow.locked || flow.emailVisible)) {
         this.$message.info(
-          'Complete the current order or close the email dialog before leaving. An unpaid order can be resumed here.'
+          'Complete the current order or close the payment dialog before leaving. An unpaid order can be resumed here.'
         )
         next(false)
       } else next()

+ 1 - 1
src/ui-refactor/views/guest-shop/OrderPaystack.js

@@ -39,7 +39,7 @@ export default {
             key: this.paystackkey,
             email: this.email,
             amount: this.amount,
-            currency: this.currency,
+            currency: 'NGN',
             ref: this.reference,
             metadata: this.metadata,
             channels: this.channels,

+ 4 - 4
src/ui-refactor/views/guest-shop/README.md

@@ -25,13 +25,13 @@
 
 下单只发送 `countryId / goodsId / goodsNum / email / payType / consignee / acceptMobile / province / lgaName / cityName / detailaddress`。手机号区号跟随国家显示,`acceptMobile` 仍传用户输入值,`province` 保留地区路径数组。不发送会员编号、报单中心、支付密码或会员地址 ID。
 
-游客商品卡片、购物车单价/行金额、结账汇总与税额统一使用接口 `MARKET_PRICE`,不套用会员销售价或折扣;保留原含税算法及免运费阈值,税不再叠加到应付金额。游客和注册详情隐藏 Sales Price,登录后的展示与计价保持原样。商品、购物车和结账展示优先使用商品 `COIN`,结算配置的 `coin` 只作兜底;两个 GET 的返回顺序不影响商品币种。Place order 先验证地址,再确认邮箱,最后下单。非 Paystack 以匿名下单成功返回的 SN 进入公开详情页。
+游客商品卡片、购物车单价/行金额、结账汇总与税额统一使用接口 `MARKET_PRICE`,不套用会员销售价或折扣;保留原含税算法及免运费阈值,税不再叠加到应付金额。游客和注册详情隐藏 Sales Price,登录后的展示与计价保持原样。商品、购物车和结账展示优先使用商品 `COIN`,结算配置的 `coin` 只作兜底;两个 GET 的返回顺序不影响商品币种。Place order 先验证地址,再确认金额并下单,不再要求输入邮箱;下单请求保留 `email` 字段为空字符串。非 Paystack 以匿名下单成功返回的 SN 进入公开详情页。
 
-匿名下单实际可返回订单记录 `SN / PAY_AMOUNT / ORDER_AMOUNT / COUNTRY_ID / CURRENCY_ID`:金额优先取 `PAY_AMOUNT`,缺失时取 `ORDER_AMOUNT`,不使用 `_STANDARD` 字段或 `EXCHANGE_RATE` 换算。订单未返回 ISO 币种代码时,必须先核对 `COUNTRY_ID` 和当前国家,再用 `CURRENCY_ID` 匹配所选商品的 `LOCAL_CURRENCY_ID`,使用该商品的 `COIN`;无法匹配时保留订单并阻止支付。继续兼容原 `SN / amount / currency`,显式返回的 `amount / currency` 优先。返回 `EMAIL` 为空时仍使用表单内已确认的邮箱。
+匿名下单实际可返回订单记录 `SN / PAY_AMOUNT / ORDER_AMOUNT / COUNTRY_ID / CURRENCY_ID`:金额优先取 `PAY_AMOUNT`,缺失时取 `ORDER_AMOUNT`,不使用 `_STANDARD` 字段或 `EXCHANGE_RATE` 换算。订单未返回 ISO 币种代码时,必须先核对 `COUNTRY_ID` 和当前国家,再用 `CURRENCY_ID` 匹配所选商品的 `LOCAL_CURRENCY_ID`,使用该商品的 `COIN`;无法匹配时保留订单并阻止支付。继续兼容原 `SN / amount / currency`,显式返回的 `amount / currency` 优先。Paystack 邮箱读取下单响应的 `EMAIL`;缺失或格式无效时保留已创建订单并提示联系客服,不发起 SDK,也不重复下单。真实接口能否接受空邮箱并返回有效 `EMAIL` 尚需联调确认。
 
-支付金额为主币单位,只在支付适配时转为最小单位一次。最终金额或币种变化时更新弹窗并要求再次确认,不自行换汇。`OrderPaystack` 继续复消 V1 的 SN / metadata 协议,并处理脚本失败、超时及 SDK 异常;不使用注册的 accessCode / draft 协议。响应中的 `STATUS / PAY_AT` 不作为前端确认已付款的依据。
+支付金额为主币单位,只在支付适配时转为最小单位一次。最终金额或币种变化时更新弹窗并要求再次确认,不自行换汇。按 2026-10-27 用户要求,`OrderPaystack` 调用 V1 SDK `setup` 时的 `currency` 固定传 `NGN`,不区分国家;金额数值及商品、订单页面的币种展示保持原逻辑。继续复消 V1 的 SN / metadata 协议,并处理脚本失败、超时及 SDK 异常;不使用注册的 accessCode / draft 协议。响应中的 `STATUS / PAY_AT` 不作为前端确认已付款的依据。
 
-请求期间防止重复提交。关闭支付保留 SN,重开只恢复支付,不重复 POST,也不调用会员取消接口;未付单存在时锁定商品、地址、邮箱和支付方式。异步响应和 SDK 回调受组件生命周期与本次支付序号约束。
+请求期间防止重复提交。关闭支付保留 SN,重开只恢复支付,不重复 POST,也不调用会员取消接口;未付单存在时锁定商品、地址和支付方式。异步响应和 SDK 回调受组件生命周期与本次支付序号约束。
 
 `/guest-order?order=<SN>` 在进入、刷新和订单参数变化时调用匿名详情接口,传 `orderSn`,响应为 `{ order, goods }`。订单号必须与请求一致;加载中清除旧明细,失败可重试,离开页面或更换订单后忽略旧响应。`GuestOrderPage` 管理请求、下载与复制,`GuestOrderDetails` 负责展示;卡片复用 `UiSectionCard`,图片、按钮和状态使用 Element UI。
 

+ 8 - 7
src/ui-refactor/views/guest-shop/__tests__/verifyBrowser.cjs

@@ -81,11 +81,11 @@ async function main() {
           assert.equal(request.method(), 'POST')
           const params = request.postDataJSON()
           assert(!('payPassword' in params) && !('userName' in params) && !('decUserName' in params))
-          assert.equal(params.email, 'visitor@example.test')
+          assert.equal(params.email, '')
           orders.push(params)
           data = params.countryId === ids.ae
-            ? { SN: 'SAMPLE-ORDER-' + orders.length, amount: 10, currency: 'USD' }
-            : { SN: 'SAMPLE-ORDER-' + orders.length, DEC_SN: 'SAMPLE-DECLARATION', COUNTRY_ID: ids.ng, CURRENCY_ID: '104', ORDER_AMOUNT: 130, PAY_AMOUNT: 130, PAY_FREIGHT: 0, PAY_AMOUNT_STANDARD: 0.075, EXCHANGE_RATE: '1200', EMAIL: '', STATUS: 1 }
+            ? { SN: 'SAMPLE-ORDER-' + orders.length, amount: 10, currency: 'USD', EMAIL: 'visitor@example.test' }
+            : { SN: 'SAMPLE-ORDER-' + orders.length, DEC_SN: 'SAMPLE-DECLARATION', COUNTRY_ID: ids.ng, CURRENCY_ID: '104', ORDER_AMOUNT: 130, PAY_AMOUNT: 130, PAY_FREIGHT: 0, PAY_AMOUNT_STANDARD: 0.075, EXCHANGE_RATE: '1200', EMAIL: 'visitor@example.test', STATUS: 1 }
         } else { unknown.push(api); return route.abort() }
         return route.fulfill({ contentType: 'application/json', body: JSON.stringify({ success: true, data: { data }}) })
       }
@@ -108,7 +108,7 @@ async function main() {
           const box = await page.locator('.el-dialog:visible').boundingBox()
           assert(box && box.x >= 0 && box.x + box.width <= width + 1, label + ' dialog overflow')
         }
-        if (width === 375 && height === 812 && /checkout|email|market|order/.test(label)) await page.screenshot({ path: path.join(output, label + '-mobile.png'), fullPage: true, animations: 'disabled' })
+        if (width === 375 && height === 812 && /checkout|payment|market|order/.test(label)) await page.screenshot({ path: path.join(output, label + '-mobile.png'), fullPage: true, animations: 'disabled' })
         checks.push({ label, width, height })
       }
       await page.setViewportSize({ width: 1440, height: 900 })
@@ -162,10 +162,11 @@ async function main() {
       await page.locator('#ng-guest-detailaddress').fill('Sample street')
       await layouts(market + '-checkout')
       await page.getByRole('button', { name: 'Place order', exact: true }).click()
-      await page.locator('#ng-paystack-payment-email').fill('visitor@example.test')
+      assert.equal(await page.locator('.ng-paystack-payment-dialog input').count(), 0)
       assert((await page.locator('.ng-paystack-payment-amount strong').textContent()).includes(currency + ' 130'))
-      await layouts(market + '-email', true)
-      await page.getByRole('button', { name: 'Continue to Paystack', exact: true }).click()
+      await layouts(market + '-payment', true)
+      await page.getByRole('button', { name: 'Continue to Paystack', exact: true }).focus()
+      await page.keyboard.press('Enter')
       if (market === 'ae') {
         await page.locator('.ng-paystack-payment-amount strong').filter({ hasText: 'USD 10' }).waitFor()
         assert.equal(await page.evaluate(() => !!window.samplePaymentOpened), false)

+ 4 - 4
src/ui-refactor/views/guest-shop/guestPurchase.js

@@ -333,10 +333,6 @@ export default {
         return
       }
       if (!this.canCheckout || !this.regionsReady || !validShipping(this.form)) return
-      if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.form.email.trim())) {
-        this.fail('Please enter a valid email address.')
-        return
-      }
       if (!this.payList.some(item => item.label === this.payType)) return
       this.submitting = true
       this.error = ''
@@ -374,6 +370,7 @@ export default {
           amount: data.amount ?? data.PAY_AMOUNT ?? data.ORDER_AMOUNT,
           currency: data.currency ?? currencyProduct?.COIN
         }
+        this.form.email = typeof data.EMAIL === 'string' ? data.EMAIL.trim() : ''
         this.pending = paymentOrder(this.pending)
         if (this.pending.amount !== this.totals.total || this.pending.currency !== this.currency) {
           this.$message.info(
@@ -391,6 +388,9 @@ export default {
     async startPayment() {
       try {
         this.pending = paymentOrder(this.pending)
+        if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.form.email)) {
+          throw new Error('The order did not return a valid payment email. Please contact customer service with your order number.')
+        }
         this.paymentAttempt++
         this.sdkActive = true
         await this.$nextTick()

+ 0 - 1
src/ui-refactor/views/purchase/PurchaseFlow.vue

@@ -318,7 +318,6 @@
     </template>
     <paystack-payment-dialog
       :visible="visible"
-      :email.sync="payment.email"
       :amount="payment.amount"
       :currency="payment.currency"
       :loading="cancelLoading"

+ 4 - 8
src/ui-refactor/views/purchase/__tests__/PurchaseFlow.spec.js

@@ -590,18 +590,14 @@ it.each(submissions)('%s retains its draft on failed payment and cancels the cor
   expect(vm.payment.amount).toBe(vm.isUpgrade ? 200 : '170.00')
   const dialog = vm.$children.find(child => child.$options.name === 'PaystackPaymentDialog').$el
   expect(dialog.querySelector('.el-dialog__title').textContent).toBe('Paystack Payment')
-  expect(dialog.textContent).toContain('Confirm your email to continue to the Paystack secure checkout.')
+  expect(dialog.textContent).toContain('Continue to the Paystack secure checkout.')
   expect(dialog.querySelector('.ng-paystack-payment-amount strong').textContent).toBe(vm.isUpgrade ? 'NGN 200' : 'NGN 170')
   expect(vm.$refs.paystack.amount).toBe(Number(vm.payment.amount) * 100)
   expect(vm.$refs.paystack.metadata).toBe(vm.payment.metadata)
   expect(vm.$refs.paystack.reference).toBe(vm.reference + vm.paymentAttempt)
-  const email = dialog.querySelector('#ng-paystack-payment-email')
-  expect(email.readOnly).toBe(false)
-  email.value = 'confirmed@example.test'
-  email.dispatchEvent(new Event('input', { bubbles: true }))
-  await settle()
-  expect(vm.payment.email).toBe('confirmed@example.test')
-  expect(vm.$refs.paystack.email).toBe('confirmed@example.test')
+  expect(dialog.querySelector('input')).toBeNull()
+  expect(vm.payment.email).toBe('operator@example.test')
+  expect(vm.$refs.paystack.email).toBe('operator@example.test')
   dialog.querySelector('.ng-paystack-payment-continue').click()
   expect(vm.$refs.paystack.$options.methods.payWithPaystack).toHaveBeenCalledTimes(1)
   expect(vm.mayLeave({ path: '/dashboard/index' })).toBe(false)

+ 0 - 2
src/ui-refactor/views/signup/components/SignupDialogs.vue

@@ -2,10 +2,8 @@
   <div class="ng-signup-dialogs">
     <paystack-payment-dialog
       :visible="paymentVisible"
-      :email="paymentEmail"
       :amount="paymentOrder.amount"
       :currency="paymentOrder.currency"
-      readonly-email
       :before-close="cancelPayment"
       @continue="$refs.paystack.payWithPaystack()"
     >

+ 0 - 1
src/ui-refactor/views/welcome-pack/MemberWelcomePack.vue

@@ -71,7 +71,6 @@
       :currency="currencyUnitCode"
       @cancel="handleClose"
       @paid="processPayment"
-      @email="payForm.email = $event"
       @orders="handleOrderList"
       @close-product="visibleProduct = false"
     />

+ 0 - 7
src/ui-refactor/views/welcome-pack/WelcomePackDialogs.vue

@@ -10,13 +10,6 @@
       :show-close="!cancelLoading"
     >
       <el-form v-loading="cancelLoading" label-position="top" @submit.native.prevent>
-        <el-form-item label="Email" for="ng-welcome-payment-email">
-          <el-input
-            id="ng-welcome-payment-email"
-            :value="payment.email"
-            @input="$emit('email', $event)"
-          />
-        </el-form-item>
         <el-form-item label="Amount">
           <el-input :value="payment.currency + ' ' + payment.amount" readonly />
         </el-form-item>

+ 4 - 3
src/ui-refactor/views/welcome-pack/__tests__/MemberWelcomePack.spec.js

@@ -187,9 +187,10 @@ it('keeps member Paystack amount conversion, email and channels without the gues
   expect(sdk.email).toBe('pay@example.test')
   expect(sdk.currency).toBe('NGN')
   const dialogs = descendants(vm).find(child => child.$options.name === 'WelcomePackDialogs')
-  dialogs.$emit('email', 'updated@example.test')
-  await settle()
-  expect(vm.payForm.email).toBe('updated@example.test')
+  const paymentDialog = descendants(dialogs).find(child => child.$options.name === 'UiDialog').$el
+  expect(paymentDialog.textContent).toContain('Amount')
+  expect(paymentDialog.querySelector('#ng-welcome-payment-email')).toBeNull()
+  expect(vm.payForm.email).toBe('pay@example.test')
 })
 
 it('ignores a delayed callback belonging to a cancelled order', async() => {

+ 29 - 15
tests/unit/ui-refactor/guestShop.spec.js

@@ -10,7 +10,7 @@ jest.mock('@/router', () => ({ push: jest.fn(), replace: jest.fn() }))
 
 const product = { ID: 'P1', GOODS_NAME: 'Product', SELL_PRICE: 100, MARKET_PRICE: 120, DISCOUNT: 80, STORE_NUMS: 5, TAX_RATE: 7.5, COIN: 'NGN' }
 const instances = []
-const shipping = { consignee: 'Recipient', acceptMobile: '123456789', province: ['R1'], lgaName: 'District', cityName: 'City', detailaddress: 'Street', email: 'guest@example.test' }
+const shipping = { consignee: 'Recipient', acceptMobile: '123456789', province: ['R1'], lgaName: 'District', cityName: 'City', detailaddress: 'Street' }
 async function settle() { for (let i = 0; i < 12; i++) { await Promise.resolve(); await Vue.nextTick() } }
 async function instance(market = 'ng', stage = 'catalog') {
   const vm = new (Vue.extend(behavior))({ propsData: { market, stage }})
@@ -36,7 +36,7 @@ beforeEach(() => {
   shop.fetchGuestProducts.mockResolvedValue({ data: { list: [product], totalCount: 1 }})
   shop.fetchGuestCart.mockResolvedValue({ data: { sellType: [{ id: 1, sell_type: [{ label: 'pay_stack', name: 'Paystack' }] }], freight: 10, freeShipping: 500, coin: 'NGN' }})
   getGuestRegionList.mockResolvedValue({ data: [{ value: 'R1', label: 'Region' }] })
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'ORDER1', amount: 130, currency: 'NGN' }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'ORDER1', amount: 130, currency: 'NGN', EMAIL: 'guest@example.test' }})
 })
 afterEach(() => { instances.splice(0).forEach(vm => vm.$destroy()) })
 
@@ -124,22 +124,36 @@ it('keeps selections across pages and rejects unavailable or fractional quantiti
   vm.toggleProduct({ ...product, ID: 'P3', STORE_NUMS: 0 })
   expect(vm.items).toHaveLength(2)
 })
-it('requires shipping and email before calling the order API, with no passwords or member identity', async() => {
+it('requires shipping but no email input before calling the order API, with no passwords or member identity', async() => {
   const vm = await instance()
   vm.toggleProduct(product)
   vm.stage = 'checkout'
   await settle()
   vm.openEmail()
   expect(vm.emailVisible).toBe(false)
-  Object.assign(vm.form, shipping, { email: 'invalid' })
+  Object.assign(vm.form, shipping)
   vm.openEmail()
   await vm.continuePayment()
-  expect(shop.createGuestOrder).not.toHaveBeenCalled()
-  vm.form.email = shipping.email
-  await vm.continuePayment()
-  expect(shop.createGuestOrder).toHaveBeenCalledWith({ ...shipping, countryId: '620699181539139625', goodsId: ['P1'], goodsNum: [1], payType: 'pay_stack' })
+  expect(shop.createGuestOrder).toHaveBeenCalledWith({ ...shipping, email: '', countryId: '620699181539139625', goodsId: ['P1'], goodsNum: [1], payType: 'pay_stack' })
+  expect(vm.form.email).toBe('guest@example.test')
   expect(vm.$refs.paystack.payWithPaystack).toHaveBeenCalledTimes(1)
 })
+it.each([undefined, '', 'invalid', null, 123])('retains the order and reports a missing or invalid server payment email %s without creating another order', async email => {
+  const vm = await checkout()
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'ORDER1', amount: 130, currency: 'NGN', EMAIL: email }})
+  await vm.continuePayment()
+  expect(shop.createGuestOrder).toHaveBeenCalledTimes(1)
+  expect(vm.pending.SN).toBe('ORDER1')
+  expect(vm.sdkActive).toBe(false)
+  expect(vm.submitting).toBe(false)
+  expect(vm.$refs.paystack.payWithPaystack).not.toHaveBeenCalled()
+  expect(vm.$message.error).toHaveBeenCalledWith('The order did not return a valid payment email. Please contact customer service with your order number.')
+  vm.closePayment()
+  vm.openEmail()
+  await vm.continuePayment()
+  expect(shop.createGuestOrder).toHaveBeenCalledTimes(1)
+  expect(vm.$refs.paystack.payWithPaystack).not.toHaveBeenCalled()
+})
 it('blocks duplicate submit and retains the same unpaid order after cancellation', async() => {
   const vm = await checkout()
   let resolve
@@ -147,7 +161,7 @@ it('blocks duplicate submit and retains the same unpaid order after cancellation
   const first = vm.continuePayment()
   await vm.continuePayment()
   expect(shop.createGuestOrder).toHaveBeenCalledTimes(1)
-  resolve({ data: { SN: 'ORDER1', amount: 130, currency: 'NGN' }})
+  resolve({ data: { SN: 'ORDER1', amount: 130, currency: 'NGN', EMAIL: 'guest@example.test' }})
   await first
   const callback = vm.paymentCallback
   vm.closePayment()
@@ -166,7 +180,7 @@ it('blocks duplicate submit and retains the same unpaid order after cancellation
 })
 it('requires review of a changed server payment amount and currency before starting the SDK', async() => {
   const vm = await checkout()
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'ORDER1', amount: 10, currency: 'USD' }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'ORDER1', amount: 10, currency: 'USD', EMAIL: 'guest@example.test' }})
   await vm.continuePayment()
   expect(vm.pending.currency).toBe('USD')
   expect(vm.$refs.paystack.payWithPaystack).not.toHaveBeenCalled()
@@ -185,12 +199,12 @@ it.each([
   vm.stage = 'checkout'
   await settle()
   vm.openEmail()
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', DEC_SN: 'DECLARATION1', COUNTRY_ID: countryId, CURRENCY_ID: currencyId, PAY_AMOUNT: 130, ORDER_AMOUNT: 150, PAY_AMOUNT_STANDARD: 0.075, EXCHANGE_RATE: '1200', EMAIL: '', STATUS: 1 }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', DEC_SN: 'DECLARATION1', COUNTRY_ID: countryId, CURRENCY_ID: currencyId, PAY_AMOUNT: 130, ORDER_AMOUNT: 150, PAY_AMOUNT_STANDARD: 0.075, EXCHANGE_RATE: '1200', EMAIL: '  guest@example.test  ', STATUS: 1 }})
   await vm.continuePayment()
   expect(vm.pending).toEqual({ SN: 'RECORD1', amount: 130, currency, subunits: 13000 })
   expect(vm.$refs.paystack.payWithPaystack).toHaveBeenCalledTimes(1)
   expect(vm.metadata.cart_id).toBe('RECORD1')
-  expect(vm.form.email).toBe(shipping.email)
+  expect(vm.form.email).toBe('guest@example.test')
   expect(vm.$router.push).not.toHaveBeenCalled()
   vm.closePayment()
   vm.openEmail()
@@ -201,15 +215,15 @@ it.each([
 it('accepts ORDER_AMOUNT when the returned order record has no PAY_AMOUNT', async() => {
   shop.fetchGuestProducts.mockResolvedValue({ data: { list: [{ ...product, LOCAL_CURRENCY_ID: '104' }], totalCount: 1 }})
   const vm = await checkout()
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', ORDER_AMOUNT: 130 }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', ORDER_AMOUNT: 130, EMAIL: 'guest@example.test' }})
   await vm.continuePayment()
   expect(vm.pending).toEqual({ SN: 'RECORD1', amount: 130, currency: 'NGN', subunits: 13000 })
   expect(vm.$refs.paystack.payWithPaystack).toHaveBeenCalledTimes(1)
 })
-it('updates the email amount and requests confirmation when the order record changes the total', async() => {
+it('updates the payment amount and requests confirmation when the order record changes the total', async() => {
   shop.fetchGuestProducts.mockResolvedValue({ data: { list: [{ ...product, LOCAL_CURRENCY_ID: '104' }], totalCount: 1 }})
   const vm = await checkout()
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', PAY_AMOUNT: 95 }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'RECORD1', COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', PAY_AMOUNT: 95, EMAIL: 'guest@example.test' }})
   await vm.continuePayment()
   expect(vm.pending.amount).toBe(95)
   expect(vm.$refs.paystack.payWithPaystack).not.toHaveBeenCalled()

+ 5 - 5
tests/unit/ui-refactor/guestShopPaystack.spec.js

@@ -7,8 +7,8 @@ jest.mock('vue-paystack', () => ({
   render: h => h('button')
 }))
 const instances = []
-function instance() {
-  const vm = new (Vue.extend(OrderPaystack))({ propsData: { paystackkey: 'test-key', email: 'guest@example.test', amount: 29, currency: 'USD', reference: 'guest-ORDER1-1', metadata: { cart_id: 'ORDER1' }, channels: ['card'], callback: jest.fn(), close: jest.fn() }})
+function instance(currency = 'USD') {
+  const vm = new (Vue.extend(OrderPaystack))({ propsData: { paystackkey: 'test-key', email: 'guest@example.test', amount: 29, currency, reference: 'guest-ORDER1-1', metadata: { cart_id: 'ORDER1' }, channels: ['card'], callback: jest.fn(), close: jest.fn() }})
   instances.push(vm)
   return vm
 }
@@ -17,13 +17,13 @@ afterEach(() => {
   document.querySelectorAll('script[src="https://js.paystack.co/v1/inline.js"]').forEach(script => script.remove())
   delete window.PaystackPop
 })
-it('uses the existing V1 SN metadata contract and never scales subunits again', async() => {
+it.each(['NGN', 'AED', 'USD'])('always sends NGN for source currency %s, preserving V1 metadata and subunits', async currency => {
   const openIframe = jest.fn()
   window.PaystackPop = { setup: jest.fn(() => ({ openIframe })) }
-  const vm = instance()
+  const vm = instance(currency)
   await vm.payWithPaystack()
   const options = window.PaystackPop.setup.mock.calls[0][0]
-  expect(options).toMatchObject({ amount: 29, currency: 'USD', email: 'guest@example.test', ref: 'guest-ORDER1-1', metadata: { cart_id: 'ORDER1' }})
+  expect(options).toMatchObject({ amount: 29, currency: 'NGN', email: 'guest@example.test', ref: 'guest-ORDER1-1', metadata: { cart_id: 'ORDER1' }})
   options.callback({ reference: 'guest-ORDER1-1' })
   options.onClose()
   expect(vm.callback).toHaveBeenCalledTimes(1)

+ 7 - 10
tests/unit/ui-refactor/guestShopUi.spec.js

@@ -16,6 +16,7 @@ jest.mock('vue-paystack', () => ({
   render: h => h('button')
 }))
 Vue.use(ElementUI)
+Vue.component('RouterLink', { render(h) { return h('a', this.$slots.default) } })
 Vue.filter('toThousandFilter', toThousandFilter)
 const push = jest.fn()
 Vue.prototype.$router = { push, replace: jest.fn() }
@@ -72,7 +73,7 @@ it('connects product, cart and checkout controls without guest BV or member fiel
   const vm = mount(Flow, { market: 'ae', stage: 'catalog' })
   await settle()
   expect(vm.$el.querySelector('.ng-signup-product-price').textContent).toContain('AED 150')
-  expect(vm.$el.textContent).not.toContain('BV')
+  expect(vm.$el.querySelector('.ng-signup-products').textContent).not.toContain('BV')
   vm.$el.querySelector('.ng-signup-product-add').click()
   await settle()
   vm.stage = 'cart'
@@ -98,12 +99,8 @@ it('connects product, cart and checkout controls without guest BV or member fiel
   await settle()
   const dialog = vm.$children.find(child => child.$options.name === 'PaystackPaymentDialog')
   expect(dialog.visible).toBe(true)
-  expect(dialog.readonlyEmail).toBe(false)
-  const input = dialog.$el.querySelector('#ng-paystack-payment-email')
-  input.value = 'visitor@example.test'
-  input.dispatchEvent(new Event('input', { bubbles: true }))
-  await settle()
-  expect(vm.form.email).toBe('visitor@example.test')
+  expect(dialog.$el.querySelector('input')).toBeNull()
+  expect(dialog.$el.textContent).not.toContain('Confirm your email')
   expect(dialog.$el.querySelector('[type=password]')).toBeNull()
 })
 it('keeps Nigeria merchandise, cart, checkout and email amounts in the product currency', async() => {
@@ -126,19 +123,19 @@ it('keeps Nigeria merchandise, cart, checkout and email amounts in the product c
   expect(dialog.visible).toBe(true)
   expect(dialog.$el.querySelector('.ng-paystack-payment-amount').textContent).toContain('NGN 130')
 })
-it('opens Paystack with the order record amount, product currency and entered email', async() => {
+it('opens Paystack with the order record amount, product currency and server email without user input', async() => {
   const openIframe = jest.fn()
   window.PaystackPop = { setup: jest.fn(() => ({ openIframe })) }
   shop.fetchGuestProducts.mockResolvedValue({ data: { list: [{ ID: 'P1', GOODS_NAME: 'Nigeria product', SELL_PRICE: 62500, MARKET_PRICE: 50000, DISCOUNT: 80, TAX_RATE: 7.5, STORE_NUMS: 5, COIN: 'NGN', LOCAL_CURRENCY_ID: '104' }], totalCount: 1 }})
   shop.fetchGuestCart.mockResolvedValue({ data: { sellType: [{ id: 1, sell_type: [{ label: 'pay_stack', name: 'Paystack' }] }], freight: 0, freeShipping: 0, coin: 'NGN' }})
-  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'SAMPLE-ORDER', DEC_SN: 'SAMPLE-DECLARATION', ORDER_AMOUNT: 50000, PAY_AMOUNT: 50000, PAY_FREIGHT: 0, COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', EMAIL: '', STATUS: 1 }})
+  shop.createGuestOrder.mockResolvedValue({ data: { SN: 'SAMPLE-ORDER', DEC_SN: 'SAMPLE-DECLARATION', ORDER_AMOUNT: 50000, PAY_AMOUNT: 50000, PAY_FREIGHT: 0, COUNTRY_ID: '620699181539139625', CURRENCY_ID: '104', EMAIL: 'visitor@example.test', STATUS: 1 }})
   const vm = mount(Flow, { market: 'ng', stage: 'catalog' })
   vm.publicKey = 'sample-key'
   await settle()
   vm.toggleProduct(vm.products[0])
   vm.stage = 'checkout'
   await settle()
-  Object.assign(vm.form, { consignee: 'Recipient', acceptMobile: '123', province: ['R1'], lgaName: 'District', cityName: 'Lagos', detailaddress: 'Street', email: 'visitor@example.test' })
+  Object.assign(vm.form, { consignee: 'Recipient', acceptMobile: '123', province: ['R1'], lgaName: 'District', cityName: 'Lagos', detailaddress: 'Street' })
   vm.$el.querySelector('.ng-purchase-place-order').click()
   await settle()
   const dialog = descendants(vm).find(child => child.$options.name === 'PaystackPaymentDialog')

+ 6 - 14
tests/unit/ui-refactor/paystackPaymentDialog.spec.js

@@ -16,38 +16,30 @@ afterEach(() => {
   jest.useRealTimers()
 })
 
-it.each([false, true])('preserves editable/readonly email and delegates payment and cancellation (readonly=%s)', async readonlyEmail => {
-  const changed = jest.fn()
+it('shows payment details without email input and delegates payment and cancellation', async() => {
   const continued = jest.fn()
   const cancelled = jest.fn()
   const vm = new Vue({
-    data: () => ({ visible: true, email: 'member@example.test', loading: false }),
+    data: () => ({ visible: true, loading: false }),
     render(h) {
       return h(PaymentDialog, {
-        props: { visible: this.visible, email: this.email, amount: 104000, currency: 'NGN', readonlyEmail, loading: this.loading },
+        props: { visible: this.visible, amount: 104000, currency: 'NGN', loading: this.loading },
         attrs: { 'before-close': cancelled, 'close-on-press-escape': false },
-        on: { 'update:email': value => { this.email = value; changed(value) }, continue: continued }
+        on: { continue: continued }
       })
     }
   }).$mount()
   document.body.appendChild(vm.$el)
   instances.push(vm)
   await settle()
-  const input = vm.$el.querySelector('input')
-  expect(input.value).toBe('member@example.test')
-  expect(input.readOnly).toBe(readonlyEmail)
+  expect(vm.$el.querySelector('input')).toBeNull()
+  expect(vm.$el.querySelector('.ng-paystack-payment-note').textContent).toBe('Continue to the Paystack secure checkout.')
   expect(vm.$el.querySelector('.ng-paystack-payment-amount').textContent).toContain('NGN 104,000')
-  if (!readonlyEmail) {
-    input.value = 'confirmed@example.test'
-    input.dispatchEvent(new Event('input', { bubbles: true }))
-    expect(changed).toHaveBeenCalledWith('confirmed@example.test')
-  }
   const button = vm.$el.querySelector('.ng-paystack-payment-continue')
   button.click()
   expect(continued).toHaveBeenCalledTimes(1)
   vm.loading = true
   await settle()
-  expect(input.disabled).toBe(true)
   expect(button.disabled).toBe(true)
   expect(vm.$el.querySelector('.el-dialog__headerbtn')).toBeNull()
   button.click()