0

I am new in ionic 4. I want to add alipay plugin in my ionic apps. I saw all the tutorial do like this only :

    import { Alipay } from '@ionic-native/alipay/ngx';

constructor(private alipay: Alipay) {

//alipayOrder is a string that has been generated and signed by the server side.
this.alipay.pay(alipayOrder)
   .then(result => {
      console.log(result); // Success
   })
   .catch(error => {
      console.log(error); // Failed
   });

}

But this only show the loading say openning the alipay but do not open the alipay page to pay. What I need to change inside the code? I want to send the total payment to use the alipay do payment

qing
  • 785
  • 1
  • 10
  • 24

1 Answers1

1

The documentation for the Ionic Native packages isn't really a full tutorial for implementing it. You need to have done it a few times to learn what it means.

  1. Go to the main Ionic Native community page and follow the generic setup instructions that all packages should have done:

  2. The first line of your snippet goes at the top

  3. The rest of this is just a rough outline of the API, but not a full guide to its use.

Often you can find more information by clicking through to the github repo.

From my investigation it has revealed that you need to install with an app_id variable:

cordova plugin add cordova-plugin-gubnoi-alipay --variable APP_ID=[your AppId]

Which means you need to sign up for a developer account with AliPay and have an app created on their platform.

The documentation also links out to this page:

Which has details for all of the types of parameters you can use to generate an order on their side which can be turned into a url like this:

var payInfo = "app_id=2015052600090779&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%221%22%2C%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%22IQJZSRC1YMQB5HU%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fdomain.merchant.com%2Fpayment_notify&sign_type=RSA2&timestamp=2016-08-25%2020%3A26%3A31&version=1.0&sign=cYmuUnKi5QdBsoZEAbMXVMmRWjsuUj%2By48A2DvWAVVBuYkiBj13CFDHu2vZQvmOfkjE0YqCUQE04kqm9Xg3tIX8tPeIGIFtsIyp%2FM45w1ZsDOiduBbduGfRo1XRsvAyVAv2hCrBLLrDI5Vi7uZZ77Lo5J0PpUUWwyQGt0M4cj8g%3D";

And then finally passed into the plugin to manage the payment process.

Also, it seems that you might have some success by contacting AliPay for specific questions.

[Update] How To Get An App ID

On this page it has these instructions:

enter image description here

So you need to go to the signup page and register a normal account and then find the option to upgrade it to a developer account.

After that you can register an app with the platform to get the id.

rtpHarry
  • 13,019
  • 4
  • 43
  • 64
  • thank you for your reply, Where can I get the APP_ID? – qing Jul 14 '19 at 10:26
  • added an extra reply – rtpHarry Jul 14 '19 at 10:48
  • I already sign up personal account, but after I sign up, it always need I verify the account. Is I need to sign up company account instead of my personal account? – qing Jul 14 '19 at 11:54
  • I'm sorry I'm not an alipay expert, I was just helping you to give you a framework for figuring out how to solve your own problem. I've never used the platform. I just tried to help you understand what you needed to do at a high level. Like I said, they have a support phone line, if you should probably contact them if you're stuck. – rtpHarry Jul 15 '19 at 04:25