hopingsteam

doPayT.php

Jan 18th, 2021
626
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('display_errors',1);
  5. define("ERR_CODE_OK",0x00);
  6.  
  7. //live mode WSDL location
  8. //    $soap = new SoapClient('https://secure.mobilpay.ro/api/payment2/?wsdl', Array('cache_wsdl' => WSDL_CACHE_NONE));
  9. //test mode WSDL location
  10.     $soap = new SoapClient('http://sandboxsecure.mobilpay.ro/api/payment2/?wsdl', Array('cache_wsdl' => WSDL_CACHE_NONE));
  11. //your seller account identifier - available in your mobilPay account under Admin - Seller accounts - Edit - Security settings
  12.     $sacId ='<your_sac_id>';
  13.  
  14. // Pay example
  15.  
  16. $req = new stdClass();
  17.  
  18.     $account = new stdClass();
  19.     $account->id = $sacId;
  20.     $account->user_name = '<your_mobilPay_username>'; //please ask mobilPay to upgrade the necessary access required for token payments
  21.     $account->customer_ip = $_SERVER['REMOTE_ADDR']; //the IP address of the buyer.
  22.     $account->confirm_url = '<your_confirm_URL>';  //this is where mobilPay will send the payment result. This has priority over the SOAP call response
  23.  
  24.  
  25.     $transaction = new stdClass();
  26.     $transaction->paymentToken = '<the_payment_token>'; //you will receive this token together with its expiration date following a standard payment. Please store and use this token with maximum care
  27.  
  28.     $billing = new stdClass();
  29.     $billing->country = 'billing_country';
  30.     $billing->county = 'billing_county';
  31.     $billing->city = 'billing_city';
  32.     $billing->address = 'billing_address';
  33.     $billing->postal_code = 'billing_postal_code';
  34.     $billing->first_name = 'billing_first_name';
  35.     $billing->last_name = 'billing_last_name';
  36.     $billing->phone = 'billing_phone';
  37.     $billing->email = 'email_address';
  38. /*
  39.     $shipping = new stdClass();
  40.     $shipping->country = 'shipping_country';
  41.     $shipping->county = 'shipping_county';
  42.     $shipping->city = 'shipping_city';
  43.     $shipping->address = 'shipping_address';
  44.     $shipping->postal_code = 'shipping_postal_code';
  45.     $shipping->first_name = 'shipping_first_name';
  46.     $shipping->last_name = 'shipping_last_name';
  47.     $shipping->phone = 'shipping_phone';
  48.     $shipping->email = 'shipping_email';
  49. */
  50.  
  51.     $order = new stdClass();
  52.     $order->id = md5(uniqid(rand())); //your orderId. As with all mobilPay payments, it needs to be unique at seller account level
  53.     $order->description = 'desc'; //payment descriptor
  54.     $order->amount = XX.XX; // order amount; decimals present only when necessary, i.e. 15 not 15.00
  55.     $order->currency = 'RON'; //currency
  56.     $order->billing = $billing;
  57. //  $order->shipping = $shipping;
  58.  
  59.     $params = new stdClass();
  60.     $params->item = new stdClass();
  61.     $params->item->name = 'param1name';
  62.     $params->item->value = 'param1value';
  63.  
  64.     $account->hash = strtoupper(sha1(strtoupper(md5('<your_mobilPay_account_password')) . "{$order->id}{$order->amount}{$order->currency}{$account->id}"));
  65.  
  66.     $req->account = $account;
  67.     $req->order = $order;
  68.     $req->params = $params;
  69.     $req->transaction = $transaction;
  70.  
  71.     try
  72.     {
  73.         $response = $soap->doPayT(Array('request' => $req));
  74.         if (isset($response->errors) && $response->errors->code != ERR_CODE_OK)
  75.         {
  76.             throw new Exception($response->code, $response->message);
  77.         }
  78.     }
  79.     catch(SoapFault $e)
  80.     {
  81.         throw new Exception($e->faultstring);//, $e->faultcode, $e);
  82.     }  
  83. ?>
  84.  
RAW Paste Data