<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Somto Anunobi</title>
    <description>The latest articles on DEV Community by Somto Anunobi (@somteacodes).</description>
    <link>https://dev.to/somteacodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F740033%2F6195d24f-ef88-4b50-bb17-8dba8391b901.jpeg</url>
      <title>DEV Community: Somto Anunobi</title>
      <link>https://dev.to/somteacodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/somteacodes"/>
    <language>en</language>
    <item>
      <title>Accept payments with Paystack in your vue 3 apps</title>
      <dc:creator>Somto Anunobi</dc:creator>
      <pubDate>Fri, 29 Oct 2021 22:58:35 +0000</pubDate>
      <link>https://dev.to/somteacodes/accept-payments-with-paystack-in-your-vue-3-apps-330p</link>
      <guid>https://dev.to/somteacodes/accept-payments-with-paystack-in-your-vue-3-apps-330p</guid>
      <description>&lt;p&gt;This post would be my first of both things&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First post on &lt;a href="https://dev.to"&gt;Dev.to&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;First &lt;a href="https://www.npmjs.com/package/vue3-paystack"&gt;npm package&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Paystack is an online payment processor for Africans, so if you are reading this. You are most likely familiar with Vue and want to accept payments in your Vue app.&lt;br&gt;
This post is not an exhaustive guide on how to use Paystack, a more detailed guide is here.&lt;/p&gt;

&lt;p&gt;If you happen to be using Vue 2, there is an existing plugin here&lt;br&gt;
While working on a Vue 3 app, I had many unsuccessful attempts to use the plugin intended for Vue 2. I quickly realized that I needed to write my solution to integrate Paystack into my app. &lt;/p&gt;

&lt;p&gt;In the spirit of sharing, I decided to host the solution on npm for anyone who might run into the same issues and contributors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RVm8zt_y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nz2k6g9rc437d66hoxk4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RVm8zt_y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nz2k6g9rc437d66hoxk4.png" alt="Vue 3 paystack" width="763" height="356"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;You can install the package via the node package manager by running the following command in your terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="nx"&gt;vue3&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;paystack&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;To use in your app, you import with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;paystack&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vue3-paystack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  component
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;paystack&lt;/span&gt;
   &lt;span class="nx"&gt;buttonClass&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'button-class btn btn-primary'&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
   &lt;span class="nx"&gt;buttonText&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Pay Online&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;publicKey&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;amount&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;reference&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;reference&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;onSuccess&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;onSuccessfulPayment&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
   &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;onCanel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;onCancelledPayment&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/paystack&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Some useful props
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Type &amp;amp; Description&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;buttonClass&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;String&lt;/code&gt; CSS class names for the button, to style the component&lt;/td&gt;
&lt;td&gt;&lt;code&gt;""&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;buttonText&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;String&lt;/code&gt; Displayed text for the button&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"Pay Now"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;publicKey&lt;/code&gt; &lt;em&gt;required&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;String&lt;/code&gt;  Public key from your &lt;a href="https://dashboard.paystack.com"&gt;Paystack developer dashboard&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;email&lt;/code&gt; &lt;em&gt;required&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;String&lt;/code&gt;Email of user making payment&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;amount&lt;/code&gt; &lt;em&gt;required&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Number&lt;/code&gt; in lowest denomition, so payment is &lt;code&gt;500 Naira&lt;/code&gt;, the amount pass should be &lt;code&gt;500*100 = 5000&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;reference&lt;/code&gt; &lt;em&gt;required&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;String&lt;/code&gt; a randomly generated code, made up of characters and numbers&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;currency&lt;/code&gt;  &lt;em&gt;required&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;String&lt;/code&gt; International payments are supported&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"NGN"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onSuccess&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Function&lt;/code&gt; Function that gets called when the transaction is successful&lt;/td&gt;
&lt;td&gt;&lt;code&gt;function() { console.log(response); }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;onCancel&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Function&lt;/code&gt; Function that gets called when the transaction is cancelled&lt;/td&gt;
&lt;td&gt;&lt;code&gt;function() { console.log("payment closed"); }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;channels&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Array&lt;/code&gt; Sets up the payment channels&lt;/td&gt;
&lt;td&gt;&lt;code&gt;function() { return ["card", "bank", "ussd", "qr", "mobile_money"]; }&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The component is fully stylable, hence the need to pass in the text and the CSS classes via props for the component to inherit.&lt;/p&gt;

&lt;p&gt;This is not an official plugin from paystack, but rather my own solution, you can read more about this plugin &lt;a href="https://vue3paystack.netlify.app/"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  I'd love the attention
&lt;/h2&gt;

&lt;p&gt;You can contribute, suggest features or just star the project on &lt;a href="https://github.com/somteacodes/vue3-paystack"&gt;Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>paystack</category>
      <category>vue</category>
      <category>payments</category>
    </item>
  </channel>
</rss>
