Month: July 2018

1 Jul

Stripe alipay module for WHMCS

Stripe payment API integration with WHMCS is easy to do. This article covered payment using stripe with alipay.

1) First let’s create a source using the below code

 $response = \Stripe\Source::create(array(
      "type" => "alipay",
      "currency" => "usd",
      "amount" => $params['amount'] * 100,
      "metadata" => array(  
          "invoiceid" => $invoiceid,
          "userid" => $params['clientdetails']['userid'],
          "order_id" => $invoiceid . "_" . date( "YmdHis" )
      ),
      "redirect" => array(
        "return_url" => $systemUrl . "/modules/gateways/callback/stripe_alipay.php?invoiceid=$invoiceid"
      ),
    ));

2)Then we need to make use of the hook feature of stripe.

Hooks we have to use are
surce.chargeable, charge.succeeded.

From surce.chargeable we have to create charge as

 $charge = \Stripe\Charge::create(array(
        "amount" => $amount,
        "currency" => "usd",
        "source" => $source_id,
    ));

And then from charge.succeeded, We have to add transaction details as shown below.

    $source_meta_data = $event_json->data->object->source;
    $source_id = $event_json->data->object->id;
    $amount = ($event_json->data->object->amount) / (100.00);
    $invoiceid = $source_meta_data->metadata->invoiceid;
    $order_id = $source_meta_data->metadata->order_id;
    $userid = $source_meta_data->metadata->userid;
    $invoiceid = checkCbInvoiceID($invoiceid, "stripe_alipay");
    addInvoicePayment($invoiceid, $source_id, $amount, 0, "stripe_alipay");
    logTransaction("stripe_alipay", json_decode($body, true), "Successful");

This is a high level idea of the gateway module development.
If you would like to develop a stripe module or need more info, please contact from the link
Contact Us.
We will get back to you asap.