Search code examples
phpapipayment

Having an issue in moyasar payment APIs


Hi Friends I am working on moyasar payment API. I get stuck on posting the payment. I am following their API documentation. https://moyasar.com/docs/api/?shell#the-payment-object I have followed the documentation but still not getting success.

require_once 'vendor/autoload.php';    

Moyasar\Client::setApiKey("my secrete key");

$data = [
   "id"=> "d1d3-5f72-9056-191683f55872",
   "status"=> "paid",
   "amount"=> 88571,
   "fee"=> 1580,
   "currency"=> "SAR",
   "refunded"=> 0,
   "refunded_at"=> null,
   "description"=> null,
   "amount_format"=> "885.71 SAR",
   "fee_format"=> "15.80 SAR",
   "refunded_format"=> "0.00 SAR",
   "invoice_id"=> "a1be-5b13-a281-b27a4a6dad39",
   "ip"=> null,
   "callback_url"=> null,
   "created_at"=> "2016-05-11T17=>04=>17.000Z",
   "updated_at"=> "2016-05-12T17=>04=>19.633Z",
   "source"=> [
      "type"=> "creditcard",
      "company"=> "visa",
      "name"=> "Customer Name",
      "number"=> "xxxx-xxxx-xxxx-xxxx",
      "message"=> null,
      "transaction_url"=> null
   ]
];

try{
   $response = Moyasar\Client::post("https://api.moyasar.com/v1/payments", $data);
}
catch(Exception $ex){
   echo $ex->getMessage();
}

$data = json_decode($response);

echo '<pre>'.print_r($data, true).'</pre>';

I am getting Error

Client error: POST https://api.moyasar.com/v1/payments resulted in a 404 Not Found response: {"type":"api_error","message":"Object not found","errors":null}

If anyone can help, I will be really thankful.


Solution

  • if you go back to Moyasar's API documentation, you will find the following quote:

    You cannot create a payment through wrapper libraries unless you satisfy the requirements of PCI DSS Compliance and it applies to you. Check out create a payment via Moyasar payment form.

    Creating payments has been removed recently from the libraries

    To create a payment you may only use Moyasar form, which is described here: https://moyasar.com/docs/payments/create-payment/mpf/