Skip to content

Instantly share code, notes, and snippets.

View nickhargreaves's full-sized avatar
👨‍💻

Nick Hargreaves nickhargreaves

👨‍💻
View GitHub Profile
class SpaceShip(models.Model):
# Sample merchant product
model = models.CharField(max_length=255, blank=False, null=False)
price = models.DecimalField(max_digits=99, decimal_places=2)
currency = models.CharField(max_length=55, default='KES', blank=False, null=False)
def __str__(self):
return self.model
@receiver(post_save, sender=Payment)
def call_payment_api(sender, instance, created, **kwargs):
if created:
# Initiate a Beyonic Collection Request to request money from the user
import beyonic
beyonic.api_key = settings.BEYONIC_API_KEY
response = beyonic.CollectionRequest.create(
phonenumber=instance.phone_number,
amount=instance.item.price,
currency=instance.item.currency,
class SpaceShipListView(ListView):
model = SpaceShip
class SpaceShipPayment(View):
def get(self, request, *args, **kwargs):
"""
Get the item_id and phone_number from request to create a new payment
:param request:
:param args:
{% load qr_code %}
<h1>SpaceShips</h1>
<ul>
{% for spaceship in object_list %}
<li>
{{ spaceship.model }}
{% qr_from_text spaceship.pk size=8 version=12 %}
</li>
{% empty %}
<li>No spaceships yet.</li>
class MainActivity : AppCompatActivity() {
private lateinit var mResultTextView: TextView
private lateinit var mPhonenumberTextView: TextView
private var b: Boolean? = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
import 'package:beyonic_flutter_library/beyonicservice.dart';
import 'package:beyonic_flutter_library/models/payments.dart';
beyonic_service = BeyonicService(apiKey: your_api_key);
// load list of payments
Future <List<Payment>> _payments = beyonic_service.load(Payment.all, offset: 0);
// load single payment
Future <Payment> _payment = beyonic_service.load(Payment.single);