Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qr code #235

Merged
merged 2 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ $bankTransfer = $api->payment->fetch('pay_8JpVEWsoNPKdQh')->bankTransfer();
$bharatQR = $api->virtualAccount->create(array('receivers' => array('types' => array('qr_code')), 'description' => 'First QR code', 'amount_expected' => 100, 'notes' => array('receiver_key' => 'receiver_value'))); // Create Static QR
$bharatQR = $api->virtualAccount->create(array('receivers' => array('types' => array('qr_code')), 'description' => 'First QR code', 'notes' => array('receiver_key' => 'receiver_value'))); // Create Dynamic QR

// QR Code
$qrCode = $api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => "cust_HKsR5se84c5LTO","description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"))); // Create QR Code
$qrCode = $api->qrCode->create(array("type" => "upi_qr","name" => "Store_1", "usage" => "single_use","fixed_amount" => 1,"payment_amount" => 300,"customer_id" => "cust_HKsR5se84c5LTO","description" => "For Store 1","close_by" => 1681615838,"notes" => array("purpose" => "Test UPI QR code notes"),"tax_invoice" => array("number" => "INV001", "date" => 1589994898,"customer_name" => "Gaurav Kumar", "business_gstin"=> "06AABCU9605R1ZR","gst_amount" => 4000, "cess_amount" => 0, "supply_type" => "interstate"))); // Create QR Code GST
$closeQRCode = $api->qrCode->fetch('qr_HMsVL8HOpbMcjU')->close() // Close QR code
$qrCode = $api->qrCode->fetch('qr_HMsVL8HOpbMcjU') // Fetch particular QR code
$qrCode = $api->qrCode->all(["customer_id" => 'cust_HKsR5se84c5LTO']) // Fetch QR code for particular customer id
$qrCode = $api->qrCode->all(["payment_id" => 'pay_Di5iqCqA1WEHq6']) // Fetch QR code for particular payment id
$qrCode = $api->qrCode->all() // Fetch all QR code
$qrCode = $api->qrCode->fetch('qr_HMsVL8HOpbMcjU')->fetchAllPayments() // Fetch Payments for a QR Code

// Subscriptions
$plan = $api->plan->create(array('period' => 'weekly', 'interval' => 1, 'item' => array('name' => 'Test Weekly 1 plan', 'description' => 'Description for the weekly 1 plan', 'amount' => 600, 'currency' => 'INR')));
$plan = $api->plan->fetch('plan_7wAosPWtrkhqZw');
Expand Down
66 changes: 66 additions & 0 deletions src/QrCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Razorpay\Api;

class QrCode extends Entity
{
/**
* Create QR code
* @param array $attributes
* @return Entity|QrCode
*/
public function create($attributes = array())
{
$relativeUrl = "payments/". $this->getEntityUrl() ;

return $this->request('POST', $relativeUrl, $attributes);
}

/**
* Fetch QR code details based QR id
* @param $id
* @return Entity|QrCode
*/
public function fetch($id)
{
$relativeUrl = "payments/". $this->getEntityUrl(). $id ;

return $this->request('GET', $relativeUrl);
}

/**
* Close the QR code based on id
* @return Entity|QrCode
*/
public function close()
{
$relativeUrl = "payments/{$this->getEntityUrl()}{$this->id}/close" ;

return $this->request('POST', $relativeUrl);
}

/**
* Fetch all QR code details
* @param array $options
* @return Entity|QrCode
*/
public function all($options = array())
{
$relativeUrl = "payments/". $this->getEntityUrl();

return $this->request('GET', $relativeUrl, $options);
}

/**
* Fetch payments made to a QR Code based on QR id
* @param array $options
* @return Entity|QrCode
*/
public function fetchAllPayments($options = array())
{
$relativeUrl = "payments/{$this->getEntityUrl()}{$this->id}/payments" ;

return $this->request('GET', $relativeUrl, $options);
}

}