title: how to redirect back to my ionic app from a payment site
body: <p>Good everyone. Please I need your assistance. I am using a payment gateway that needs to redirect back to my ionic app after a successful transaction. But after a successful transaction, I am having this error message "can't post to localhost:8100/home" but when I use a site URL for example(<a href="https://siteurl.com" rel="nofollow noreferrer">https://siteurl.com</a>), it works by redirecting to the specified site. I don't know where I am getting it wrong and what will be the callback URL to my app. Here is my code. Thanks.</p>
  
  <pre><code>completePurchase() {
      this.loadingCtrl.create({
        message: "Order Processing...",
        showBackdrop: true
      }).then((overlay) =&gt; {
        this.loading = overlay;
        this.loading.present();
        let currentCustomerId = localStorage.getItem('currentUserId');
        if (this.paymentGatwayId == "tbz_rave") {
          this.rave.init(false, "PUBLIC_KEY") //true = production, false = test
            .then(_ =&gt; {
              var paymentObject = this.ravePayment.create({
                customer_email: this.user.email,
                amount: this.totalPrice,
                customer_firstname: `${this.user.first_name}`,
                customer_lastname: `${this.user.last_name}`,
                customer_phone: `${this.user.billing.phone}`,
                currency: "NGN",
                txref: "rave-1234550",
                redirect_url: "http://localhost:8100/home",
                meta: [{
                  metaname: "flightID",
                  metavalue: "AP1234"
  
                }]
              })
              this.rave.preRender(paymentObject)
                .then(secure_link =&gt; {
                  secure_link = secure_link + " ";
                  const browser: InAppBrowserObject = this.rave.render(secure_link, this.iab);
                  browser.on("loadstart")
                    .subscribe((event: InAppBrowserEvent) =&gt; {
                      if (event.url.indexOf('http://localhost:8100/home') != -1) {
  
                        if (event.url.includes("payment_successfull")) {
  
                          browser.close();
  
                          console.log("Transaction Succesful");
  
                          // Place order after payment successfull
                            let orderObj = {};
                      orderObj['payment_method'] = this.paymentGatwayId;
                      orderObj['payment_method_title'] = this.paymentGatewayTitle;
                      orderObj['customer_id'] = currentCustomerId;
                      this.platform.ready().then(() =&gt; {
                        this.address = {
                          first_name: this.user.first_name,
                          last_name: this.user.last_name,
                          address_1: this.user.billing.address_1,
                          city: this.user.billing.city,
                          address_2: this.user.billing.address_2,
                          phone: this.user.billing.phone,
                        }
                        orderObj['billing'] = this.address;
                        orderObj['line_items'] = this.baseProducts;
                        this.WC.placeOrder(orderObj).then(async (respData) =&gt; {
                          this.storage.clear();
                          this.storage.set('currentOrderData', respData);
                          console.log(orderObj);
                          //navigate after successful placing of other
                          const alert = await this.alertCtrl.create({
                            cssClass: 'my-custom-class',
                            header: 'Status',
                            message: ' &lt;strong&gt;Transaction successful&lt;/strong&gt;!',
                            buttons: [
                              {
                                text: 'Okay',
                                handler: () =&gt; {
                                  this.route.navigate(['/menu/order']);
                                }
                              }
                            ]
                          });
  
                          await alert.present()
  
                          this.route.navigate(['/menu/order']);
                        }).catch((error) =&gt; {
                          console.log('Problem with placing order', error);
                        });
                      });
  
                        } else {
                          browser.close();
                          console.log("Transaction fail");
  
                        }
                        browser.close()
                      }
                    })
                }).catch(error =&gt; {
                  // Error or invalid paymentObject passed in
                  console.log("error", error);
                })
            });
        }
      });
      setTimeout(() =&gt; {
  
        this.loading.dismiss();
      }, 5000);
    }
  </code></pre>
  
  <p><strong>Service page for placing an order after a successful transaction</strong> </p>
  
  <pre><code>placeOrder(orderDataObj){
    let headers = new HttpHeaders ({
      'Content-Type': 'application/x-www-form-urlencoded'
    });
  
    let orderData = this.JSON_to_URLEncoded(orderDataObj);
  
    this.apiUrl = `${this.siteUrl}${this.woocommercePath}orders?consumer_key=${this.consumerKey}&amp;consumer_secret=${this.consumerSecret}`;
    console.log('API URL for order: ', this.apiUrl);
  
    return new Promise ((resolve) =&gt; {
      this.orderResp = this.http.post(this.apiUrl,orderData, {headers});
      this.orderResp.subscribe((responseData) =&gt; {
        resolve(responseData);
      });
    });
  
  }
  </code></pre>